Cache bug suggestions client-side to avoid redundant refetches#9667
Open
camd wants to merge 1 commit into
Open
Cache bug suggestions client-side to avoid redundant refetches#9667camd wants to merge 1 commit into
camd wants to merge 1 commit into
Conversation
The Failure Summary tab refetched /bug_suggestions/ on every remount. Because react-tabs unmounts inactive TabPanels, switching away from and back to the tab (or re-selecting a job) remounted FailureSummaryTab and refetched + re-processed identical data, which felt slow even though the backend caches the result. Add a bounded, per-session cache in BugSuggestionsModel keyed by jobId, mirroring the decisionTaskIdCache pattern in models/push.js: - Serve cache hits without a network round trip. - Only cache non-empty results, so a still-parsing job (empty response) keeps refetching until suggestions appear. - Cap the cache at 50 entries, evicting the oldest. - Expire entries after a 1h TTL so a long-lived session eventually picks up a newly-filed bug once the backend's own 24h cache has refreshed. Add unit tests covering cache hits, the empty-result bypass, TTL expiry, and size-limit eviction.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9667 +/- ##
=======================================
Coverage 82.59% 82.60%
=======================================
Files 622 622
Lines 36580 36592 +12
Branches 3279 3282 +3
=======================================
+ Hits 30213 30225 +12
Misses 6217 6217
Partials 150 150 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
The
/jobsdetails panel Failure Summary tab felt slow.BugSuggestionsModel.get()was a barefetchwith no client-side caching. Because react-tabs unmounts inactiveTabPanels (noforceRenderTabPanel), switching away from and back to the Failure Summary tab — or re-selecting a previously viewed job — remountedFailureSummaryTab, which refetched/bug_suggestions/and re-ranfilterGenericFailureson identical data every time. The backend already caches the error summary per job for 24h, so this was pure redundant work on a warm backend.forceRenderTabPanelwas considered and rejected: it eagerly mounts all sibling tabs for every selected job, andSimilarJobsTabfetches on mount, so it would add network load nobody asked for.Change
Add a bounded, per-session cache in
BugSuggestionsModelkeyed byjobId, mirroring the existingdecisionTaskIdCachepattern inmodels/push.js:FailureSummaryTabis untouched — it just benefits from the now cache-aware model.Why 1h TTL is enough
Measured against the prod replica (30d, 57,486 classifications): 96.5% of classifications reference a bug that was already in use before the job even finished (a lower bound), and of the ≤3.5% "new bug" cases, 97% are filed within 24h of the job during active triage — where the backend's 24h cache is the binding constraint, not the frontend. So staleness from a genuinely new bug is rare, and the 1h TTL comfortably covers it.
Tests
New unit tests in
tests/ui/models/bugSuggestions_test.jscover cache hits, the empty-result bypass, TTL expiry, and size-limit eviction.