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
{{ message }}
Repository navigation
Environments: elide private writes when concurrent tracing is impossible #535
Issue #533 safely removed read locking from uncaptured mutator-private activations, but every private binding write still acquires Environment.binding_lock. Exact schema-next attribution for representative_shape_transition_fanout at 8 lanes / 1,000 jobs accounts for all 72,531 invocation acquires:
16,334 reads (16,238 root, 96 captured)
56,197 writes
0 concurrent-trace acquires
56,191 of the writes are uncaptured private-activation writes; only 6 are root writes
Thus private writes are 99.99% of Environment writes and 77.47% of all Environment locking in this workload. The context uses parallel mutators with mid-script collection disabled, so no marker can trace activation tables concurrently, yet the process-global lock policy cannot express that fact.
Required design
Give each Environment an immutable/inherited synchronization capability derived from its owning Context. An uncaptured private activation may elide binding-write locking only when concurrent environment tracing is impossible for that Context. Root, module, captured/shared, standalone concurrent-marker, and parallel mid-script collector paths must remain locked. Closure publication must continue to revoke private access before another mutator can observe the environment.
This must be a general ownership/capability rule, not a workload check or global flag workaround.
Acceptance
Unit tests prove private write elision and capture revocation with exact lock attribution.
TSan covers shared closure mutation and concurrent marker/parallel collector configurations.
threadfuzz stays deterministic and race-free.
Full unit suite passes without leaks.
Exact affected test262 subtree comparisons show no regressions.
One safety refinement from the collector audit: a default no-GIL Context can still enter driveParallelCollection during allocation-failure recovery, even with routine parallel mid-script GC disabled. Therefore an immutable “no concurrent tracer” bit alone is insufficient. The implementation must use a race-free dynamic marker/mutator handshake: publish trace-active before tracing, drain already-entered private writes, and force later private writes through binding_lock until concurrent tracing finishes or aborts.
The implementation refines the initial static-capability design into a heap-scoped active-trace capability. Every private write enters a seq_cst per-interpreter guard before reading the shared heap's trace flag. A collector publishes that flag, then drains pre-existing writers across the owner, live siblings, bootstrapping realms, and retiring realms before it can trace an Environment. Writers arriving after publication use the existing binding mutex. This is necessary because a precise heap collector traces all registered realms, not only the Context that initiated collection.
Exact 8-lane attribution for representative_shape_transition_fanout, 1,000 jobs:
ReleaseFast test/language: 23,648 -> 23,648, 0 flips and byte-identical diagnostics
attribution schema self-test passes
Capture revocation, root environments, shared/captured environments, and active concurrent tracing remain on the locked path. #531 has the raw scaling samples and remains open because throughput still declines after two lanes.
Activity
bench(environment): attribute binding lock ownership (#531)
chrisbbreuer commentedon Aug 11, 2026
Diagnostic prerequisite landed in
3577d307.One safety refinement from the collector audit: a default no-GIL Context can still enter
driveParallelCollectionduring allocation-failure recovery, even with routine parallel mid-script GC disabled. Therefore an immutable “no concurrent tracer” bit alone is insufficient. The implementation must use a race-free dynamic marker/mutator handshake: publish trace-active before tracing, drain already-entered private writes, and force later private writes throughbinding_lockuntil concurrent tracing finishes or aborts.perf(environment): elide guarded private writes (#535)
chrisbbreuer commentedon Aug 11, 2026
Implemented and landed in
2d895edb.The implementation refines the initial static-capability design into a heap-scoped active-trace capability. Every private write enters a seq_cst per-interpreter guard before reading the shared heap's trace flag. A collector publishes that flag, then drains pre-existing writers across the owner, live siblings, bootstrapping realms, and retiring realms before it can trace an
Environment. Writers arriving after publication use the existing binding mutex. This is necessary because a precise heap collector traces all registered realms, not only theContextthat initiated collection.Exact 8-lane attribution for
representative_shape_transition_fanout, 1,000 jobs:Validation on the landed code:
threadfuzzdefault: 400/400, 0 failuresthreadfuzzexact-value verifier: 300/300, 0 failurestest/language: 23,648 -> 23,648, 0 flips and byte-identical diagnosticsCapture revocation, root environments, shared/captured environments, and active concurrent tracing remain on the locked path. #531 has the raw scaling samples and remains open because throughput still declines after two lanes.