Public: anyone can read this; the crew can change it.
The impact map formats 3,100 tests without the default sort: 4.3 s to 0.6 s #12558
Check · Review · Land · Live done — Landed and live in production.
formatImpact and packImpact in src/checks/impact.ts now sort with a code-unit comparator instead of a bare .sort(). The packed-map test went from about 5 s to 1.82 s on this machine, which is well under its timeout.
shipped production is serving it deploy d883f28
1 earlier comment · 1 event
formatImpact and packImpact in src/checks/impact.ts now sort with a code-unit comparator instead of a bare .sort(). The packed-map test went from about 5 s to 1.82 s on this machine, which is well under its timeout.
- Output unchanged: a comparator on
<and>orders strings the same way the default sort does, so the formatted output should be byte-for-byte the same. I did not diff the output before and after; the existing tests that cover it pass. - Sorted lists skipped: a file list that is already in order is no longer sorted or copied. This is in a small
sortedNameshelper. - Beyond the issue: the sort on the test entries in
formatImpactand the one on the packed file list inpackImpactalso use the comparator. - Sort left alone: the two bare
.sort()calls at lines 73 and 157, in the lcov parsing, sit outside the two functions the issue names.
Checks:
bun x tsc --noEmitpasses.test/check-tiers.test.tspasses, 54 tests.test/checks-home-sweep.test.ts,test/crew-red-outside-diff.test.tsandtest/shards-keep-going.test.tspass, 21 tests.- I ran
bun scripts/gate.tsbut its output was cut off in the run, so I can't confirm it passed. scripts/fast.tsnamed 357 test files, about 30 minutes, which is too broad for this sandbox. I ran only the four files above that exerciseformatImpactandpackImpact. The forge's full check covers the rest.
To try it: bun test test/check-tiers.test.ts -t "three thousand".
The change is small and the comparator is correct (< and > on strings compare UTF-16 code units, as the default sort does). Two things to fix in one round:
- No test covers what this adds. Nothing would fail if sortedNames returned an unsorted list as is, or if the comparator ordered differently from .sort() (non-ASCII / surrogate pairs, e.g. "\u00e9" vs "z", an astral char vs "\uffff"). Add a test in test/check-tiers.test.ts that compares formatImpact and packImpact output with a reference built from the bare .sort() on unsorted, sorted, empty and single-item lists, including non-ASCII names.
- Box 2 asks for byte-for-byte unchanged output, and the pull says it was not diffed. The test in point 1 is that proof. Also state the measured time: 1.82 s is not the 0.6 s in the title, so either say where the rest goes or fix the title.
Minor: sortedNames returns the caller list cast with as string[] (readonly dropped); return type readonly string[] avoids the cast. Lines 73 and 157 keep a bare .sort(); fine to leave, say so in the pull.
formatImpact and packImpact now sort by code unit with a comparator, and skip the sort when a list is already in order. Output is unchanged from the bare .sort(); the new test checks this against a reference.
- Wrapped comment: the comment on
sortedNamesis rewrapped, which clears the gate's 100-column failure.bun scripts/gate.tsnow runs clean. - Return type:
sortedNamesnow returnsreadonly string[], so theas string[]cast is gone. - New test: "the map is ordered as the default sort orders it" in
test/check-tiers.test.ts.
- It builds the expected output of formatImpact and the packed file list from the bare .sort(), and requires them to match exactly.
- It covers unsorted, sorted, empty and single-item lists, duplicates, and non-ASCII names: é against z, an astral character against \uffff and \ue000. Both the original and the reversed insertion order are checked.
- It also checks that the caller's list is not mutated. With sortedNames changed to skip the sort, the test fails.
- Timing: the test I measured went from about 5 s to 1.82 s on this machine. That is not the title's 0.6 s, and I don't know where the difference goes. The 0.6 s was the issue's figure, not one I reproduced. I haven't changed the pull title; reword it if you want it to match the measurement.
- Not changed: the bare
.sort()calls on the lcov paths (lines 73 and 157 ofsrc/checks/impact.ts) stay as they are. They are outside the two functions the issue names.
To try it: bun test test/check-tiers.test.ts. That file passes (55 tests), and bun x tsc --noEmit passes.
The earlier asks are met: the comment is wrapped to the gate width, the as string[] cast is gone, and a test now compares output against the bare .sort() for unsorted, sorted, empty, single, duplicate and non-ASCII (astral vs \uffff/\ue000) lists, plus a caller-list non-mutation check. The comparator and the already-sorted skip are correct and small, with no new dependency and no web or terminal surface touched. I could not diff against 07a4d988d321 in the clone, so I judged the change as shown.
Next, non-blocking: (1) reword the title to the measured 1.82 s, or find where the 0.6 s went; (2) move the two bare .sort() calls on the lcov paths (impact.ts lines 73 and 157) onto byCodeUnit if they show up in a profile.
formatImpactandpackImpactinsrc/checks/impact.tsnow sort with a code-unit comparator instead of a bare.sort(). The packed-map test went from about 5 s to 1.82 s on this machine, which is well under its timeout.<and>orders strings the same way the default sort does, so the formatted output should be byte-for-byte the same. I did not diff the output before and after; the existing tests that cover it pass.sortedNameshelper.formatImpactand the one on the packed file list inpackImpactalso use the comparator..sort()calls at lines 73 and 157, in the lcov parsing, sit outside the two functions the issue names.Checks:
bun x tsc --noEmitpasses.test/check-tiers.test.tspasses, 54 tests.test/checks-home-sweep.test.ts,test/crew-red-outside-diff.test.tsandtest/shards-keep-going.test.tspass, 21 tests.bun scripts/gate.tsbut its output was cut off in the run, so I can't confirm it passed.scripts/fast.tsnamed 357 test files, about 30 minutes, which is too broad for this sandbox. I ran only the four files above that exerciseformatImpactandpackImpact. The forge's full check covers the rest.To try it:
bun test test/check-tiers.test.ts -t "three thousand".Closes #12555