Skip to content

A file's mtime is unique, so cargo's freshness record is stable - #77

Merged
lann merged 1 commit into
mainfrom
ci-mtime-ties
Aug 15, 2026
Merged

A file's mtime is unique, so cargo's freshness record is stable#77
lann merged 1 commit into
mainfrom
ci-mtime-ties

Conversation

@lannbot

@lannbot lannbot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What

Each file's restored mtime takes a sub-second offset derived from its path, and scripts/restore-mtimes.py joins the build-directory cache key.

Why

#76 measured a steady gate of 3m12 with nothing compiled. On main it settled at 4m52 with eight units rebuilding every run — iroh, iroh-dns ×3, iroh-relay ×3, iroh-peer — from an exact-key cache hit. The branch's clean run was luck.

Cargo records a path dependency's freshness as the newest mtime in the package and the name of the file that carried it. A commit that touches several files gives them all one timestamp, so which file is newest is decided by directory order, which differs between clones. Running the gate under fingerprint logging (probe run 31740876568) names it exactly:

iroh-dns dirty: PrecalculatedComponentsChanged {
    old: "1784575660.000000000s (Cargo.toml)",
    new: "1784575660.000000000s (CHANGELOG.md)" }
iroh-relay dirty: PrecalculatedComponentsChanged { ... (Cargo.toml) → (CHANGELOG.md) }
iroh dirty:      UnitDependencyInfoChanged { ... }   ← the cascade
iroh-peer dirty: UnitDependencyInfoChanged { ... }

Same instant, different file. A path-derived nanosecond offset makes one file strictly newest, and every clone agrees which. Verified locally: every package under .deps/iroh now has exactly one newest file (iroh-dns previously tied Cargo.toml with CHANGELOG.md, precisely as cargo reported).

Measured

Seeded, then two consecutive runs on this branch — each re-clones .deps, so each walks a differently ordered directory:

run compiled gate step
31741582706 (seeds the key) 9
31742095487 0 2 m 42 s
31742497596 0 2 m 44 s

Against 4m52 with eight rebuilds on main today. just check passes; this PR's own run is the gate.

Notes

  • The key gains scripts/restore-mtimes.py: artifacts are kept on the strength of the mtimes they were judged fresh against, so changing how those are assigned must invalidate them. Removing the temporary branch allowlist used for the measurement changes ci.yml, which is in the key too — so the first run on main restores the newest entry under the prefix (not cold), rebuilds those units once, and saves. The run after that is the steady state above.
  • Verification allowlist stripped; the branch is one commit.

Cargo records a path dependency's freshness as the newest mtime in the
package and the name of the file that carried it. Dating files by their
last commit gives every file a commit touched the same timestamp, so
which one is newest falls to directory order — which differs between
clones. The gate rebuilt iroh, iroh-dns, iroh-relay and iroh-peer on
every run, reporting

    PrecalculatedComponentsChanged {
        old: "1784575660.000000000s (Cargo.toml)",
        new: "1784575660.000000000s (CHANGELOG.md)" }

the same instant, a different file. Each file now takes a sub-second
offset derived from its path, so one file is newest and every clone
agrees which.

The stamping policy joins the build-directory cache key: artifacts are
kept or discarded on the strength of the mtimes they were judged
against, so a change to how those are assigned invalidates them.
@lann
lann merged commit 6398cab into main Aug 15, 2026
1 check passed
@lann
lann deleted the ci-mtime-ties branch August 15, 2026 00:05
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