feat(metrics-explorer): fast path for get treemap in case of no filter#11459
feat(metrics-explorer): fast path for get treemap in case of no filter#11459nikhilmantri0902 wants to merge 2 commits into
Conversation
💡 Codex Reviewsignoz/pkg/modules/metricsexplorer/implmetricsexplorer/module.go Lines 1140 to 1143 in 5fb4c4b The new signoz/pkg/modules/metricsexplorer/implmetricsexplorer/module.go Lines 1403 to 1405 in 5fb4c4b The no-filter treemap fast path drops the fingerprint predicate entirely and aggregates by metric name only. The previous implementation always scoped sample counts to ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Pull Request
📄 Summary
GetTreemap(samples mode) narrows the samples-table scan viafingerprint IN (huge set)regardless of filter presence. That set is millions of UInt64s.When no user filter is present, the
__metric_candidatesIN-set is the only narrowing needed . The__filtered_fingerprintsCTE andfingerprint IN (…)predicate become pure overhead.This PR adds
computeSamplesTreemapFastPathand dispatches to it fromGetTreemapwhenreq.Filteris empty. TimeSeries mode unchanged.Follow-up to the
GetStatsfastpath PR (same pattern, different endpoint).Issues closed by this PR
Part of https://github.com/SigNoz/engineering-pod/issues/5043
✅ Change Type
🐛 Bug Context
Fix Strategy
Dispatch upstream from
req.FilterinGetTreemap:hasFilter := req.Filter != nil && strings.TrimSpace(req.Filter.Expression) != ""!hasFilter→ newcomputeSamplesTreemapFastPath(no filter param, no__filtered_fingerprints)hasFilter→ existingcomputeSamplesTreemapFastpath body matches slowpath exactly except: (1) no
filterWhereClause.AddWhereClauseon__metric_candidates, (2) no__filtered_fingerprintsCTE, (3) nofingerprint IN (…)predicate. Both differences are gated on filter presence in the slowpath.🧪 Testing Strategy
metric_name GLOBAL IN (__metric_candidates)only; no__filtered_fingerprints.samplesandpercentageformetric_name = 'http.server.duration.bucket'between fastpath and slowpath responses — match exactly.req.Filter == nil→ fastpath.count(*)vssum(count)table-aware viaCountExpressionForSamplesTable.GetTreemapsamples-mode no-filter calls only. TimeSeries mode and with-filter samples path untouched.__metric_candidates, same__total_samples, same__sample_counts(modulo fingerprint predicate). Semantic equivalence verifiedmanually.
📝 Changelog
📋 Checklist
👀 Notes for Reviewers
GetStatsfastpath PR — samehasFiltercheck, same shape.buildFilterClauseis now called once perGetTreemapinvocation (was already the case). When!hasFilterand samples mode, the returned emptyWhereClauseis discarded —buildFilterClauseshort-circuits on empty expression(
module.go:932-934) so this is essentially free.computeSamplesTreemapleft intact (not renamed) — minimizes diff. Itsif filterWhereClause != nilguards are now always true under the new dispatch, but harmless.