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
Large and huge size classes increase incrementally, by one page and one chunk, respectively. Applications that incrementally reallocate tend not to hit degenerate behavior for large size classes only because jemalloc attempts in-place growing reallocation (and always succeeds at in-place shrinking). However, for huge size classes, the only possible saving grace is mremap(2), which is disabled by default because of Linux VM shortcomings.
Any size class spacing up to the golden ratio (~1.618) has reasonable properties (growing allocation can re-use the holes left by the two previous size classes in the growth sequence if they're adjacent), and furthermore using fewer size classes tends to decrease long-term fragmentation. Experiment with large and huge size class spacing that is some multiple in the 1.25-1.6 range.
Relatedly, right now there are four small size classes for every doubling of size, which works out to a spacing maximum of 1.25, but that might be closer spacing than necessary. Ideally, the full range of small..large..huge size classes will use the same spacing.
Assuming that logarithmically spaced huge size classes work out, per arena stats should also be added for all huge size classes, much as there are currently stats for all large size classes (of which there will be mercifully fewer).
f97e5ac and 0c5dd03 now make it reasonable to add the logarithmically spaced size classes between the page size and four times the page size, typically [2^12..2^14). The page runs for these size classes will be at most 7 pages, so no extra mechanisms should be necessary to mitigate unused dirty page accumulation due to per run external fragmentation.
Add huge size class stats to arenas, now that there are few enough of them for that to be feasible.
Add --with-lg-size-class-group.
Evaluate whether to remove the dirty/clean run splitting optimization in arena_dalloc_bin_run(). Bin runs are now much smaller, so the optimization likely has little positive effect, but it can increase run fragmentation.
Use pages_purge() as appropriate to discard pages when shrinking a huge allocation to something other than a multiple of the chunk size, and take advantage of whether this provides zeroed pages when expanding from e.g. 5 MiB to 6 MiB.
3c4d92e implements huge size class statistics for arenas, and incidentally includes some of the refactoring necessary to use pages_purge() for sub-chunk huge size class resizing, which is the only remaining work item.
Activity
jasone commentedon May 16, 2014
Assuming that logarithmically spaced huge size classes work out, per arena stats should also be added for all huge size classes, much as there are currently stats for all large size classes (of which there will be mercifully fewer).
jasone commentedon Aug 20, 2014
Groundwork was laid for this in d04047c. Additionally, huge allocations are now managed by arenas (e2deab7), so the hard parts are already done.
jasone commentedon Sep 29, 2014
f97e5ac and 0c5dd03 now make it reasonable to add the logarithmically spaced size classes between the page size and four times the page size, typically [2^12..2^14). The page runs for these size classes will be at most 7 pages, so no extra mechanisms should be necessary to mitigate unused dirty page accumulation due to per run external fragmentation.
[-]Experiment with size classes.[/-][+]Normalize size class spacing.[/+]jasone commentedon Oct 1, 2014
As part of this work, add e.g.
--with-lg-size-class-groupto make size class group size ($lg_ginsize_classes.sh) easy to configure.jasone commentedon Oct 6, 2014
155bfa7 normalizes size classes. Remaining work:
--with-lg-size-class-group.arena_dalloc_bin_run(). Bin runs are now much smaller, so the optimization likely has little positive effect, but it can increase run fragmentation.pages_purge()as appropriate to discard pages when shrinking a huge allocation to something other than a multiple of the chunk size, and take advantage of whether this provides zeroed pages when expanding from e.g. 5 MiB to 6 MiB.jasone commentedon Oct 10, 2014
fc0b3b7 adds
--with-lg-size-class-group.jasone commentedon Oct 11, 2014
I removed the run splitting from
arena_dalloc_bin_run()and made related optimizations: 381c23d.jasone commentedon Oct 13, 2014
3c4d92e implements huge size class statistics for arenas, and incidentally includes some of the refactoring necessary to use
pages_purge()for sub-chunk huge size class resizing, which is the only remaining work item.jasone commentedon Oct 16, 2014
9673983 implements sub-chunk purging/zeroing for huge reallocation, which completes this project.