Repository navigation
Conversation
simonswine
left a comment
There was a problem hiding this comment.
Thanks for bringing this ingestion optimisation to the query path.
In our workload we barely see any regression, but also no improvement. I think for us it is very uncommon to have a node with more than 64 children. full report
Before we can merge this we need to fix the clash with the truncation marker and add a regression test case.
Btw: I also run the benchmarks from a draft PR of mine against it: #5661
See the results here: https://simonswine.github.io/benchstat-prof-reports/reports/pyroscope-5759-main-common-100x/report.html
| if i, ok := t.wide.get(childKey(parent, location)); ok { | ||
| return i | ||
| } | ||
| tail := childKey(parent, sentinel) |
There was a problem hiding this comment.
Using sentinel here will mix up wide nodes and truncated children nodes. They get marked here btw:
pyroscope/pkg/phlaredb/symdb/resolver_tree.go
Line 457 in 8551b4c
I think we should likely use a separate constant at least for marking wide nodes (potentially for both).
There was a problem hiding this comment.
Thx for spotting this one!
Signed commits reportAll 3 commits between |
1a30f45 to
b72e8d6
Compare
StacktraceTree.Insertfinds a child by walking its parent's sibling list, so inserting under a node with N children costs O(N). Profiles of whole hosts have nodes with thousands of children: stacks that are cut short (failed unwinds, truncated stacks) all hang off the root, each with a distinct leaf. Every insert then scans those siblings, and building the tree of such a profile is dominated by that scan.This is the same fix as #5732 for
symdb.stacktraceTree, applied tomodel.StacktraceTree, which the query path uses to build the intermediate tree of each stack trace range.Change
childIndexdesign as symdb: index children of wide stack trace tree nodes #5732, which allocates a few times per tree rather than once per entry).Resetclears the index.Tests
Test_StacktraceTree_Insert_matches_sibling_scan: the nodes built byInsertare identical to those of a plain sibling-scan reference, on wide and narrow synthetic stacks and onpkg/phlaredb/symdb/testdata/big-profile.pb.gz.Test_StacktraceTree_Reset_clears_wide_index.Benchmarks
fanoutsweeps the number of children of the hottest node (visits skewed towards the first children, as in real profiles). The index is neutral below 32 children and never slower at any width; the gain grows with width.wide: synthetic stacks with 5000 distinct root frames and 500 second frames.narrow: deep stacks over 4 frames per level; no node becomes wide.profile:big-profile.pb.gzis 9% slower. It has no node wide enough to benefit, and pays for tracking the last sibling on each scan. This is the same trade-off as in symdb: index children of wide stack trace tree nodes #5732In production (whole-host CPU profiles),
StacktraceTree.Insertwent from ~21% to ~3% of query-backend CPU under load.