Repository navigation
Description
5 unit-test assertions check elapsed time. They fail whenever the machine running the suite is busy, whether or not the code under test got slower:
frontend.worker.graph-view-test/tags-and-objects-graph-skips-large-unrelated-page-set-quickly:(< elapsed 1000), wall clock, best of 3.frontend.worker.graph-view-test/tags-and-objects-graph-builds-large-tagged-set-quickly:(< elapsed 1000), wall clock, best of 3.frontend.worker.search-test, the combine-results case:(< elapsed-ms 200), process CPU time.frontend.worker.search-test/sync-search-indice-300-new-blocks-performance-when-semantic-search-enabledand...-disabled:(< elapsed-ms 1000), process CPU time.
Two examples from running the suite on a laptop that was also in use: tags-and-objects-graph-builds-large-tagged-set-quickly measured 1509 ms; sync-search-indice-300-new-blocks-performance-when-semantic-search-enabled failed once and passed twice when run again alone, with no code change in between.
Proposal: keep each performance guarantee, but assert on work done instead of time, so the result does not depend on the machine.
- Count the work. For example, the "skips large unrelated page set" test builds the tags-and-objects graph over 12,000 unrelated pages. Instead of "under 1 second", count the entity lookups (
d/entity) duringbuild-graphand assert that the count does not depend on the 12,000 pages. This is the same idea as Django'sassertNumQueries. - Compare the work at 2 sizes. For a guarantee like "stays linear", count the work at n and at 4n items and assert it grew about 4 times, not 16. This catches the accidentally quadratic code these tests guard against, on any machine. The combine-results case already replaces
d/entityandd/pull-manywith stubs, so it can count their calls directly.
For the sync-search-indice pair, sync-search-indice-300-new-blocks-does-not-check-page-descendants already asserts the cause of the slowdown they guard without timing, so their time bound could go.
Timing itself would then belong in a separate benchmark run on a quiet machine that compares against earlier runs, rather than in the unit suite.
I can send a pull request that converts the 5 assertions this way, if that approach is acceptable.
Activity
yuxi-liu-wired commentedon Sep 30, 2026
Resolved by #13452: the 5 elapsed-time assertions listed here now bound the work done instead, and master has no elapsed-time assertion left in these tests.