ReviewOS

zig-utils/zig-js

GC: honor explicit requests after parallel round-limit aborts

#1038
Closed chris opened this 9 days ago ·
9 days ago

Problem

The opt-in no-GIL mid-script parallel collector can consume the only checkpoint after a JavaScript gc() request with the retry cooldown installed by #907.

A full threadfuzz midgc sweep failed the Thread.restrict lifecycle witness at seed 146 with:

attempts = 1
collections = 0
aborts = 1
round_limit_aborts = 1
generations = 64
born_growth_rounds = 57
finish_retries = 7
backoff_skips = 1
topology_retry_bypasses = 0
backoff_limit_bypasses = 0

All running peers published every generation. The first attempt safely aborted after continuous allocation. The workload then called the shell gc() helper, which set gc_requested, but serviceParallelGc checked the retry cooldown and ordinary heap threshold before treating that explicit request as due. The single remaining eligible checkpoint was skipped, so no finishing sweep occurred.

The failure is scheduling-sensitive: eight isolated repetitions of the exact seed passed. This is the same low-frequency shape discussed in #907, whose one-safepoint cooldown bound still permits the first skipped checkpoint to be the final checkpoint.

Definition of done

  • A pending explicit gc()/host collection request bypasses the opportunistic retry cooldown and heap-pressure threshold in the parallel mid-script collector.
  • A successful parallel sweep clears the explicit request; abort-safe failures leave it pending.
  • A focused Thread.restrict mid-GC runner can repeat the exact witness without paying for all 45 mid-GC cases per seed.
  • Focused normal and unsuppressed TSan repetitions pass, along with the full mid-GC gate and relevant unit coverage.
  • Preserve the existing publication/round budgets and ordinary opportunistic cooldown behavior.
9 days ago

Resolved by bc2f22e (fix(gc): honor explicit parallel collection requests (#1038)) and pushed to main.

The parallel mid-script collector now distinguishes explicit shell/host requests from opportunistic heap-pressure attempts. Explicit requests bypass the abort retry cooldown and the ordinary heap threshold, remain pending across abort-safe failures, and clear only after a stable finishing sweep. Automatic retries retain the #907 cooldown policy. A direct unit test proves a below-threshold request bypasses an armed cooldown, and threadfuzz midgcrestrict repeats the unchanged full-profile Thread.restrict witness without running the other 44 cases per seed.

Validation:

  • focused cooldown/request unit: pass
  • focused existing cooldown/topology unit: pass
  • midgcrestrict normal varied seeds: 100/100
  • historical seed 146 in fresh processes: 100/100
  • unsuppressed TSan focused: 20/20
  • ReleaseSafe focused: 100/100
  • full normal mid-GC profile: 900/900, 0 failures
  • full sharded units: 2,581 passed, 1 skipped, 0 failed, 0 leaked

The first combined unit attempt had one shard exit 0 without its summary; no test emitted a failure. The exact shard then passed 258/258 with no leaks, and the complete combined rerun produced the clean result above. The pinned test262 corpus is uninitialized in this checkout, so no conformance count was measured.

Sign in to comment on this issue.