It only works with a malloc that uses MAP_UNINITIALIZED and MADV_DONTNEED (maybe jemalloc?), but presumably they use this...
-
-
-
Only Facebook's internal jemalloc uses MAP_UNINITIALIZED.
-
Note the patch is from Facebook. MADV_FREE landed upstream now though. Shouldn't have nearly as much need for this stuff now.
-
MADV_FREE doesn't drop any pages. It only marks the range as reclaimable. Then drops them when under memory pressure.
-
It relies on dirty bit to know if the pages were written to. Means uninit data can be odd even without optimizing compilers.
-
i.e. uninitialized malloc memory can start as non-zero and then become zero, if malloc marked that memory with MADV_FREE.
End of conversation
New conversation -
-
-
what is a use case for this ?
-
Improving performance by reducing page zeroing. MADV_FREE should negate 99.9% of the desire to want these things.
-
A nice thing about MADV_FREE is that even if the memory is handed out again, unused ranges can still be dropped.
-
It's pretty much designed for malloc. There's still a niche for a full range granularity equivalent with undo op.
-
Android has something close to that via ashmem. Can unpin a range of ashmem pages, then try pin them back in memory.
-
Chromium and Firefox have to use more memory or sacrifice performance on desktop Linux vs. Windows, Android, etc.
End of conversation
New conversation -
-
-
is that actually in the kernel? or just a random patch no one committed?
-
MAP_UNINITIALIZED is in the kernel. This is likely something FB uses with internal jemalloc / HHVM.
-
See https://twitter.com/CopperheadOS/status/786296202438467585 … though. MADV_FREE is quite new so they probably didn't switch yet.
-
See https://github.com/torvalds/linux/commit/854e9ed09dedf0c19ac8640e91bcc74bc3f9e5c9 …. Commit message mentions Facebook's MAP_UNINITIALIZED usage / exts.
End of conversation
New conversation -
-
-
and that feature still exists today ;)
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.