Repository navigation
Conversation
…test-runs-3 Each of the eight cases ran `bun test --aot` over two layers in a project of its own. Each such run compiles all of Bun's own code for the lowest layer. Seven cases now share one run in layers, as the folders of one project. `TestRunPartFiles:1` keeps each test file a program of its own. The case whose file deletes `require.cache[__filename]` keeps its own run: its build lets every file load again, which changes the lowest layer. The test asserts what the stage log of both runs says about that. The plain runs and the runs as one program do not change. Each case states the lines that it prints and the tests that it passes. Plain `bun test` and each compiled run must tell that of the case. A run as one program must say its form. There is one test for each case and each form: 24 tests, before 8.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Require-cache scenario cases test/aot/require-cache-in-test-runs-3.test.ts |
Defines cases for CommonJS and ES-module cache visibility, circular loads, thrown modules, and cache deletion. Each case records fixture files and expected output and reports. |
Test mode execution and result parsing test/aot/require-cache-in-test-runs-3.test.ts |
Defines plain, one-program AOT, and two-layer AOT modes. The run helper executes cases in shared or separate projects, parses per-case results and stage-log data, and the cleanup hook disposes temporary folders. |
Plain and compiled run assertions test/aot/require-cache-in-test-runs-3.test.ts |
Checks plain-run expectations for every case, compares compiled output with plain output, and checks two-layer stage-log entries when available. |
Possibly related PRs
- oven-sh/bun#47755: Updates adjacent require-cache-in-test-runs-4 AOT cases with harnesses that check printed output and require-cache behavior.
Suggested reviewers: jarred-sumner
Merge Risk: 
Minimal · up to 91420
-
The change consolidates require-cache tests and adds explicit output expectations. No actionable merge-blocking risk is established; merge after normal checks pass.
Pre-merge checks: 
4
-
Full details: Description check
-
Explanation
The description is detailed and follows the repository template in substance. It covers the problem, the fix, and verification with timings and CI results. The template asks for "What does this PR do?" and "How did you verify your code works?" Both are present: the Problem and Fix sections describe the change, and the Notes section and the verification bullets describe how the author tested it. The description uses headings such as Problem, Fix, Background, Downsides, and Notes rather than the exact template headings. The author should rename or map the content to the two template headings so reviewers can find them. The description also contains a large amount of detail in a collapsed block, which makes the core summary harder to scan. The description has no separate statement of the exact commands run for the verification section beyond the timing runs and the lint and type checks, which is adequate. Overall the description is mostly complete.
-
- 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.
|
Status: ready for review. At the head commit the file passes on its three lanes (build 136938). The red tests of that build are in files that this PR does not touch, and the CI report marks them as failing on main too. The review findings are answered in 914205b. How the time was measured.
Main's build and the builds of this PR did not run the file alike: the builds of this PR ran it first in its group because the PR changes it. The description has the details, every local run, and what was compared to show that the seven cases get the same programs in the shared run. |
…test-runs-3 `bun test` runs the test files of a subfolder in the order in which the file system lists them. In the shared run the case with two test files lies in a subfolder, so the order of its report depended on the file system. A line of stdout now says which test file it is of, and what a run tells of a case lists its test files by name. Also: - A blank line of stdout counts again. Only the banner is left out. - A test file that does not load fails its own case alone in the shared run. - The assertion on the stage log holds only where the run has layers. - afterAll waits for the runs before it removes their folders. - The output of a failed run leaves out the warnings that the stage log adds.
Problem
test/aot/require-cache-in-test-runs-3.test.tstakes 307 s on debian 13 x64-asan (build 136399). Each of its 8 cases runsbun test --aotover two layers in its own project, and each such run compiles all of Bun's own code: 32 of 40 s locally.Fix
bun bd testtakes 309 s before, 148 s and 160 s after (CPU time, user + sys: 2622 s before, 1077 s and 1140 s after). In CI on x64-asan: 36 s.Background
bun test --aotcompiles Bun's own code as the lowest program, what the test files import above it, and each test file on top.Downsides
-tfilter for one case in layers builds the shared run: about 260 s of CPU time, before 230 s.Notes
All numbers are from a debug build with ASAN on Linux x64, 12 processors, 16 GB. The host shares the processors with other machines, so the runs vary.
useris the steadiest number.Where the time goes. One command at a time, on a quiet host.
bun test --isolate, one casebun test --isolate --aot, one case,TestRunLayers:0TestRunLayers:2,TestRunPartFiles:1BUN_JSC_logAOTPhaseTimes=1gives the steps. The lowest layer (the packages that test files share) is built from 0.2 s to 32.5 s. The layer above takes 4.4 s, the program of the test file 2.4 s, the worker 0.3 s.Timings of
bun bd test <file>. Each row is one run. Rows of one block ran one after the other./proc/statcounts 350 s to 800 s of steal in the busy runs and 1300 s to 3100 s in the very busy runs.scripts/runner.node.tssets on the ASAN lane, and--max-concurrency=2as in a bucket of 7 files on 8 processors: main's file 478.6 s (user 2283 s), this PR 241.3 s (user 955 s). Busy host.Timings in CI. Each cell is one run. Main's file is from build 136399, this PR from build 136925 at the first commit and from build 136938 at the head.
Why seven cases can share a run in layers. Bytes of each program, from
AOT test build | program bytes. "Alone" is a run inside the folder of the case, so every path is the same.one.test.tsof case 1, of case 2one.test.tsof case 3, of case 4call.test.tsof case 5statement.test.tsof case 5one.test.tsof case 6one.test.tsof case 8--aot-build-test-partand read the compiler's map (BUN_JSC_aotMapFilePath): every function has the same bytes for every operation.Array.prototype.join,includes, and the string concatenation oflook, of which the run holds seven copies. No operation of the module loader comes or goes.console.log("c5/call.test.ts|"), so that a line of stdout says which test file it is of.Why the eighth case is alone.
src/file.cjsof "a file that takes itself out of require.cache while it runs" hasdelete require.cache[__filename]. The build cannot read that key. The stage log then saysevery file may load again, and every program of the run is compiled for that: the lowest layer has 2.4 MB more and each test file 16,384 bytes more (last column). The run of that case takes about 1.4 times the CPU time of a run without it.Why the runs as one program stay alone. I built the seven cases as one program and compared the compiler's map with the seven programs of main's test. Of 155 functions, 85 have the same bytes for every operation. In 5 functions of cases 3, 5 and 8
GetGlobalBindingappears, and in 2CheckInitialized: their files look up globals such asconsoleat run time and check a binding before they read it. Alone they do neither. One build for the seven takes 54 s of CPU time. Seven builds take about 335 s.The order of the test files of a case.
bun testsorts the test files of the folder that it starts in. It runs those of a folder below in the order in which the file system lists them (src/runtime/cli/test/Scanner.rs), which on ext4 is the order of a hash. The case with two test files lies in a folder below in the shared run. So what a run tells of a case lists its test files by name, each with its lines of stdout and of the report. With the two files namede.test.tsanda.test.ts, which this file system lists in that order, the first commit of this PR fails the test of that case in layers, and the head passes.Faults. A debug build with a switch in
src/aotthat is not in this PR. Each row is one run of each file.IS_LISTED_IN_CACHEbun testand the run in layers end with 1. The two tests of that case fail, and the 14 other tests of plain and of layers pass.Assertions.
bun testbun testbun testover the same project. Every line of stdout but the first (bun test v..) counts, blank lines tooAOT test run | one programlayers 2(run()of the harness)bun test --aotcompiles nothing, main's file passes its comparisons of one program and fails at the form of the layers. In this PR the 8 tests of one program fail too.git diff -wshows no changed line inside them.Order of the tests. A run begins when the first test asks for it. So no more builds are under way than tests, and
--max-concurrencyof the runner still holds. The tests of the layers come first, and the case with its own run first of all. Then both builds in layers begin together, also with two tests at a time.Limits.
run()of the harness lets such a run pass without layers, and the test then leaves out the assertion on the stage log.afterAllwaits for the runs that are still under way before it removes their folders.test/expected-durations.jsoncomes from CI runs. This PR does not edit it.The stage log.
BUN_JSC_logAOTPhaseTimes=1is on for the two runs in layers, so that a build says why every file may load again. The two layers of case 3, built with and without it, have the same SHA-256. It adds about 1 MB to the stderr that the test reads.Also run.
prettier --checkandoxlinton the file.tscwith the file alone inincludereports nothing for it.[auto-merge] gate passed · iteration 1 · 1 files touched
passes on PR (with fix)
diff hotspot
gate history · 2 passed · 0 rejected · iteration 1
evidence per changed file