Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Build a Smaller sccache

Rebuild a concurrent command cache, not merely a HashMap<String, Vec<u8>>.

What are we preserving?

  • a short-lived client and resident async server;
  • deterministic keys over declared and discovered inputs;
  • hit versus compile fallback;
  • a separate child-process budget;
  • captured output and exit status;
  • publication after successful completion;
  • runtime-selected storage;
  • graceful connection drain.

Stages

  1. Cache one fake compiler whose key includes source bytes and arguments.
  2. Put the cache behind a local Tokio socket protocol.
  3. Execute a real child command and capture declared output files.
  4. Add a semaphore-like process permit independent of connections.
  5. Implement disk storage through a Storage trait and atomic publication.
  6. Return output before awaiting a deliberately slow secondary cache write.
  7. Stop listener admission, drain connection tasks, then enforce a deadline.
  8. Add simultaneous same-key requests and decide whether to deduplicate them.

Compare the result with production sccache: compiler argument semantics, preprocessing, dependency normalization, archives, many storage systems, distributed toolchains, authentication, multi-level backfill, jobserver interop, platform process handling, statistics, and corruption recovery are the hardening layers still missing.