This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][RFC] Allow explicit shrinking of arena heaps using anenvironment variable


On Sat, Jul 21, 2012 at 01:21:54AM +0530, Siddhesh Poyarekar wrote:
> > > The default behaviour remains as before -- this new behaviour is
> > > only seen when MALLOC_ARENA_SHRINK is exported and set to a
> > > positive value.
> > 
> > Why don't we enable this unconditionally?
> > 
> > What would be the problem in doing that?
> 
> mmap is more expensive than madvise, with the zeroing of pages and all
> that, so it might not be the best option to enable unconditionally. I
> wonder what the performance improvement will be with doing a
> memset(..., 0, ...) on the tail of the arena and then calling mprotect
> instead of the mmap.

memset and mprotect is in principle much more (even larger big-O!)
expensive than a new mmap. The latter just changes the page table
entries to reference COW zero pages; the former floods the cache then
leaves the pages in a state where the kernel won't recognize them as
"empty" and thus might swap them to disk. It also means you don't
recover the commit charge for use by other applications.

Using madvise (MADV_DONTNEED) then mprotect should be equivalent to
mmap, but it's unclear to me which will be faster.

Rich


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]