You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test: keep hot() from being inlined in disallow-code-generation-from-strings.test.ts - #45639
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:
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.
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.
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
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.
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:
numberOfDFGCompiles(hot)counts an optimized replacement ofhot's own code block (CodeBlock::numberOfDFGCompiles). Two things race to be compiled:hot, and the function around the loop. If the outer function wins,hotis 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 sparehotwins. The process then spins on one core, and outlives the test that timed out.noInline(hot)frombun:jsctakeshotout of the inliner's candidates, so it keeps being called and gets compiled. This is the only loop onnumberOfDFGCompilesintest/.The hang needs neither
--compilenor=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:
CPUQuota=200%CPUQuota=100%What a hung process shows:
perf: 90% of the samples are innumberOfDFGCompilesand 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,hotis compiled.