Skip to content

Avoid flattening remembered-set chunks into a temporary array during collection #201

Closed

Description

@dimensionscape

In GlobalAllocator::Collect, the generational path creates a local QuickVec<Object*> rememberedSet and calls sGlobalChunks.copyPointers. That helper first counts the entries, resizes the temporary native array, then copies every pointer out of the MarkChunk list. Collect then walks the copied array once to set each referrer's mark byte. The temporary array has no later use and is destroyed at the end of Collect.

This adds a native allocation, a full pointer copy and extra passes inside the stop-the-world phase. The work repeats each collection when there are remembered referrers. This is a source-level performance candidate at checkout 03a4e8d; no pause reduction has been measured yet.

Consider applying the mark-byte patch directly while walking the chunks, avoiding the flattened array. Preserve both current modes: a minor collection leaves the chunks available for remembered-set marking, while a full collection returns them to the free list. The traversal must not free a chunk before consuming its pointers or disturb the list used by the subsequent mark phase.

Measure large old-to-young reference sets, small sets and empty sets. Record setup/patch time, total pauses, native allocation count and remembered pointer count. Include thread detach handing back a partially filled chunk, transitions between full and generational modes, and verifier builds. Require the existing generational stress and soak coverage before adopting it, especially while #168 remains unresolved.

If direct traversal complicates the lifecycle, retaining bounded scratch capacity is an alternative to repeated allocation, but it would still copy every pointer and needs a retention limit after unusually large collections.

Related: #151 for phase-aware benchmarks. This targets temporary remembered-set flattening, not the correctness of write barriers or thread handoff.

Activity

  1. added 3 commits that reference this issue on Oct 20, 2026
    4e73554
    1973cb2
    182a8a1
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions