Skip to content

Revert #553 (WarmUpBlockProvider deferred thread start): hangs the sampling profiler on Windows - #555

Closed
Jarred-Sumner wants to merge 1 commit into
mainfrom
claude/revert-553-warmup-start-threshold
Closed

Jarred-Sumner wants to merge 1 commit into
mainfrom
claude/revert-553-warmup-start-threshold

Conversation

@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

Reverts #553.

#553 defers constructing WarmUpBlockProvider (an AutomaticThread) from VM bring-up to the 64th MarkedBlock request, so WTF::Thread::create now runs lazily from tryAllocateAlignedMemory on the mutator while user code executes. On Windows this hangs @datadog/pprof, which drives JSC::SamplingProfiler through Bun's v8::CpuProfiler shim (the sampler suspends the JS thread; suspending it mid thread-creation is the usual Windows self-deadlock).

Evidence from Bun CI (oven-sh/bun#41190, the first PR pinned past #553):

Suggested reland: keep creating the helper thread at bring-up and defer only the warming work to the threshold (or start the thread from a safepoint rather than the allocator), verified against that test on Windows.

…equests" (#553)

Deferring the helper thread start to the 64th MarkedBlock request means
WTF::Thread::create now runs from tryAllocateAlignedMemory on the mutator while
user code is executing. On Windows that hangs @datadog/pprof (JSC
SamplingProfiler via the v8::CpuProfiler shim): test/integration/datadog-pprof
times out at 120 s on windows-x64 in every Bun CI run pinned past #553
(builds 109483, 109496, 109557) and passes with the same Bun tree pinned to
#552 without #553 (build 109518). Revert until the thread start is moved off
the allocation path and verified against that test on Windows.
@Jarred-Sumner

Copy link
Copy Markdown
Collaborator Author

Not reverting; Bun turns useWarmUpMarkedBlocks off on Windows in JSCInitialize instead (oven-sh/bun#41190) until the thread start moves off the allocation path.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

// MarkedBlock::tryCreate is the only caller today and always asks for a block-shaped region.
// The guard keeps a future caller of some other size from being handed a block.
if (alignment == MarkedBlock::blockSize && size == MarkedBlock::blockSize && WarmUpBlockProvider::isEnabled() && WarmUpBlockProvider::isPastStartThreshold()) {
if (alignment == MarkedBlock::blockSize && size == MarkedBlock::blockSize && WarmUpBlockProvider::isEnabled()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟣 Pre-existing: this revert moves the first helper-thread spawn back to VM bring-up, but Thread::create is still issued from tryAllocateAlignedMemory on the mutator every time the helper has idle-timed-out (10 s of no block requests) and a new block is needed, so a long-running profiled process on Windows can still hit the same sampler self-deadlock the PR is reverting to avoid. Fix: never spawn the helper from the allocator — restart it from a safepoint, or drop the idle timeout so the OS thread stays alive once created.

Extended reasoning...

After the supply is filled and block demand stops, AutomaticThread waits warmUpMarkedBlockIdleTimeout (default 10 s), WarmUpThread::shouldSleep() sees m_demandSinceIdleCheck clear, and the OS thread exits via stopForTimeout → threadIsStopping (m_hasUnderlyingThread=false, m_phase=Stopped, m_blocks freed). The next MarkedBlock request reaches line 264 → singleton().tryTake() finds the supply empty and phase≠StandingDown → m_condition->notifyOne() → AutomaticThreadCondition::notifyOne finds !hasUnderlyingThread() → AutomaticThread::start() → WTF::Thread::create(), all on the JS mutator inside the allocation slow path with user code on the stack. That is the exact call the PR description names as the Windows self-deadlock trigger when SamplingProfiler suspends the JS thread mid thread-creation. The base branch has this same restart path (plus the 64th-block path the revert removes), so this is an unfixed sibling of the bug being addressed rather than a regression; a steady-state heap easily goes 10 s without needing a fresh MarkedBlock, so the window is…

Verification: pre-existing — the idle-timeout restart path is untouched by this diff and exists identically on the base branch (and pre-#553), so merging makes nothing worse; the specific CI test the PR targets completes in well under 10 s and won't hit it. Mechanism verified: - FastMallocAlignedMemoryAllocator.cpp:123 — WarmUpThread is constructed with timeout… | pre-existing — the idle-timeout re-spawn path…

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Essentials

Run ID: 95903225-61d3-4b0a-8c20-36ad272f4e16

📥 Commits

Reviewing files that changed from the base of the PR and between 72e75e4 and 61308f2.

📒 Files selected for processing (2)
  • Source/JavaScriptCore/heap/FastMallocAlignedMemoryAllocator.cpp
  • Source/JavaScriptCore/runtime/OptionsList.h

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


Walkthrough

Changes

The warm-up allocator no longer waits for a request-count threshold. The related JSC option is removed. Eligible MarkedBlock allocations immediately use the warm-up provider.

Warm-up allocator behavior

Layer / File(s) Summary
Remove warm-up threshold option
Source/JavaScriptCore/runtime/OptionsList.h
Removes warmUpMarkedBlockStartAfterBlocks from the JSC options.
Select the warm-up provider immediately
Source/JavaScriptCore/heap/FastMallocAlignedMemoryAllocator.cpp
Removes the start-threshold check for eligible aligned block allocations.

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

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Preview Builds

Commit Release Date
61308f2a autobuild-preview-pr-555-61308f2a 2026-09-03 03:36:06 UTC

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant