Repository navigation
perf(clientdb): avoid rescanning children for new spans - #14738
Merged
Merged
Conversation
grouville
force-pushed
the
perf/review-span-child-index
branch
3 times, most recently
from
October 22, 2026 05:42
800965a to
9ee81f8
Compare
This was referenced Oct 22, 2026
grouville
force-pushed
the
perf/review-span-child-index
branch
from
October 23, 2026 05:18
9ee81f8 to
24446e4
Compare
tiborvass
marked this pull request as ready for review
October 27, 2026 18:41
tiborvass
force-pushed
the
perf/review-span-child-index
branch
2 times, most recently
from
October 27, 2026 19:37
1ad67a1 to
200ae7f
Compare
Go test collection listing produces wide traces. Adding each new child currently scans its siblings to reject duplicates, so the work grows quadratically with the number of children. A real dagger/dagger listing recorded more than two billion such comparisons. Use the existing parent map to recognize new span IDs. Keep the old scan for IDs repeated across traces. For cause links, check the existing reverse index instead of every span linked to the same target. Both directions are updated together under the existing lock. Add a compatibility test for repeated IDs and late parents/links, plus a benchmark that builds a fresh index at several widths. No additional map, lock or retained state is introduced. Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Tibor Vass <[email protected]>
grouville
force-pushed
the
perf/review-span-child-index
branch
from
October 27, 2026 21:16
200ae7f to
dfa7ebc
Compare
tiborvass
approved these changes
Oct 27, 2026
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.
Listing Go tests in dagger/dagger creates many spans under the same query. Each new child currently scans the query's existing children to reject duplicates. A captured listing had 53,749 children under one query; across that trace, those scans require about 1.47 billion string comparisons.
Use the existing parent map to recognize a new span ID and append it directly. Keep the duplicate check for IDs reused across traces. For cause links, check the span's own targets instead of every span linked to the same target. Both directions are already recorded together under the same lock. This adds no map, lock or retained state.
This is part of the work to make Go collection listing faster.
Standalone measurement on main
I replayed the actual 225,955 span snapshots against engine main at 14c1942, with only this change applied to the candidate.
These are medians of two replays per version, in opposite orders. Every index and child order matches. Reading and decoding the capture are outside the measurement. The host was busy, so these numbers measure CPU work rather than elapsed command time.
Effect on a full listing
dagger check --module go --check test --list --allA CPU profile covering final shutdown also found about 8.3 CPU-seconds in the sibling scan. The unpatched command then repeatedly reached the CLI's 10-second deadline while flushing traces. It returned the correct rows but exited with a cleanup error.
With this change, three warm listings completed in 84.10–85.13 s, including all 4,399 expected rows and cleanup. One of those runs spent 0.39 s flushing traces. Returning to the unpatched engine reproduced the 10-second flush timeout.
This establishes a useful effect on completion. It does not establish a paired full-command speedup: the unpatched commands failed, so their times are excluded.
These full runs use main at
14c1942, with #14730, the parser from Dang #204, and Dang #205 common to both versions. The Go module is merged main atbf45651plus Go #68. The source is dagger/dagger atff0b029a, withtest = ["."]selecting the root Go module. Each command starts a fresh CLI after source and test edits. Both versions use the same CLI, including a local stdout-buffer correctness fix, eight CPUs, 40 GiB RAM, normal telemetry and GC, and profiling off.Tests
The full
engine/clientdbrace suite passes on14c1942. The added test covers repeated snapshots, IDs reused across traces, late parents and cause links, and child order.