Repository navigation
feat(taskfiles): Add METADATA_ONLY option to checksum tasks to compute checksums from file metadata instead of file contents. - #125
Merged
LinZhihao-723 merged 4 commits intoOct 19, 2026
Conversation
…ute checksums from file metadata instead of file contents.
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
LinZhihao-723
marked this pull request as ready for review
October 19, 2026 02:00
sitaowang1998
approved these changes
Oct 19, 2026
sitaowang1998
left a comment
Contributor
There was a problem hiding this comment.
The code lgtm. I think we need to get an approval from Kirk for high level ides.
Member
Idea makes sense to me. |
This was referenced Oct 19, 2026
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.
Description
Motivation
Spider installs its Rust toolchain (stable and nightly, plus
clippy,rustfmt, andcargo-nextest) into its build directory using a task guarded bychecksum:validate/checksum:compute. The checksum is meant to make re-runs cheap: if the installed toolchain hasn't changed, the installation is skipped. However,checksum:computebuilds a fulltararchive of the include paths and pipes it throughmd5sum, so every validation reads and hashes the content of every file. For the Rust toolchain, this is ~3.07 GB across ~132k files.Since every Rust lint/build/test task depends on the toolchain task, every invocation pays this cost, even when all the actual work (e.g.,
cargo fmt --check) takes less than a second. Fortask lint:check-rust-formatin Spider:md5sumover 3 GB.autoMemoryReclaimenabled).Switching to a faster hash doesn't help much:
b2sumsaves ~0.7 s when warm and nothing when cold, since the disk I/O dominates.Solution
This PR adds an opt-in
METADATA_ONLYparameter tochecksum:computeandchecksum:validate. When set to"true", the checksum is computed over the metadata of the include paths instead of their contents:TZ=UTC LC_ALL=C tar --create --file /dev/null --full-time --verbose --verbose ... | md5sumWhy this works:
/dev/null, GNU tar skips reading file contents entirely (an optimization intended for archive size estimation). It only walks the directories andstats each entry.straceconfirms this: on the Rust toolchain, it issues 19readcalls (21 KB, all from shared libraries and locale files), compared with ~405kreadcalls for the content-based checksum.--verbose --verbose --full-time, tar still prints a long listing of every entry it would have archived, in the same--sort nameorder and subject to the same include/exclude patterns. Each line contains the entry's type, mode, owner/group (normalized to0/0by the existing--owner/--groupflags), size, mtime with nanosecond precision, path, and symlink/hard link target. Hashing this listing detects added, removed, and renamed files, permission changes, and any modification that updates the size or mtime.TZ=UTC LC_ALL=Cmakes the listing (and therefore the checksum) independent of the local time zone and locale, since tar renders timestamps in local time.--mtime "UTC 1970-01-01"is dropped in this mode, since the real mtime is the main change signal.Trade-offs:
touch) now invalidates the checksum, whereas it doesn't in content mode.The default remains content-based, so existing callers are unaffected. Like content mode, metadata mode relies on GNU tar (
gtaron macOS).Performance
Measured in Spider on the Rust toolchain (~3.07 GB, ~132k files), median of 3 runs. "Cold" means the toolchain's file contents were evicted from the page cache before each run.
task lint:check-rust-formatend to end, warm page cachetask lint:check-rust-formatend to end, cold page cacheThe metadata-only time no longer depends on the page cache, since no file contents are read.
Checklist
breaking change.
Validation performed
checksum-test-metadata-only-skip: An unchanged directory is skipped in metadata-only mode.checksum-test-metadata-only-rerun-on-mtime-change: Changing only a file's mtime triggers a rerun in metadata-only mode.checksum-test-skip-on-mtime-change: Changing only a file's mtime is still skipped in content mode (the default).task tests:checksumandtask tests:remotepass.task lint:check-yamlpasses.METADATA_ONLYunset, the checksum is identical to the one computed before this change.METADATA_ONLY: "true"for the Rust toolchain checksum):task lint:check-rust-format.stracethat no file contents in the toolchain are read.touching a file in the toolchain triggers a reinstallation, and that the next run skips it again.