Skip to content

cache: preserve and count lookup read errors - #2967

Merged
sylvestre merged 10 commits into
mozilla:mainfrom
aw1cks-forks:aggregate-cache-read-errors
Nov 22, 2026
Merged

sylvestre merged 10 commits into
mozilla:mainfrom
aw1cks-forks:aggregate-cache-read-errors

Conversation

@aw1cks

@aw1cks aw1cks commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fix two gaps in cache read-error reporting:

  • Read-error cache misses omitted cache_read_errors.
  • Client-side lookups turned backend failures and invalid cached archives into ordinary misses.

Keep existing hit/miss wire replies unchanged and report backend lookup failures through a separate error response. Older clients reject that response rather than decode it as a miss. Restart the daemon after updating to use the corrected error handling.

@codecov-commenter

codecov-commenter commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.84685% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.80%. Comparing base (153cad6) to head (b5f1642).

Files with missing lines Patch % Lines
src/protocol.rs 86.48% 5 Missing ⚠️
src/server.rs 98.80% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2967      +/-   ##
==========================================
+ Coverage   79.69%   79.80%   +0.10%     
==========================================
  Files          75       76       +1     
  Lines       46614    46854     +240     
==========================================
+ Hits        37149    37391     +242     
+ Misses       9465     9463       -2     

☔ 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.

Comment thread docs/Architecture.md Outdated
compilation increments `Cache read errors` as well as the existing `Cache errors`
and `Cache misses` counters. Ordinary misses do not increment the read-error
counter, and overall lookup timeouts are recorded separately as `Cache timeouts`.
Errors handled inside a multilevel tier walk are not aggregate lookup errors.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didn't understand this line, could you please clarify or drop it? :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded in 804433b let me know what you think

Comment thread src/cache/ipc_storage.rs Resolved
Comment thread src/test/mock_storage.rs Resolved
@aw1cks

aw1cks commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

I also found another error-to-miss issue in disk path lookup - 47010f9
I've now wired error propagation through StorageGetPath for disk-cache initialisation failures

@aw1cks
aw1cks requested a review from sylvestre October 31, 2026 12:46
@aw1cks

aw1cks commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Upon further inspection, I've noticed that an older client can interpret StorageGetRaw(Ok(Some(...))) or StorageGetPath(Err(...)) as a miss rather than failing decoding.

Would an explicit fail be preferred here? Precedent was not clear to me in previous breaking changes.

@aw1cks
aw1cks force-pushed the aggregate-cache-read-errors branch from cba732f to 8fe6532 Compare November 12, 2026 22:34
@aw1cks

aw1cks commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

hi @sylvestre , I have rebased this PR along with #2966 and #2965 , if you had some time to approve the CI runs & re-review it would be much appreciated 🙂
r.e. #2967 (comment) - I ended up erring on the side of caution, preserving existing hit/miss wire replies and using a separate error response

Comment thread src/cache/ipc_storage.rs Resolved
Comment thread src/compiler/nvcc.rs Resolved
Changing the payload of an existing bincode variant can let an older
client decode an error as a miss. Keep the path and raw success replies
unchanged and append a distinct StorageReadError variant instead.

Keep the backend cause in the daemon log as well as in the reply. The
compile path counts lookup errors; a tier that fails during fallback
is not itself an aggregate read error.
A backend without a local path returns archive bytes over IPC. If those
bytes are corrupt, the ZIP error explains what went wrong but does not
identify the entry to inspect.

Attach the lookup key only on decode failure. The IPC regression test
checks that the diagnostic names the key and retains the ZIP cause.
@aw1cks
aw1cks force-pushed the aggregate-cache-read-errors branch from 8fe6532 to 516dc50 Compare November 18, 2026 11:34
Comment thread src/protocol.rs Resolved
Derived equality checks the path on a hit and distinguishes a miss
from an unsupported lookup. Use it for both decoding directions; the
serialized bytes and the compatibility cases stay unchanged.
After the upstream storage trait split, get() on a concrete IpcStorage
requires CacheStorage in scope. Import it in the server tests so both
raw and disk-path lookup cases compile on the merged branch.
@sylvestre
sylvestre merged commit 62773e7 into mozilla:main Nov 22, 2026
51 checks passed
@sylvestre

Copy link
Copy Markdown
Collaborator

Thanks for your PR

katopz added a commit to riir-ai/sccache that referenced this pull request Nov 23, 2026
Rebased onto main at 0e8f184 (the mozilla#3007 CacheStorage/PreprocessorCacheStorage
split + mozilla#2967's StorageReadError wire). BackoffStorage now implements
CacheStorage (get_path returns Result<GetPathResult>) plus an empty
PreprocessorCacheStorage forward - preprocessor entries are a local-disk
concern, never a stalled-backend read the gate exists for - so Storage comes
back via the blanket impl and the chain keeps wrapping Arc<dyn Storage>.

The server's StorageGetRaw handler keeps the skip/timeout arms ahead of the
new storage_read_error path: a skipped or timed-out lookup is reported to the
client as an absent entry, never as a counted read error - a gate skip is not
a failure the client should count.

Test fixtures implement CacheStorage + the empty preprocessor impl; the
cancelled-read test uses Waker::noop() (clippy 1.99's manual_noop_waker).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants