Repository navigation
Conversation
…s with its collection unfinished
…he marking helper
…ucts Pins the preview build of oven-sh/WebKit#1080.
Collaborator
Author
|
Updated 4:05 AM PT - Nov 20th, 2026
❌ @robobun, your commit ce47fa2 has 1 failures in
🧪 To try this PR locally: bunx bun-pr 49338That installs a local version of the PR into your bun-49338 --bun |
Collaborator
Author
|
The one red test in CI,
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #49314
Problem
heapUsedstays byte-identical for 17 s whileheapTotalgrows by 4.7 GB.Collector Threadwaits with no time limit inSlotVisitor::drainInParallelPassively. EveryHeapHelperthread is parked inSlotVisitor::drainFromShared.Fix
test/js/bun/gc/gc-controller-cadence.test.ts(both fail with main's pin), and the GC and Worker test directories.Background
BUN_JSC_logGC=1prints what the conducting thread and each helper marked. The tests read that.Bun__JSC_onBeforeWait: it missesAtomics.wait.Downsides
Notes
The tests cannot fail without the pin. The change is in
scripts/build/deps/webkit.ts, not insrc/. With main's pin (cbf8d973991b) both tests fail: the helper marks 0 KB for the main heap (20 of 20 runs, and 20 of 20 with 12 busy loops beside it). With this pin theAtomics.waittest passes 40 of 40, 40 of 40 with 12 busy loops, 30 of 30 on 2 CPUs, and 12 of 12 on a debug+ASAN build.Reproduction of the issue (release build, about 10 GB of RAM, 55 s): 8 idle Workers get one burst of allocation each, then the main thread reads a pipe and allocates. On main:
heapUsed was byte-identical for 17.0s while heapTotal grew by 4.70GB, 6 of 6 runs. With the fix:0.0s,0.00GB, in the three forms of the script (pipe, 2 ms timer, less work per chunk).A probe with the shape of the report: 25 or 32 Workers idle in their event loops, default GC settings, one empty message to each Worker while its collector thread conducts its idle collection, a main thread that works on a 2 ms timer. A first revision of the WebKit change left the main heap with no helper for the last 34 s of the run (cycles of 1.0 to 2.4 s). With the revision that is pinned here: no such cycle in 4 of 4 runs, longest cycle 195 to 782 ms.
Other ways a thread holds a collection (6 Workers, main-heap cycles with no helper, longest cycle), main's pin against the fix:
Bun.spawnSyncBun.sleepSyncCost with one heap. Release builds without LTO of
7624a7ea1with WebKit0befb64cand with the fix on it, Linux x64, 12 cores, interleaved runs, min / median / max:With one heap the helpers leave and come back 48 times in the 204 cycles of the 3 MB churn, and not at all in the two larger ones.
BUN_JSC_gcHelpersLeaveWhenConductorIsAway=0turns the new behaviour off.Debug build. A debug+ASAN build with the preview (assertions on) ran the new test, a stress of 8 Workers that allocate and sleep (default, two markers,
collectContinuously), and the three test directories. On this machine 7 tests of those directories pass the 5 s default limit of a debug build and pass with a longer limit (twoFTL code age outtests at 6.2 and 6.6 s, fiveWorker destructiontests at 5.6 to 6.4 s). On release builds they take the same time with and without the fix.The second new test (the collector thread gives the conn to a Worker that sleeps) is skipped on Windows, debug and ASAN, as its neighbours are: it needs a 4-million-object heap and Bun's idle collection on the collector thread. Its timer lands inside the idle collection in 8 of 10 runs, so the test does not require that it did.
Platforms. The new tests pass on the Linux, macOS (x64 and arm64) and Windows (x64 and arm64) lanes, and on the x64 lane with AddressSanitizer, whose JavaScriptCore has assertions on. On Windows only the
Atomics.waittest runs.What stays for later.
drainInParallelPassivelystill waits with no time limit when the helpers are busy in another heap (oven-sh/WebKit#775 is about that wait). Workers that all mark at the same time still share one pool (#44186).no test proof · iteration 2 · platform-specific test(s) that do not run on this machine, deferring to CI, which covers all platforms: test/js/bun/gc/gc-controller-cadence.test.ts