Repository navigation
reapi: hash files and build a remote compile's input root - #4
Merged
Merged
Conversation
tiny-ac
force-pushed
the
reapi/digests
branch
from
October 21, 2026 15:22
6106ec3 to
b680f1d
Compare
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.
Adds SHA-256 file digests, a cache of them, and the digest of a remote compile's input root, REAPI's name for the directory tree of every file the compile reads. Nothing calls them yet; a later PR sends them to a REAPI server.
DigestCachehashes a file again when its size, modification time, ctime or inode changes. It doesn't cache files changed in the last 2 s, since on a filesystem with coarse timestamps a same-size edit can leave the size, modification time and ctime unchanged. When full (100,000 entries), it drops every entry that isn't pinned.digest_and_pinpins an entry,savewrites the pinned entries to a file, andloadreads them back as pinned.InputRoot::buildlays out the files as REAPI's canonicalDirectorytree and returns the root's digest. It fails on conflicting or invalid paths.Changes
src/reapi/digest.rs:of_bytes,of_fileandDigestCache.src/reapi/input_root.rs:InputRootandInputRootFile.Cargo.toml:reapienables the existing optionalsha2dependency.Cost
Without the
reapifeature, nothing new is compiled. With it, onlysha2is added, whichdist-clientalready uses.Known limits
On Windows the cache checks a file's creation time instead of its ctime and inode, so an in-place edit that keeps the size and modification time goes unnoticed. sccache's preprocessor cache has the same limit.
Validation
-D warningsand--features reapi, at each commit.cargo test --features reapi --lib reapi::: 27 new tests, 13 for digests (one Unix-only, one Linux-only) and 14 for the input root.cargo check --no-default-features --features reapi.