Skip to content

wip: do most of the processing on the client side - instead of the server#2642

Closed
sylvestre wants to merge 8 commits intomozilla:mainfrom
sylvestre:client2
Closed

wip: do most of the processing on the client side - instead of the server#2642
sylvestre wants to merge 8 commits intomozilla:mainfrom
sylvestre:client2

Conversation

@sylvestre
Copy link
Copy Markdown
Collaborator

- Replace block_in_place with pool.block_on to avoid hanging when no
  tokio runtime context is available during cache initialization.
- Add 30s timeout to the HTTP client used for TaskCluster token fetch
  to prevent indefinite hangs when the endpoint is unreachable.
…jectSource serializable

- Fix from_bytes: previously passed pre-built bytes into a ZipWriter,
  which would append zip metadata on finish(), corrupting the data.
  Now stores them in a `prebuilt` field and returns them unchanged.
- Derive Serialize/Deserialize on FileObjectSource so it can be used
  in the IPC protocol for client-side compilation.
Redesign the client-side compilation protocol to avoid transferring
large artifacts over IPC:

- CacheGetRequest now includes output_paths so the server can extract
  artifacts directly to disk on a cache hit.
- CacheGetResponse::Hit now carries only stdout/stderr instead of the
  full cache entry bytes.
- CachePutRequest now includes output_paths (for the server to read
  from disk) plus stdout/stderr, replacing the raw entry bytes.

This relies on client and server sharing the same filesystem, which is
always the case since they run on the same machine.

Note: this commit temporarily breaks compilation of server.rs; the
next commit updates the server handlers to match.
- Remove IPC frame size limit (use usize::MAX) so large cache entries
  can be transferred when needed.
- handle_cache_get: extract artifacts directly to client-supplied paths
  on disk, returning only stdout/stderr over IPC.
- handle_cache_put: read output artifacts from disk, pack into a cache
  entry with stdout/stderr, and store to the backend. Errors are logged
  but don't crash the connection (best-effort caching).
Replace the stub that fell back to server-side compilation with the
full client-side flow:

1. Detect the compiler locally.
2. Parse arguments and bail out for non-cacheable invocations.
3. Run the preprocessor and compute the BLAKE3 cache key using a
   NoopStorage (real cache I/O goes through the server).
4. Send CacheGet to the server; on a hit the server extracts artifacts
   to disk and returns only stdout/stderr.
5. On a miss, compile locally and send CachePut so the server can
   read output files from disk and store them.
- Replace flowcharts with sequence diagrams for both compilation modes
- Add colored styling to mermaid diagrams
- Document C/C++ vs Rust cache key generation differences
- Add performance note for client-side preprocessing
- Update "foundational stage" note to reflect current implementation
The per-feature cargo test matrix was failing because tests depend on
features not included in the individual feature flag. Revert to cargo
check which validates compilation without running tests.
Mark test_server_unsupported_compiler and test_server_compile with
#[serial] and explicitly unset SCCACHE_CLIENT_SIDE_COMPILE so they
exercise the server-side compilation path regardless of the environment.
@sylvestre sylvestre changed the title Client2 wip: do most of the processing on the client side - instead of the server Mar 15, 2026
@sylvestre sylvestre closed this Mar 15, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 6.93069% with 282 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.94%. Comparing base (2b65ac8) to head (2b66a2e).

Files with missing lines Patch % Lines
src/commands.rs 2.89% 134 Missing ⚠️
src/server.rs 1.53% 128 Missing ⚠️
src/protocol.rs 0.00% 8 Missing ⚠️
src/cache/gcs.rs 12.50% 7 Missing ⚠️
src/cache/cache_io.rs 54.54% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2642      +/-   ##
==========================================
- Coverage   73.37%   72.94%   -0.43%     
==========================================
  Files          68       69       +1     
  Lines       37337    37582     +245     
==========================================
+ Hits        27395    27415      +20     
- Misses       9942    10167     +225     

☔ View full report in Codecov by Sentry.
📢 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.

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.

2 participants