Repository navigation
test: count work instead of elapsed time - #13452
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
tiensonqin
force-pushed
the
test/work-counts
branch
from
September 26, 2026 13:13
444b28f to
0e0718a
Compare
Contributor
|
Reasonable tradeoff replacing flaky One coverage note: removing the timing bounds from the two |
The 2 large tags-and-objects graph tests bounded wall-clock time (best of 3 under 1 s). They now count the d/entity lookups made while building the graph, at a small and a large size, and require the same count: 12 and 12000 unrelated pages, 12 and 3885 tagged objects.
combine-results: instead of a 200 ms CPU bound, count the reads of result fields and the db lookups at 625 and 2500 results. 4 times the results must take under 8 times the reads (linear gives 4, a scan per result 16) and the same number of db lookups. The 2 sync cases for 300 new blocks drop their 1 s CPU bound. The page-check count of the same insert now allows 1 check per new block; checking every new block for page descendants doubles it, which the old bound of 2 per block let through.
tiensonqin
force-pushed
the
test/work-counts
branch
from
September 30, 2026 10:49
0e0718a to
1c13ae8
Compare
devin-ai-integration Bot
pushed a commit
that referenced
this pull request
Oct 1, 2026
* test(graph-view): count entity lookups, not time The 2 large tags-and-objects graph tests bounded wall-clock time (best of 3 under 1 s). They now count the d/entity lookups made while building the graph, at a small and a large size, and require the same count: 12 and 12000 unrelated pages, 12 and 3885 tagged objects. * test(search): count work instead of CPU time combine-results: instead of a 200 ms CPU bound, count the reads of result fields and the db lookups at 625 and 2500 results. 4 times the results must take under 8 times the reads (linear gives 4, a scan per result 16) and the same number of db lookups. The 2 sync cases for 300 new blocks drop their 1 s CPU bound. The page-check count of the same insert now allows 1 check per new block; checking every new block for page descendants doubles it, which the old bound of 2 per block let through.
devin-ai-integration Bot
pushed a commit
that referenced
this pull request
Oct 8, 2026
* test(graph-view): count entity lookups, not time The 2 large tags-and-objects graph tests bounded wall-clock time (best of 3 under 1 s). They now count the d/entity lookups made while building the graph, at a small and a large size, and require the same count: 12 and 12000 unrelated pages, 12 and 3885 tagged objects. * test(search): count work instead of CPU time combine-results: instead of a 200 ms CPU bound, count the reads of result fields and the db lookups at 625 and 2500 results. 4 times the results must take under 8 times the reads (linear gives 4, a scan per result 16) and the same number of db lookups. The 2 sync cases for 300 new blocks drop their 1 s CPU bound. The page-check count of the same insert now allows 1 check per new block; checking every new block for page descendants doubles it, which the old bound of 2 per block let through.
devin-ai-integration Bot
pushed a commit
that referenced
this pull request
Oct 8, 2026
* test(graph-view): count entity lookups, not time The 2 large tags-and-objects graph tests bounded wall-clock time (best of 3 under 1 s). They now count the d/entity lookups made while building the graph, at a small and a large size, and require the same count: 12 and 12000 unrelated pages, 12 and 3885 tagged objects. * test(search): count work instead of CPU time combine-results: instead of a 200 ms CPU bound, count the reads of result fields and the db lookups at 625 and 2500 results. 4 times the results must take under 8 times the reads (linear gives 4, a scan per result 16) and the same number of db lookups. The 2 sync cases for 300 new blocks drop their 1 s CPU bound. The page-check count of the same insert now allows 1 check per new block; checking every new block for page descendants doubles it, which the old bound of 2 per block let through.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
The 5 unit-test assertions that bound elapsed time (listed in #13446) now bound the work done instead, counted with
with-redefswrappers, so they give the same result on a busy machine as on an idle one. Test code only; each test keeps its other assertions.frontend.worker.graph-view-test: the 2 large tags-and-objects graph tests count thed/entitylookups made while building the graph, at a small and a large size, and require the same count.frontend.worker.search-test: the combine-results case counts the reads of result fields and the db lookups at 625 and 2,500 results. The 2sync-search-indice-300-new-blocks-performance-*cases lose their time bound; other tests in the namespace count the work they guarded, and one of those,sync-search-indice-300-new-blocks-does-not-check-page-descendants, gets a tighter bound (below).fastest-buildandprocess-cpu-time-mshad no other users and are removed.Per test
Each count was checked against the slowdown it guards: in a scratch build, never committed, the slow code was put back behind an environment flag and the namespace run with and without the flag. Without it every test passes.
tags-and-objects-graph-skips-large-unrelated-page-set-quicklyGuards
f299b4e31("enhance: speed up tags graph", in #12604). The graph took every entity that has any tag, looked each up withd/entityand checked its visibility, then kept those tagged with a displayed tag. Every page carries the Page tag, so 12,000 plain pages meant over 12,000 lookups for an empty graph. Since the fix, only candidates of a displayed tag are looked up.Count:
d/entitycalls duringbuild-graph, with 12 unrelated pages and with 12,000: 417 and 417. The test asserts they are equal.Slow code put back (look up and check every entity of the
:block/tagsdatoms before the tag filter): 1,268 and 133,136. Fails.tags-and-objects-graph-builds-large-tagged-set-quicklyGuards
1cccd59ce("enhance: speed up graph opening", in #12604). Each tagged object was looked up withd/entity, checked withldb/hidden?,ldb/recycled?,ldb/class?andldb/property?, and its node built from entity attributes. Since the fix, visibility, titles and uuids come from datoms for all objects at once.Count:
d/entitycalls duringbuild-graph, with 12 tagged objects and with 3,885: 790 and 790, asserted equal. The node and link counts (3,886 and 3,885) stay.Slow code put back (
(visible-entity? (d/entity db id))for each tagged object): 1,078 and 94,030. Fails.combine-results-large-result-benchmarkGuards
e47539398("fix: speed up worker search").combine-resultslooked up each result withd/entityand found its keyword result with(first (filter #(= (:id %) id) keyword-results)), a scan of the results for each result. Since the fix, all results are pulled with 1d/pull-manyand walked once.Count: each keyword result is a map that counts the reads of its fields (
ReadCountingResult, adeftypeover the map). 625 results: 3,750 reads; 2,500 results: 15,000, 4 times as many. The test asserts under 8 times, the midpoint between linear (4) and quadratic (16) on a log scale. Thed/entityandd/pull-manycalls are counted too: 1 at both sizes, asserted equal. The result count and the page-boost ranking stay.Slow code put back:
d/entityper result instead ofd/pull-many: 625 and 2,500 db lookups. Fails.sync-search-indice-300-new-blocks-performance-when-semantic-search-enabledand...-disabledThe time bound came with #12818 ("fix: speed up incremental search indexing"), in its first commit
69b60c60b. That commit dropped the vector context: each synced block had its parent, previous and next sibling and children added to the batch, and its vector title built from them, which sorted the parent's children again for every block. A later commit of the same pull request,4d28bdcc1, stopped checking every new block for page descendants and addedsync-search-indice-300-new-blocks-does-not-check-page-descendants, which counts theldb/page?calls of the same 300-block insert.These tests already count each of those causes:
build-blocks-indice-uses-block-indexasserts 0ldb/sort-by-ordercalls whileblock->index, the function sync uses, builds vector titles for 40 siblings. With the sort put back intoblock->index: 40 calls. Fails.sync-search-indice-indexes-only-directly-affected-blocksasserts the parent and siblings stay out. With the expansion put back: 301 blocks (the page joins), and both fail.does-not-check-page-descendantscounts 300 page checks now, 1 per new block. With4d28bdcc1's key line reverted (page-hierarchy-eidskeeps the blocks that have a:block/pagedatom): 600. Its bound was(<= checks 600), so it still passed with the revert; it is now(<= checks 300), and the revert fails it.The 2 cases keep their other assertions: 300 blocks, and vector titles present and equal to the titles, or absent.
Tests
frontend.worker.graph-view-test(20 tests, 59 assertions) andfrontend.worker.search-test(65 tests, 213 assertions), withTZ=Etc/GMT+12andTZ=Pacific/Kiritimati: 0 failures, 0 errors in each. The counts do not vary between runs, so each ran once.TZ=Etc/GMT+12(2476 tests, 12406 assertions) and once withTZ=Pacific/Kiritimati(the 1446 tests of the date-dependent namespaces). The only failures are the 3 zone-dependent tests that fix(test): build test dates in local time #13430 fixes (6 assertions at UTC-12, 4 at UTC+14), the same as on master.Refs #13446.
Allow edits from maintainers.