Skip to content

Cache bug suggestions client-side to avoid redundant refetches#9667

Open
camd wants to merge 1 commit into
masterfrom
camd/failure-summary-bugsuggestions-cache
Open

Cache bug suggestions client-side to avoid redundant refetches#9667
camd wants to merge 1 commit into
masterfrom
camd/failure-summary-bugsuggestions-cache

Conversation

@camd

@camd camd commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Problem

The /jobs details panel Failure Summary tab felt slow. BugSuggestionsModel.get() was a bare fetch with no client-side caching. Because react-tabs unmounts inactive TabPanels (no forceRenderTabPanel), switching away from and back to the Failure Summary tab — or re-selecting a previously viewed job — remounted FailureSummaryTab, which refetched /bug_suggestions/ and re-ran filterGenericFailures on 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.

forceRenderTabPanel was considered and rejected: it eagerly mounts all sibling tabs for every selected job, and SimilarJobsTab fetches on mount, so it would add network load nobody asked for.

Change

Add a bounded, per-session cache in BugSuggestionsModel keyed by jobId, mirroring the existing decisionTaskIdCache pattern in models/push.js:

  • Serve cache hits without a network round trip.
  • Only cache non-empty results — an empty response means "no failures yet" or "log parsing still in progress", so leaving those uncached lets a later revisit pick up suggestions once the log finishes parsing.
  • 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.

FailureSummaryTab is 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.js cover cache hits, the empty-result bypass, TTL expiry, and size-limit eviction.

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-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.60%. Comparing base (740daac) to head (a3b4164).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants