Parent: #473
Measured problem
After #1009, the frozen representative_json invocation still allocates 407,017 GC cells one at a time. Attribution shows these are the remaining managed string cells produced by JSON.stringify output and parsed string values; the object/array cells already use bounded batches.
Executed ReleaseFast/real-GC prototype against pushed #1009:
- total invocation cells remain exactly 1,001,001;
- slab-lock acquisitions fall 3,114,143 -> 2,330,774 (-25.2%);
- single-allocation acquisitions fall 407,017 -> 6,633;
- publication acquisitions fall 444,141 -> 68,781;
- bounded batch acquisitions rise 37,124 -> 62,148.
The implementation is not JSON-specific. The active interpreter keeps a realm-matched, traced, relocatable reserve of valid empty StringCells. Allocations 1-16 remain exact single-cell allocations; sustained allocation 17 fills a bounded 16-cell batch. Unused cells remain valid managed empty strings until consumed, so collection and finalization are defined at every safepoint.
Three alternating exact-parent pairs, exact checksums and thermal state 0 throughout:
representative_json: 0.996430x instructions, 0.990986x CPU, 0.990697x wall;- variant: 0.999569x instructions, 1.000181x CPU, 1.000019x wall;
- reviver-source: 0.989830x instructions, 0.919519x CPU, 0.911213x wall;
- escaped strings: 0.998421x instructions, 0.991289x CPU, 0.991579x wall;
- depth-4096 stringify control: 0.997193x instructions;
- shallow-4096 stringify control: 0.999059x instructions.
Scope
- Reuse
Heap.createBatch(StringCell, .string, ...)only after sustained active-interpreter demand. - Keep arena/static strings and allocations without a matching active interpreter on the existing exact path.
- Keep reserves realm-local even when sibling Contexts share one heap, preserving byte allocator/finalizer ownership.
- Trace and relocate the unused suffix as ordinary interpreter roots.
- Preserve immutable bytes/hash/aux initialization, OOM ordering, moving-GC safety, and no-GIL isolation.
Acceptance
- Seven alternating exact-parent pairs retain gains with exact checksums and neutral JSON controls.
- First-16/17th-allocation policy is pinned under real GC and TSan.
- Reserve tracing and relocation are pinned and pass under real GC.
- JSON test262 remains 165/165 with 165/165 required-VM agreement.
- String-related test262 subtrees and focused StringCell/GC/OOM tests pass.
- Shared/no-GIL managed-string TSan witnesses pass.
- Commit lands directly on
mainwith evidence linked here and in #473.