Skip to content

Bump WebKit: start the MarkedBlock warm-up thread after 64 block requests - #41239

Closed
robobun wants to merge 1 commit into
mainfrom
robobun/9dfcc910/webkit-warmup-threshold
Closed

robobun wants to merge 1 commit into
mainfrom
robobun/9dfcc910/webkit-warmup-threshold

Conversation

@robobun

@robobun robobun commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Problem

  • Since the WebKit bump in Two full collections + payload page-out once the heap goes quiet #41083, JSC starts its MarkedBlock warm-up thread on the first GC block. mimalloc's scavenger starts with it, as it starts with a process's second thread.
  • A VM takes about 30 blocks to start. So each bun -e or short script creates two idle threads and faults in unused blocks.

Fix

  • Pins WebKit to e9b43fbb, the merge of [JSC] WarmUpBlockProvider: start the helper thread after 64 block requests, not the first WebKit#553 and the only change between the two pins. The warm-up thread starts after 64 block requests (warmUpMarkedBlockStartAfterBlocks).
  • A script that keeps allocating passes 64 blocks in its first milliseconds and still gets the helper, which makes it about 19% faster.
  • Verified: test/cli/run/run-eval.test.ts. A script that waits on stdin, run as -e and as a file, must have no JSCWarmUp thread. It fails on the current canary and passes there with BUN_JSC_useWarmUpMarkedBlocks=false. CI runs it on the new pin.

Current canary (release x64 Linux), as it is and with the warm-up thread off, which is what this pin does for these scripts. Interleaved, 400 rounds, median:

canary warm-up off
bun -e 1 4.01 ms, 1031 faults 3.72 ms, 908 faults
bun empty.js 4.05 ms, 1028 faults 3.72 ms, 906 faults

Background

  • A MarkedBlock is a 16 KiB GC heap block. The warm-up thread keeps a supply of blocks whose pages it has touched, so the faults land on it, not on the JS thread.
Notes

…ests

oven-sh/WebKit#553 (merged as e9b43fbb). Since the WebKit bump in
#41083, JSC started its MarkedBlock warm-up thread on the first block
a process allocated, and mimalloc's scavenger thread started behind it.
Bringing up a VM takes about 30 blocks. So every `bun -e` and every
short script created two threads that did no useful work, and faulted
in a supply of blocks it never used.

The thread now starts after 64 block requests (the new
warmUpMarkedBlockStartAfterBlocks option). A script that keeps
allocating passes that within its first milliseconds, and still gets
the helper, which makes such a script about 19% faster.

The test starts a script that waits on stdin, as `bun -e` and as a
file, and reads its thread names from /proc. It fails on 491b5cc2.
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

On-demand reviews are free for the next 18 days. After that, they cost $0.25 per reviewed file.

Or wait 33 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Essentials

Run ID: 5b8c890a-af79-47b2-93f6-530500635e84

📥 Commits

Reviewing files that changed from the base of the PR and between 467e741 and 4f62280.

📒 Files selected for processing (2)
  • scripts/build/deps/webkit.ts
  • test/cli/run/run-eval.test.ts

Comment @coderabbitai help to get the list of available commands.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this PR and didn't find any bugs. The Bun-side diff is a clean one-line pin bump plus a well-constructed regression test, but since the actual behavioral change lives in the WebKit fork and touches JSC's GC block-allocation threading, a human should confirm the oven-sh/WebKit#553 change and that the e9b43fbb prebuilt release has all platform assets before merge.

What was reviewed:

  • The pin bump follows the scripts/build/deps convention; grepped the repo for the old hash 491b5cc2 — no other occurrences.
  • The new test awaits the child's "ready" line before reading /proc/<pid>/task/*/comm (no sleep-polling), drains stderr, asserts output before exit code, uses tempDir/bunEnv/await using, and gates on isLinux.
  • Checked pipe-read framing: console.log("ready") is a single sub-PIPE_BUF write, so reader.read() returning the full line is safe on Linux.
Extended reasoning...

Overview

This PR changes two files: scripts/build/deps/webkit.ts bumps the pinned WebKit prebuilt from 491b5cc2… to e9b43fbb…, and test/cli/run/run-eval.test.ts adds a Linux-only test asserting that a low-allocation script (run via -e and via a file) does not spawn JSC's JSCWarmUp MarkedBlock warm-up thread. The substantive change — deferring the warm-up thread until 64 block requests instead of the first — lives in oven-sh/WebKit#553, not in this diff.

Security risks

None identified. There is no new attack surface: the WebKit bump changes an internal GC-helper-thread start threshold, and the test only reads /proc/<pid>/task/*/comm for a child it spawned. No untrusted input parsing, no auth/crypto/network paths touched.

Level of scrutiny

High, because WebKit is the JavaScript engine — the single most critical dependency in the project — and the behavioral change concerns GC block allocation and threading. The Bun-side diff is trivial and correct, but the reviewable substance is in the external WebKit commit. Per the repo's dependencies-and-vendoring guidance, a WebKit pin bump requires verifying that prebuilt artifacts exist for every platform × flavor; the PR description claims 42 matching assets but that is not verifiable from this diff alone. The author also notes they did not build locally with the new pin, so CI and a human sign-off carry the full verification burden.

Other factors

The test is well-constructed against the repo's review rules: it extends the existing run-eval.test.ts rather than creating a new file, uses tempDir/bunExe/bunEnv/await using, awaits the observable "ready" stdout line rather than sleeping, drains stderr concurrently with proc.exited, asserts stderr/stdout before exit code, and covers both the -e and file entry points concurrently. I confirmed the old hash 491b5cc2 appears nowhere else in the repo. No CODEOWNERS pattern covers either changed file. The PR is otherwise self-contained and narrowly scoped, so the only reason to defer is the criticality of the dependency itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants