Skip to content

test: keep hot() from being inlined in disallow-code-generation-from-strings.test.ts - #45639

Merged
dylan-conway merged 2 commits into
mainfrom
claude/hot-loop-no-inline
Oct 17, 2026
Merged

dylan-conway merged 2 commits into
mainfrom
claude/hot-loop-no-inline

Conversation

@dylan-conway

Copy link
Copy Markdown
Member

What does this PR do?

Fixes the flaky "a compiled executable runs what is in it" tests in test/js/node/disallow-code-generation-from-strings.test.ts. In 6 of the last 27 builds of main one of the four variants ran into the 90 s timeout on a Linux lane, a different variant each time.

The program under test spins until the DFG has compiled a small function:

function hot(a, b) { return a + b; }
while (!numberOfDFGCompiles(hot)) sum = hot(sum, 1) | 0;

numberOfDFGCompiles(hot) counts an optimized replacement of hot's own code block (CodeBlock::numberOfDFGCompiles). Two things race to be compiled: hot, and the function around the loop. If the outer function wins, hot is inlined into it and is never called again, so it never reaches its own threshold and the loop never ends. On a machine with CPU to spare hot wins. The process then spins on one core, and outlives the test that timed out.

noInline(hot) from bun:jsc takes hot out of the inliner's candidates, so it keeps being called and gets compiled. This is the only loop on numberOfDFGCompiles in test/.

The hang needs neither --compile nor =strict: the loop alone in a plain script does it.

How did you verify your code works?

With the Linux x64 binary that CI built for main (f8bc171), copies run side by side in a cgroup with a CPU quota, main and this PR in alternating rounds:

main this PR
the four tests, 12 copies at CPUQuota=200% 10 of 144 runs fail, each with one test timed out 0 of 144
the loop alone, 40 copies at CPUQuota=100% 5 of 800 hang 0 of 800

What a hung process shows:

  • perf: 90% of the samples are in numberOfDFGCompiles and what it calls, the rest in JIT code.
  • BUN_JSC_reportDFGCompileTimes=1: the only function compiled is the anonymous outer one. In every run that finishes, with or without the fix, hot is compiled.

@robobun

robobun commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator
Updated 9:05 PM PT - Oct 16th, 2026

@dylan-conway, your commit 5f60bf8 is building: #127153

@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.

Code review found no issues

No high-confidence issues detected in this change.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: oven-sh/bun/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ae73e05e-0693-4dd2-b503-5cd70cf92f3c
📥 Commits

Reviewing files that changed from the base of the PR and between 7f3bc6a and 582ec1b.

📒 Files selected for processing: 1
  • test/js/node/disallow-code-generation-from-strings.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Walkthrough

The hotLoop test now imports and calls noInline(hot) before the loop that checks whether hot is compiled.

Changes

Hot-loop compilation test

Layer / File(s) Summary
Non-inline compilation check
test/js/node/disallow-code-generation-from-strings.test.ts
The test marks hot as non-inline before the compilation-checking loop.

Suggested reviewers: alii

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 5f60b

Merge Risk: ⚪ Minimal · up to 5f60b

The compiled-executable test can keep hot from being inlined while checking its compilation, with no remaining actionable merge risk.

Pre-merge checks: Passed 4
Check name Status Explanation
Description check Passed The description includes both required sections. It clearly explains the timeout cause, the noInline(hot) fix, and extensive verification results.
Title check Passed The title clearly and concisely identifies the main change: preventing hot() from being inlined in the affected test.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@dylan-conway
dylan-conway merged commit 57c4be7 into main Oct 17, 2026
4 of 5 checks passed
@dylan-conway
dylan-conway deleted the claude/hot-loop-no-inline branch October 17, 2026 03:04
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.

2 participants