Skip to content

Restore matching build-script input timestamps - #40

Merged
zanieb merged 4 commits into
mainfrom
zb/cache-build-script-mtimes
Oct 24, 2026
Merged

zanieb merged 4 commits into
mainfrom
zb/cache-build-script-mtimes

Conversation

@zanieb

@zanieb zanieb commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

A warm workspace cache can still trigger substantial recompilation after a fresh CI checkout. checksum-freshness recognizes unchanged Rust sources, but Cargo still uses timestamps for build-script input checks. New checkout timestamps can therefore rerun build scripts and rebuild dependent crates even when those inputs are unchanged. CI pays for both restoring the artifacts and rebuilding them.

Cache hashes, modes, and timestamps for tracked files in workspace packages with build scripts alongside the artifacts, and restore timestamps for matching files and directories. Changes to tracked inputs or directory entries within a current build-script package invalidate that package's cached runs and their output directories in the selected profiles. Refresh Git's index metadata afterwards so subsequent checkouts can recognize unchanged files.

Timestamp restoration is part of the normal cache lifecycle. It requires Git and either uv or Python before the action, and one artifact cache per workspace so the input snapshot corresponds to the restored outputs. Git metadata, symlinks, untracked files, and inputs outside these packages retain Cargo's usual freshness checks.

@zanieb
zanieb marked this pull request as ready for review October 24, 2026 03:40
@zanieb
zanieb merged commit 52ea66b into main Oct 24, 2026
3 checks passed
@zanieb
zanieb deleted the zb/cache-build-script-mtimes branch October 24, 2026 03:41
astral-automations-bot Bot added a commit to astral-sh/uv that referenced this pull request Oct 24, 2026
Fresh checkouts can change build-script input timestamps and invalidate
otherwise reusable workspace artifacts. Enable the shared cache action's
timestamp restoration for the Linux test job and the Linux x86_64
development-binary job.

Uses the timestamp restoration from astral-sh/github-actions#40.

Twenty paired exact warm-cache hits per row. Times are means in seconds,
excluding queue and pre-step runner waiting. In the table, parentheses
give the 90% confidence interval for mean time saved.

| Job | Before (s) | After (s) | Speedup | Saved (s; 90% CI) |
| --- | ---: | ---: | ---: | ---: |
| Linux tests | 256.5 | 212.6 | 1.21× | 43.9 (27.7 to 60.1) |
| Linux development binary | 41.6 | 32.4 | 1.29× | 9.2 (7.0 to 11.5) |

<details>
<summary>Timing scope and runs</summary>

uv source is pinned to
[0eac269](astral-sh@0eac269).
The baseline uses the merged cache action at `3c9fe5d`; the candidate
enables timestamp restoration at `374b3d5`. Each pair uses the same
runner class and workload.

Times span the first job step through post steps, including setup, cache
restoration, and the development binary upload. Speedup is the ratio of
mean times. The paired t intervals estimate uncertainty in the mean
saving under these conditions. Values are rounded independently. Cache
creation is outside these warm-hit timings.

The Linux breakdown below uses Cargo’s reported build time and
`nextest`’s execution timer. Other job steps are outside this breakdown.
Negative savings mean slower execution.

| Job | Before (s) | After (s) | Speedup | Saved (s; 90% CI) |
| --- | ---: | ---: | ---: | ---: |
| Linux test compilation | 45.4 | 11.9 | 3.80× | 33.4 (30.0 to 36.9) |
| Linux `nextest` execution | 136.1 | 126.9 | 1.07× | 9.2 (-3.3 to 21.6)
|

The `nextest` interval includes zero, so these runs do not establish a
change in test execution time.

Linux pairs:
[1](https://github.com/astral-sh/uv-dev/actions/runs/39845565322),
[2](https://github.com/astral-sh/uv-dev/actions/runs/39845570448),
[3](https://github.com/astral-sh/uv-dev/actions/runs/39845575641),
[4](https://github.com/astral-sh/uv-dev/actions/runs/39846271408),
[5](https://github.com/astral-sh/uv-dev/actions/runs/39846430674),
[6](https://github.com/astral-sh/uv-dev/actions/runs/39846516805),
[7](https://github.com/astral-sh/uv-dev/actions/runs/39847137654),
[8](https://github.com/astral-sh/uv-dev/actions/runs/39847303298),
[9](https://github.com/astral-sh/uv-dev/actions/runs/39847390120),
[10](https://github.com/astral-sh/uv-dev/actions/runs/39848003824),
[11](https://github.com/astral-sh/uv-dev/actions/runs/39848163631),
[12](https://github.com/astral-sh/uv-dev/actions/runs/39848250928),
[13](https://github.com/astral-sh/uv-dev/actions/runs/39848718406),
[14](https://github.com/astral-sh/uv-dev/actions/runs/39848950527),
[15](https://github.com/astral-sh/uv-dev/actions/runs/39849111871),
[16](https://github.com/astral-sh/uv-dev/actions/runs/39849342421),
[17](https://github.com/astral-sh/uv-dev/actions/runs/39850043674),
[18](https://github.com/astral-sh/uv-dev/actions/runs/39850206043),
[19](https://github.com/astral-sh/uv-dev/actions/runs/39850289227),
[20](https://github.com/astral-sh/uv-dev/actions/runs/39850807214).

Development binary pairs:
[1](https://github.com/astral-sh/uv-dev/actions/runs/39845559347),
[2](https://github.com/astral-sh/uv-dev/actions/runs/39845565304),
[3](https://github.com/astral-sh/uv-dev/actions/runs/39845570772),
[4](https://github.com/astral-sh/uv-dev/actions/runs/39845812706),
[5](https://github.com/astral-sh/uv-dev/actions/runs/39845981670),
[6](https://github.com/astral-sh/uv-dev/actions/runs/39845987308),
[7](https://github.com/astral-sh/uv-dev/actions/runs/39846074229),
[8](https://github.com/astral-sh/uv-dev/actions/runs/39846238545),
[9](https://github.com/astral-sh/uv-dev/actions/runs/39846241952),
[10](https://github.com/astral-sh/uv-dev/actions/runs/39846245499),
[11](https://github.com/astral-sh/uv-dev/actions/runs/39846412362),
[12](https://github.com/astral-sh/uv-dev/actions/runs/39846417727),
[13](https://github.com/astral-sh/uv-dev/actions/runs/39846423157),
[14](https://github.com/astral-sh/uv-dev/actions/runs/39846596231),
[15](https://github.com/astral-sh/uv-dev/actions/runs/39846602048),
[16](https://github.com/astral-sh/uv-dev/actions/runs/39846607338),
[17](https://github.com/astral-sh/uv-dev/actions/runs/39846771601),
[18](https://github.com/astral-sh/uv-dev/actions/runs/39846775882),
[19](https://github.com/astral-sh/uv-dev/actions/runs/39846863070),
[20](https://github.com/astral-sh/uv-dev/actions/runs/39846953535).

</details>

---------

Co-authored-by: zaniebot <242828183+zaniebot@users.noreply.github.com>
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