Properly support madvise(MADV_FREE) on linux
Categories
(Core :: Memory Allocator, enhancement, P3)
Tracking
()
People
(Reporter: glandium, Assigned: Benjamin)
Details
Attachments
(1 external file)
| Reporter | ||
Updated•7 years ago
|
Comment 1•4 years ago
|
||
Hi Glandium.
What's the difference between MADV_FREE and MADV_DONTNEED. The descriptions are so similar.
Comment 2•4 years ago
|
||
I'm not glandium, but my understanding is that MADV_DONTNEED will free the pages immediately and synchronously; in contrast, MADV_FREE permits the kernel to free them at a later point, meaning that if there isn't memory pressure before we use the pages again then we don't have the overhead of removing and reestablishing the page table entries.
Updated•4 years ago
|
Comment 3•3 years ago
|
||
Note that MADV_FREE may make Firefox much more attractive to the OOM-killer on linux (though it's likely fairly attractive already): https://stackoverflow.com/questions/74358183/why-golang-madv-free-leads-to-oom-sometimes
MADV_FREE will make us appear to use more RSS; jlebar landed code a Long Time Ago to purge MADV_FREE pages on Mac before we measure RSS: bug 693404. This helps us in our internal RSS measurements (for about:memory), but not for any external measurements
Comment 4•3 years ago
|
||
Note that MADV_FREE until kernel 4.12 on an swapless, system will immediately free memory on MADV_FREE, and other issues make MADV_FREE on linux <4.12 problematic:
https://kernelnewbies.org/Linux_4.12#Memory_management
MADV_FREE has several issues that make it unusable in software like jemalloc: doesn't support system without swap enabled, increases memory pressure, and accounting problems. This release puts MADV_FREE pages into the LRU_INACTIVE_FILE list, enables MADV_FREE for swapless systems and improves statistic accounting
4.12 looks like it was released in 2017
| Reporter | ||
Updated•2 years ago
|
| Assignee | ||
Comment 5•15 days ago
|
||
memory/build/Constants.h had this block that would appear to force Linux to always use MADV_DONTNEED:
// Newer Linux systems support MADV_FREE, but we're not supporting
// that properly. bug #1406304.
Unfortunately, Constants.h doesn't include <sys/mman.h>. A later inclusion of <sys/mman.h> will silently override MADV_FREE back to MADV_FREE. That appears to be happening with the current unified build, resulting in PurgeDirtyPages using "real" MADV_FREE despite this Constants.h block.
Updated•15 days ago
|
Description
•