Repository navigation
ci: component size writes no temp file and measures the import's chunk - #9778
Conversation
The PR report's component size measurement wrote a one-line entry file for each import into a fresh directory under the system temp directory, and bundled it with esbuild. esbuild reads the listing of every directory above each file it bundles, so every measurement read the temp directory's listing. On a shared machine whose temp directory holds 184,000 entries, that read took 140 to 270 ms per build unloaded, and about 2 s with two cores shared by four processes; the build itself takes 5 ms. component-size.test.mjs runs ten such builds, and timed out at 30 s on a loaded machine. The entry now reaches esbuild as stdin, read as if it were a file beside the measured entry, and the outputs stay in memory: nothing is written. The tests keep their fixture trees under the repository's node_modules/.cache, so the directories above the measured files are small too. The import's own chunk is now the output whose entry point is the import. Each import() target is an entry point too, and the old lookup took the first entry point in esbuild's outputs. With eight or more import() targets, a target's chunk can come first. So four figures in the main record change, each to the import's own chunk: ContextMenuItem (19,577 B of gzip JavaScript, from 53,875), Chart (133,664, from 64,413), ChartLegend (34,779, from 53,665) and ChartTooltip (102,303, from 53,670). The other 228 components' figures are unchanged. Co-authored-by: vjeux <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Before | After | Change | |
|---|---|---|---|
| Job-minutes per PR update | 92.7 | 92.7 | 0 |
| Runner pool, runner-minutes a day | 32,717 | 32,717 | 0 (0%) |
| Average concurrent jobs | 22.7 | 22.7 | 0 |
| Time to green (median → this run) | 18.9 min | 13.9 min | −5 min |
| Runs a day | 353 | 353 | 0 |
Not measured (the jobs that use these keep their recent minutes above): .github/scripts/lib/component-size.js, .github/scripts/lib/component-size.test.mjs.
Assumptions: before is each job's average over the last 20 pull-request runs; after keeps that for unchanged jobs and uses this run's minutes for added or changed ones, weighted by how often each changed job ran in those runs; runs a day averages the seven whole days before today; time to green compares this run with the median of those runs that ran the same jobs.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
This looks ready to approve. Measuring a component import no longer writes to the system temp directory, and the new lookup counts the import's own chunk. Both new tests fail against the old measurement and pass with this change. On this head's Core build, only ContextMenuItem changes; the other 102 of 103 figures are identical.
Optional: the CI impact: line gives deploy.yml's typecheck runner as ubuntu-latest, but that job runs on ubuntu-24.04-arm. It is still a standard GitHub-hosted runner, so only the label is off.
[Automated review]
There was a problem hiding this comment.
This looks ready to approve. Measuring a component import no longer writes to the system temp directory, and the new lookup counts the import's own chunk; both new tests fail against the old measurement and pass with this change. On this head's Core and Charts build, only ContextMenuItem, Chart, ChartLegend and ChartTooltip change, each to its own chunk.
Optional: the CI impact: line gives deploy.yml's typecheck runner as ubuntu-latest, but that job runs on ubuntu-24.04-arm; both are standard GitHub-hosted runners, so only the label is off.
[Automated review]
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. Its heavy suites were deferred for this push and run in the pre-merge re-run. Measuring a component import no longer writes to the system temp directory and now counts the import's own chunk. Both new tests fail against the old measurement and pass with this change, and on a Core and Charts build only ContextMenuItem, Chart, ChartLegend and ChartTooltip move, each to its own chunk.
- Optional: the
CI impact:line givesdeploy.yml'stypecheckrunner asubuntu-latest, but that job runs onubuntu-24.04-arm. Both are standard GitHub-hosted runners, so only the label is off.
[Automated review]
Re-lands #9441 by @vjeux verbatim (the same two files, byte-identical to its head
90e86f1), with vjeux as co-author. #9441 closes in favour of this pull request.Maintainer impact
.github/scripts/lib/component-size.test.mjstimes out at 30 s on a loaded machine, while it passes alone in about 2 s.The PR size report's component measurement wrote a one-line entry file for each import into a fresh directory under the system temp directory, then bundled it with esbuild. The tests also build their fixture trees there.
/dev/shm, 6.0 ms inside the repository.The measurement also took the wrong chunk for four components. Each
import()target is an entry point too, and the old lookup took the first entry point in esbuild's outputs. With eight or moreimport()targets, a target's chunk can come first, so the report counted a lazily loaded chunk (TimestampHoverCard's) in place of the import's own.Intended invariant
A component's measured size counts the import's own chunk and the chunks it imports statically, and depends only on the import being measured. How long measuring it takes does not depend on what else is in the system temp directory.
Change
bundleImportWithInputsgives esbuild the import as stdin, read as if it were a file beside the measured entry (resolveDir), and keeps the outputs in memory. It writes nothing.bundleInputsByEntrykeeps its outputs in memory without creating a temp directory for them.node_modules/.cache, so the directories above the measured files are small as well.import()targets is measured by its own chunk.Evidence
Load A/B on a 2-thread pin (one physical core), two busy loops beside it, 4 workers, ten rounds alternating which arm runs first; both arms use a temp directory of 184,000 entries with 16 processes creating and removing small trees in it, as a suite's fixtures do:
scripts/i18n-english-fallback.test.mjs)component-size.test.mjs:85Listings of the temp directory (strace, those two tests once): 9 on main, 0 on this branch.
Same-time comparison, pinned to two cores, four copies of the test file in parallel, three rounds, box load 87 to 92:
Sizes, the whole main record (
analyze-pr.js --main-record, 232 components, old lookup and new on the same built tree; the old one gives the same record on a second run): 228 figures are unchanged. Four change, each to the import's own chunk:ContextMenuItem(core; measured through the package entry)Chart(charts)ChartLegend(charts)ChartTooltip(charts)Before, each of the four took
TimestampHoverCard's lazily loaded chunk as the import's own. Six other real Core entries (Button, Tooltip, Dialog, TextInput, ProgressBar, DateInput) give byte-identical sizes; measuring them took 0.4 s instead of 4.1 s on the shared machine above.Failure before the change: with main's measurement, "writes no file to measure an import" fails (
mkdtempSyncwas called), and "measures the import's own chunk when an import() target's chunk comes first" fails: the figure is a lazily loaded module's chunk.Success after the change: the file passes 10 of 10, each case in 1 to 100 ms.
CI impact: the changed script runs in
ci.yml'sbuild-storybookjob (the PR report's size measurement inanalyze-pr.js) and indeploy.yml'stypecheckjob (the main record), each on its unchanged runner:ubuntu-latest, standard GitHub-hosted, or4-core-ubuntufor a dispatched release-check. A fresh hosted runner's temp directory is small, so a measurement takes about as long as before there.Re-check on current
main(fc68123, Core and Charts built,measureComponentImportcalled directly with main's lookup and with this one): the same four components move the same way.ContextMenuItem(through the package entry) 26,794 → 20,074 B;Chart29,026 → 142,032 B;ChartLegend26,620 → 35,162 B;ChartTooltip26,616 → 118,792 B of gzip JavaScript. Absolute figures differ from the table above becausemainhas moved since ci: component size writes no temp file and measures the import's chunk #9441's base. No committed baseline or budget holds these figures (the main record is a CI artifact), so nothing else changes.Scope