Skip to content

Normalize size class spacing. #77

Closed

Description

@jasone

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.

Activity

  1. added this to the 4.0.0 milestone on Apr 25, 2014
  2. jasone commented on May 16, 2014

    @jasone
    MemberAuthor

    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).

  3. jasone commented on Aug 20, 2014

    @jasone
    MemberAuthor

    Groundwork was laid for this in d04047c. Additionally, huge allocations are now managed by arenas (e2deab7), so the hard parts are already done.

  4. self-assigned this
    on Sep 10, 2014
  5. jasone commented on Sep 29, 2014

    @jasone
    MemberAuthor

    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.

  6. changed the title [-]Experiment with size classes.[/-] [+]Normalize size class spacing.[/+] on Oct 1, 2014
  7. jasone commented on Oct 1, 2014

    @jasone
    MemberAuthor

    As part of this work, add e.g. --with-lg-size-class-group to make size class group size ($lg_g in size_classes.sh) easy to configure.

  8. jasone commented on Oct 6, 2014

    @jasone
    MemberAuthor

    155bfa7 normalizes size classes. Remaining work:

    • 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.
  9. jasone commented on Oct 10, 2014

    @jasone
    MemberAuthor

    fc0b3b7 adds --with-lg-size-class-group.

  10. jasone commented on Oct 11, 2014

    @jasone
    MemberAuthor

    I removed the run splitting from arena_dalloc_bin_run() and made related optimizations: 381c23d.

  11. jasone commented on Oct 13, 2014

    @jasone
    MemberAuthor

    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.

  12. jasone commented on Oct 16, 2014

    @jasone
    MemberAuthor

    9673983 implements sub-chunk purging/zeroing for huge reallocation, which completes this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions