This is the mail archive of the glibc-bugs@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]

[Bug libc/11431] consider madvise for ld.so


------- Additional Comments From tglek at mozilla dot com  2010-04-06 20:59 -------
(In reply to comment #2)
> Can you suggest some statistics we can gather in order to inform
> heuristics within ld.so to trigger a madvise(MADV_WILLNEED)
> (which itself is a heuristic for the kernel)?
> 

I don't have an effective general heuristic. The problem is worst for programs
that use a large chunk of large libraries. Without modifying the compile-time
linker, the best heuristic I can come up with is to only WILLNEED executable
segments > 4 mb and data segments > 1mb.

If we could add a compile-time ld flag to flag dependent libraries with
WILLNEED, that would be ideal for Firefox. That would take the guessing out of
ld.so and push it onto application devs who are likely know exactly how the
libraries are meant to be used. Additionally libc could use an api to reset the
madvise flags to completely erase any concerns about keeping too many pages cached. 
One can already change the madvise hints by parsing /proc/<pid>/maps, but there
is no way set madvise flags early on.
On the other hand, everyday developers should not be expected to understand
pagefaulting behavior of their apps, so the benefit would be limited.

Another sure-fire solution is to do something like the current prelink cronjob.
Except in this case the program would iterate /proc/<pid>/maps figure out which
libraries are paging in multi-megabyte chunks and record that similar to the
prelink cache.


My concern is that I have yet to see any concrete evidence that madvise hints
actually hurt in low memory conditions. I started a thread on LKML asking about
madvise behavior in low memory conditions. I am still waiting for an indepth
reply, but it seems that the kernel throttles caching behavior under memory
pressure.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11431

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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