Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Aug 2014 11:23:44 -0500
From:      Alan Cox <alan.l.cox@gmail.com>
To:        David Chisnall <theraven@freebsd.org>
Cc:        Adrian Chadd <adrian@freebsd.org>, performance@freebsd.org, "current@freebsd.org" <current@freebsd.org>, John Baldwin <jhb@freebsd.org>, freebsd-current <freebsd-current@freebsd.org>, Konstantin Belousov <kostikbel@gmail.com>
Subject:   Re: PostgreSQL performance on FreeBSD
Message-ID:  <CAJUyCcPomwaWk-xEdovz9nBkdgAcZ48mCvB3szWH4hWZGQExmw@mail.gmail.com>
In-Reply-To: <DD742BF5-09DF-4399-B247-1E36F1CC46F5@FreeBSD.org>
References:  <20140627125613.GT93733@kib.kiev.ua> <20140716132938.GB93733@kib.kiev.ua> <CAJ-Vmomfp46GDdWb21g5xi34%2BK-DaCPeyrOHoELOLzRj7-dHrQ@mail.gmail.com> <201408121409.40653.jhb@freebsd.org> <DD742BF5-09DF-4399-B247-1E36F1CC46F5@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Aug 13, 2014 at 4:58 AM, David Chisnall <theraven@freebsd.org>
wrote:

> On 12 Aug 2014, at 19:09, John Baldwin <jhb@FreeBSD.org> wrote:
>
> > OTOH, I have actually seen junk profiling _improve_ performance in
> certain
> > cases as it forces promotion of allocated pages to superpages since all
> pages
> > are dirtied.  (I have a local hack that adds a new malloc option to
> explicitly
> > memset() new pages allocated via mmap() that gives the same benefit
> without
> > the junking overheadon each malloc() / free(), but it does increase
> physical
> > RAM usage.)
>
> Do you get the same effect by adding MAP_ALIGNED_SUPER | MAP_PREFAULT_READ
> to the mmap() call in jemalloc?



No.  MAP_PREFAULT_READ does not allocate physical pages.  It establishes
mappings to pages that are already allocated.



> I've been meaning to try the latter on BERI, as we spend a lot of time
> bouncing back and forth between user code and the TLB miss handlers.  Given
> that jemalloc asks for memory in 8MB chunks (I think via a single mmap
> call, although I'm not 100% certain), MAP_ALIGNED_SUPER should have little
> impact on any platform.  MAP_PREFAULT_READ may cause problems on machines
> with limited RAM and no swap (I don't know if the VM subsystem knows that
> it can safely discard a zero'd page that has been read but not written -
> I'd hope so, but it's been a while since I read that code).
>
> It might be that we can make jemalloc autotune whether to use
> MAP_PREFAULT_READ depending on some heuristic.  I wonder if something as
> simple as 'turn it on after the first mmap call' would be enough: programs
> that don't use more than 8MB of RAM won't prefault, but after that the
> wasted physical memory becomes an increasingly small percentage.
>
> David
>
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJUyCcPomwaWk-xEdovz9nBkdgAcZ48mCvB3szWH4hWZGQExmw>