Skip to content

ci: add rust-cache action - #526

Merged
Firestar99 merged 4 commits into
mainfrom
ci-rust-cache
Aug 12, 2026
Merged

ci: add rust-cache action#526
Firestar99 merged 4 commits into
mainfrom
ci-rust-cache

Conversation

@Firestar99

@Firestar99Firestar99 commented Feb 10, 2026

Copy link
Copy Markdown
Member

Requires #530

  • implement rust-cache in our CI
  • "base" cache
    • "test" job creates the cache
    • "compiletest" and "difftest" just use the cache
    • "test" warms the cache for "compiletests" and "difftests", saves ~2min each
  • "android" cache, only for the android action since it compiles for an arm target
  • lint get's no cache, while speedup is significant (6m -> 1m), not worth the cache space cost
  • github has a cache usage limit of 10GB, this is using ~4GB per branch
  • thus, caches are only created on main, but can be reused on branches based on main

(slightly outdated table, should still be accurate enough)

jobwindowsmaclinuxtotal
test620 MB580 MB730 MB1930 MB
difftest230 MB240 MB240 MB710 MB
android460 MB460 MB
vulkan-sdk290 MB460 MB750 MB
total1140 MB820 MB1890 MB3850 MB

Final Results

jobwindowsmaclinux
test own cache9m 26s11m 54s4m 59s
test test cache10m 31s6m 17s5m 37s
test test clean27m 48s*20m 25s15m 15s
test main18m 10s15m 41s11m 28s
compiletest own cache14m 17s7m 43s6m 12s
compiletest test cache14m 40s8m 42s6m 21s
compiletest test clean16m 38s*11m 45s8m 32s
compiletest main19m 32s14m 42s8m 3s
difftest own cache15m 15s10m 29s8m 22s
difftest test cache15m 13s9m 13s7m 44s
difftest test clean23m 43s15m 40s11m 51s
difftest main26m 30s15m 0s14m 30s
lint own cache1m 42s
lint test cache5m 21s
lint test clean6m 14s
lint main5m 58s

End to end:

  • own cache: 15m 41s
  • test cache: 15m 24s
  • test clean: 27m 59s*
  • test main: 26m 41s

*adjusted due to flakyness of rustup install, usually takes only 40s on windows

Analysis

  1. Speedup with a good cache, before ci: free speedups #530? negative = speedup, "main" - "test cache"
jobwindowsmaclinux
test-8m 45s-4m-6m 30s
compiletest-5m-7m-2m
difftest-11m 15s-4m 30s-6m

End to end: -11m 20s

  1. Overhead of a clean build without caches? positive = slowdown, "test clean" - "main"

Note: this includes #530

jobwindowsmaclinux
test+9m 45s+5m+4m
compiletest-3m-3m-30s
difftest-3m-40s-2m 30s

End to end: +1m 20s*

  1. How much faster would individual caches vs current shared "test" cache be? negative = speedup, "test cache" - "own cache"

Note: This is unfair as "own cache" data does not include #530. Expect difftest to be worse and test to be better than a retest with that PR.

jobwindowsmaclinux
test-1mflaky-40s
compiletest-20s-1m9s
difftest+2s+1m 10s+40s

End to end: +20s

My investigation log

Feel free to ignore and just look at the results

Adding caching

First run (with no cache present) is looking real bad:

  • windows test +1m 8s
  • windows difftest +6m 24s
    • no idea why the cache would take so long when there's nothing to download and nothing has been compiled???
  • all "install rust toolchain" are now 0s, so we probably have to move them before the cache action

First CI with restore

Comparing latest main to this PR:

  • overall time: 27m 39s -> 16m 8s
  • longest job "windows-difftest": 27m 29s -> 16m 0s
  • cache restore, measured from seconded empty commit in this PR, which may have been removed:
    • windows: 58s to 2m 3s
      • first run of windows difftest has an obscene "restore" of 6m 24s even though there's nothing to restore???
    • linux: ~30s
    • mac: 30s - 40s
  • cache creation, measured from first commit in this PR:
    • windows: 30s - 1m
    • linux: 8s - 15s
    • mac: 30s - 50s

Install toolchain before restore (run attempt #1)

  • rust-cache seems to install the toolchain for you via rustup if you don't do it yourself, toolchain install has 0s execution time
  • Action: move it before cache restore
  • Results: old rust-cache time is now split between rustup install and new rust-cache
  • Could caches contain rustup builds? Try purging caches

purging caches and retrying CI (run attempt #2)

  • as expected, a lot of runtime is moved from "rust-cache" to "install toolchain"
  • rust-cache restore times:
    • windows: 2-3s
    • mac: 1-2s
    • linux: 1-2s
    • => couldn't repo crazy CI times from first attempt, just a fluke?
  • cache creation:
    • windows: 30-50s
    • mac: 30-40s, 60s fluke?
    • linux: ~10s
  • Results: rustup before rust-cache to separate out toolchain install time

Lessen cache usage

jobwindowsmaclinuxtotal
test620 MB590 MB740 MB1950 MB
compiletest310 MB300 MB320 MB930 MB
difftest550 MB550 MB560 MB1660 MB
lint720 MB720 MB
android460 MB460 MB
vulkan-sdk290 MB500 MB460 MB1250 MB
total1770 MB1940 MB3260 MB6970 MB

remove rustup env vars

  • cache usage (limit of 10GB):
jobwindowsmaclinuxtotal
test620 MB580 MB730 MB1930 MB
difftest230 MB240 MB240 MB710 MB
android460 MB460 MB
vulkan-sdk290 MB500 MB460 MB1250 MB
total1140 MB1320 MB1890 MB4350 MB
jobwindowsmaclinux
compiletest own cache14m 17s7m 43s6m 12s
compiletest test cache16m 4s7m 28s6m 21s
compiletest main19m 32s14m 42s8m 3s
difftest own cache15m 15s10m 29s8m 22s
difftest test cache21m 18s16m 11s11m 8s
difftest main26m 30s15m 0s14m 30s
lint own cache1m 42s
lint test cache6m 1s
lint main5m 58s
  • Analysis of difftest slowdown:
    • windows & mac +6min:
      • +3min from "test difftest" aka. cargo test -p difftest
      • +3min from "difftest" themselves
    • linux follows similar pattern but less worse

move "test difftest" to test job

  • Idea: On main windows difftest:
    • test difftest: 7m 29s
    • difftest: 14m 44s
    • move work from the longest running task difftest to test
    • maybe also improve rust-cache reuse, and speed up difftest some more?
  • Results (incremental only)
    • difftest-windows: from 21m 18s to 16m 44s
    • test-windows: 9m 46s to 9m 13s, should have increased, likely just run to run variance
    • caching was useless, almost nothing is shared between "test difftest" and "difftest"
    • free -5min win 🎉

ci: make "test" prep better cache for compiletests and difftests

didn't work, try again

ci: fix prep cache being useless due to weird feature selection

  • Idea: both compiletest and difftest spent 1-2min compiling the test runners, cache that
  • see final results below

@nazar-pc

Copy link
Copy Markdown
Contributor

In my projects I usually disable caching on Windows. Their gzip or whatever compression they use is so spectacularly slow that it is faster to download/install things from scratch than decompressing/recompressing cache.

@LegNeato

Copy link
Copy Markdown
Collaborator

I feel like we had this somewhere (rust-cuda?) and had to remove it

@Firestar99

Firestar99 commented Feb 16, 2026

Copy link
Copy Markdown
MemberAuthor

Well, you've actively using it in rust-cuda, even if for windows only... Otherwise I can't find any mention of it, neither in issues, PRs or history of those files

@Firestar99

Copy link
Copy Markdown
MemberAuthor

Just rebased it and it started failing, no idea why. The diff to main is just the cache actions, and they're not caching anything since no cache is available, and uploading only happens on main.

@Firestar99
Firestar99 added this pull request to the merge queueAug 12, 2026
Merged via the queue into main with commit eb73c07Aug 12, 2026
23 checks passed
@Firestar99
Firestar99 deleted the ci-rust-cache branch August 12, 2026 09:38
Sign up for freeto 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.

4 participants

@Firestar99@nazar-pc@LegNeato@eddyb