Repository navigation
fix(dash): cache /api/components like /api/stats and /api/facets - #116
Merged
Merged
Conversation
/api/components had no cache at all -- PR #108 added the 5s TTL jsonCache to /api/stats and /api/facets but missed this one, so the dashboard's most-read tab re-ran all five of its queries (Components, DecomposeComponentSavedUSD, EstimateComponentSavedUSD) cold on every load. Measured on a corpus matching production scale (70k requests x 7 components, 490k request_components rows): ~4.4s per load, every time -- a dashboard tab left auto-refreshing, or two managers on the same window, each paid that cost independently, exactly the "piling up under load" pattern #108 already fixed everywhere else. Added componentsCache alongside statsCache/facetsCache and wrapped a.components the same way a.stats already wraps Overview. Added TestComponentsCached, which does not even compile against the pre-fix code (no componentsCache field) and passes against the fix. Signed-off-by: Osher-Elhadad <[email protected]>
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
The Components page has been "loading forever."
/api/componentshad nocache at all — PR #108 added the 5s TTL
jsonCacheto/api/statsand/api/facets, but missed this one, so the dashboard's most-read tab re-ranall five of its queries (
Components,DecomposeComponentSavedUSD,EstimateComponentSavedUSD) cold on every single load.Measured on a corpus matching production scale (70k requests x 7
components, 490k
request_componentsrows, all properly indexed — this isnot a missing-index or N+1 bug):
A tab left auto-refreshing, or two managers on the same window, each paid
that ~4.4s independently — the exact "piling up under load" pattern #108
already fixed everywhere else on this endpoint's neighbors.
(The Overview page's "sometimes a few minutes" report is the WAL-checkpoint
mechanism fixed separately in #115 — Overview shares the same
*sql.DBwiththe writer that /metrics does. Not re-fixed here.)
Fix
Added
componentsCachealongside the existingstatsCache/facetsCacheand wrapped
a.componentsthe same waya.statsalready wrapsOverview.No new abstraction, no query changes.
Test plan
go build ./...andgo vet ./...cleango test ./...passes across the whole repoTestComponentsCached— does not even compile against thepre-fix code (no
componentsCachefield) and passes against the fix