Parent: #1
Goal
Move mid-script parallel collection from a heavily tested internal capability toward a generally supportable policy.
Current baseline
The collector can trace running peers through root-publication generations, directly trace frozen parked peers, and abort without sweeping when publication or heap stability does not converge. Sync property waits, condition waits, and contended locks service publication requests at bounded pump points. Specialized fuzzer programs cover parked waiters, async jobs, ThreadLocal roots, finalization, joins, Workers, teardown, termination, and native-callback closure entry.
zig build midgc-profile now isolates this internal policy and reports attempts, finishing sweeps, publication-timeout versus round-limit aborts, deferred-cell aborts, generations, bounded born-growth extension rounds (ext-rnd), deferred-work rounds, post-abort retry backoff skips (backoff), total and worst-generation publication polls (wait-poll / wait-max), total and worst-attempt finish retries (fin-retry / retry-max), running/parked peer observations, actual peer publications, and collector-side total/maximum pause. These counters and parallel_midscript_gc remain testing/profile implementation details, not stable embedder API.
The current profile evidence says convergence pain is mostly round-limit fallback under sustained allocation, not publication-timeout failure. The internal policy now suppresses immediate retry churn after failed attempts and can extend the base generation cap only while a born-cell progress signal remains bounded and safe. Worst-generation, extension/backoff, and deferred-abort counters keep those decisions visible before changing budgets or wake/pump policy further.
Completed milestones
- Add pause, abort-reason, retry, generation, and peer-participation metrics.
- Add accounting invariants for attempt outcomes, abort classification, generations, pause totals, and max-versus-total telemetry.
- Prove both running-peer root publication and direct parked-peer observation paths execute.
- Add a focused repeatable convergence profile independent of the broad contention matrix.
- Add bounded post-abort retry backoff and born-growth convergence extension telemetry.
- Make the waiter-table reclamation witness deterministic at a truly quiescent point and add arm/GC/thread failure diagnostics.
- Add deferred generator/iterator abort telemetry so fail-closed no-GIL finishes are visible separately from generic round-limit churn.
- Add native-callback closure-root coverage for VM-lowered callback entry during mid-script collection.
Remaining work
- Define the supported collection/convergence policy for sync-wait parked peers.
- Continue reducing reliance on bounded publication polling, wake/pump retries, round-limit aborts, and quiescent fallback using the new backoff/extension/deferred-abort profile evidence.
- Expand nested native callback, host re-entry, deep VM/tree-walker, and multi-context coverage.
- Prove termination/teardown behavior when a collection is active at greater sustained depth.
- Decide when the internal
parallel_midscript_gcpath can become production policy; do not expose the test knob as public API.
Acceptance criteria
- TSan-clean higher-depth mid-GC sweeps and deterministic lifecycle oracles.
- Explicit root-publication and lock-order documentation.
- No hangs, lost cleanup jobs, or collection-time UAFs under termination and sync-wait stress.
- Profile evidence supports any convergence-policy or retry-budget change.