There was a fun little panel a few months back at Atlanta Linux Showcase
(which was inexplicably held in california this year, but I'm told they're
patching that in the next release... :)
Apparently, for mallocs below a certain size, glibc uses brk, and above a
certain size, it uses mmap. And the mmap variant is something like 10 times
slower than the brk variant, because of all the soft page faults, fiddling
with page tables, associated cache trashing, etc. (The guy found it trying
to figure out why his app was SLOWER on Linux than on Irix, and eventually
found a glibc variable that could make linux faster: raising glibc's
threshold where it does brk for malloc to infinity.)
Glibc does mmap instead of brk because theoretically brk can leave wasted
memory between fragments, although apparently nobody's ever seen more than
10% waste in a live program, and the speed penality of taking a soft page
fault at access time to muck about with the page tables is a LOT bigger than
10%...
Rob
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/