Repository navigation
Commit 15beefc
authored
build(tooling): compare CSS and HTML parsers and printers, not just minifiers (#22007)
* build(tooling): compare CSS and HTML parsers and printers, not just minifiers
`compare-css-minifiers.js` and `compare-html-minifiers.js` become
`compare-css-tools.js` and `compare-html-tools.js` (`yarn benchmark:css-tools`,
`yarn benchmark:html-tools`), sharing the measuring harness they duplicated.
Each fixture now prints three tables rather than one: parsing alone, parsing
and printing readably, and parsing and printing minified. What a parse costs is
then separated from what printing and the transforms on top of it cost, and a
parser that ships no minifier is measured for the first time — postcss,
css-tree, stylis, @adobe/css-tools and crass on the CSS side, parse5,
htmlparser2, node-html-parser, linkedom and angular-html-parser on the HTML
one, plus prettier and js-beautify as printers. A round-trip printer that
reformats nothing sits in each beautify table as the floor the rest are read
against: postcss and parse5 both hit it.
Two measurement bugs came out of the rewrite. The peak-memory column reported
the parent's high-water mark, not the tool's: Linux carries `maxRSS` across
`fork`+`exec`, so every worker inherited whatever the harness had reached, and
the rows climbed in lockstep with it. It reads `/proc/self/status` now. And
loading a comparison package by joined path skips its `exports` map, so a
package shipping one and no `main` read as missing; they resolve as bare
specifiers from the cache instead.
`FIXTURE=`, `TOOL=` and `STAGE=` narrow a run to matching rows.
* build(tooling): say when a tool spends its cost in a service process
esbuild transforms in a child process of its own, so `cpuUsage` and `VmHWM`
both miss it: 25 ms of wall time reported 1.6 ms of cpu and a peak that was
only this worker's. Those two cells now read `-`, and the row says why.
* build(tooling): name the tool when a worker's output will not parse
Parsing straight into `resolve` threw inside the close listener, so a tool
that wrote anything of its own to stdout ended the whole run with a syntax
error naming no tool, no fixture and no stage.
* test(tooling): cover what the comparison harness does with a bad worker
Both messages are asserted whole rather than by substring: 200 characters are
a substring of 500, so a truncation that never happened would pass either way.
* test(tooling): drive the comparison harness itself, not only its worker
Requiring the harness from a test instruments it, so its own lines became a
patch codecov measures — and a spawned worker earns none of them back, since
coverage does not follow a child. `measure` runs in this process instead.
What is left uncovered cannot be reached from a unit test: the npm install a
warm cache skips, and the fallback for a platform without `/proc`.
* test(tooling): reach the install the comparison cache skips when it is warm
An `npm` of our own first on `PATH` stands in for the real one, so the
orchestration is exercised without fetching anything: the cache is created,
the installer is run, and the package list is recorded only after it exits
cleanly — a list written any earlier would let a broken cache pass for warm.
* docs(tooling): say what the peak measurement actually returns
It never answers 0: where `/proc/self/status` is not there to read, the
platform's own `maxRSS` is, and that is what comes back.
* test(tooling): keep the install cases away from the real npm
The stand-in npm was put first on `PATH`, but jest hands a test file a copy
of `process.env`, and `child_process` reads the real one when no env is
given — so both install cases spawned the real npm and installed over the
network. `run` now hands the child the environment this process holds, the
stand-in leaves a mark in the cache it was called for, and each case asserts
whether that mark is there. The caches are also cleared before the run, so
one left behind by an interrupted run cannot send the cold case down the
warm path.
* test(tooling): measure a peak where there is no status file to read
The fallback to what the platform accounts for was the one line the suite
never reached, so a machine without `/proc/self/status` was covered by
nothing. Both ways of not getting a high-water mark out of it are driven
now: the file missing, and the file naming no `VmHWM`.
* test(tooling): name the command a failed spawn could not find
Bun answers a missing executable with "Executable not found in $PATH" and
node with the errno, so asserting `ENOENT` failed the bun runtime job. The
name is in both messages.1 parent b2815d2 commit 15beefc
8 files changed
Lines changed: 1489 additions & 694 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
| 286 | + | |
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
| 295 | + | |
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
226 | 227 | | |
227 | 228 | | |
228 | 229 | | |
| |||
437 | 438 | | |
438 | 439 | | |
439 | 440 | | |
| 441 | + | |
440 | 442 | | |
441 | 443 | | |
442 | 444 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
230 | | - | |
231 | | - | |
| 229 | + | |
| 230 | + | |
232 | 231 | | |
233 | | - | |
234 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
| 245 | + | |
249 | 246 | | |
250 | 247 | | |
251 | 248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
| 56 | + | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
0 commit comments