Skip to content

Implement hybrid slab/chunk allocation scheme, to reduce # of native chunks #14

Open
@cowtowncoder

Description

@cowtowncoder

(inspired by Hal H, Alex F, on discussion for use at SFDC)


Current chunk allocation scheme has the benefit of allowing much of the memory to be returned to OS when not needed, depending on constraints defined for individual queues (i.e. if they can grow/shrink). But it has potentially non-trivial overhead as chunks need bit of JVM overhead for tracking.

On the other hand, allocating bigger "slabs" (piece of memory that is multiple of chunk) would make it possible to reduce such overhead. But it will be next to impossible to free such chunks before closing down individual "MemBuffers" instances, because likelihood of at least one chunk of a slab being in use is high.
So in practice such slabs would be static; allocated when needed (or eagerly), and not freed for lifetime of individual Buffers instance (factory of group of individual queues).

One simple and seemingly efficient way to make use of this would be to allow specifying amount of "static" memory (as number of chunks) that may be allocated, and use this for allocation slabs. Chunks from slabs would then be the primary source of allocation; and dynamic (individual) chunks would only be allocated if slabs are full.
Conversely, slab-based chunks would always be reusable; whereas reuse rate for dynamic chunks could be more closely limited.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Implement hybrid slab/chunk allocation scheme, to reduce # of native chunks · Issue #14 · cowtowncoder/low-gc-membuffers