perf(grc): normalize runtime scope reads - #2652
Merged
Merged
Conversation
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.
Summary
source_runtimes.runtime_json, index those columns concurrently, and retire the replaced JSON-expression indexes.finding_evidence_counts; the aggregate plan does not scan rawfinding_evidence.Measured result
Exact-head
397003c0293b718768c46e0fe3b205ddabdcd824synthetic 500-runtime query-construction benchmark, three 2-second runs on darwin/arm64:That is 98.7% less query-construction time, 98.3% fewer allocated bytes, and 97.6% fewer allocations.
Postgres 16 scope-plan comparison over synthetic runtime/finding rows, 12 alternating warm runs:
The normalized plan cuts query text 94.7% and makes scope cardinality independent of runtime count. The measured database tradeoff is +0.600 ms execution and 42 shared-buffer hits on this synthetic corpus.
Validation
CEREBRO_POSTGRES_DSN=... go test ./internal/statestore/postgres -run TestGRCDashboardAggregatePlanUsesMaterializedEvidenceCountsPostgresIntegration -count=1CEREBRO_POSTGRES_DSN=... go test ./internal/statestore/postgres -run TestSourceRuntimeGeneratedScopeColumnsStayTenantWorkspaceIsolatedPostgresIntegration -count=1go test ./... -count=1go test -race ./internal/statestore/postgres ./internal/bootstrap -count=1make lint-internalmake check-structural check-structural-test check-archmake changed-check