You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
work around heuristic overcommit causing fork failure + improve behaviour with no overcommit #193
The current chunk allocation design is perfect for the case where full overcommit is enabled, but is flawed for the other two cases.
improving the case where overcommit is disabled
In the glibc allocator, the overcommit setting is detected at start-up and used to determine whether MADV_DONTNEED purging is used. If overcommit is disabled, it drops the commit charge by clobbering the memory with a clean PROT_NONE mapping using mmap with MAP_FIXED and then toggles it back to PROT_READ|PROT_WRITE to recycle it. Using PROT_NONE like this isn't faster than unmapping and remapping but it's usable inside chunks and avoids the fragmentation issues caused by Linux using a naive heuristic instead of best-fit.
I think MADV_FREE vs. dropping commit charge should be a runtime tunable with the default determined from the overcommit state like glibc.
working around heuristic overcommit
The default heuristic overcommit is designed to catch obvious errors, but it tends to result in spurious failures with jemalloc. The problem is that fork will fail when the process has more than approximately half of the available memory as commit charge. This is a much bigger problem in jemalloc than other allocators because it never unmaps memory, at least in the default high-performance build.
The overcommit heuristic is clearly not sensible when using jemalloc, so I think it would make sense to detect it and set MAP_NORESERVE on all of the mappings. Rather than catching obvious errors, it's resulting in an inability to use all of (well, more than half of) the system's resources. Alternatively, MAP_NORESERVE could just be set by default. It's a no-op for the other 2 overcommit states (it's not documented correctly in the man pages project).
changed the title [-]work around heuristic overcommit causing fork failure + improve default behaviour when memory accounting is enabled[/-][+]work around heuristic overcommit causing fork failure + improve behaviour with no overcommit[/+]on Feb 5, 2015
Activity
[-]work around heuristic overcommit causing fork failure + improve default behaviour when memory accounting is enabled[/-][+]work around heuristic overcommit causing fork failure + improve behaviour with no overcommit[/+]