Skip to content

Key the system-image cache on the image revision - #26

Merged
jpcottin merged 1 commit into
mainfrom
ci/revision-keyed-cache
Jul 26, 2026
Merged

Key the system-image cache on the image revision#26
jpcottin merged 1 commit into
mainfrom
ci/revision-keyed-cache

Conversation

@jpcottin

Copy link
Copy Markdown
Owner

Replaces the weekly rotation from #25 with revision-based keying.

Why: weekly rotation bounded staleness but left a window. Within a week the exact key already exists, actions/cache does not re-save on a hit, so a newly published image revision would be re-downloaded by sdkmanager on every run until the week rolled over. That is exactly the scenario you raised — a new image appearing tomorrow.

How: split restore and save so the entry can be keyed on the revision that actually ended up on disk, which is only knowable after sdkmanager has run.

restore   prefix match -> whatever copy exists
install   sdkmanager brings it up to date; read Pkg.Revision
save      key: ...-rev<N>, only if the restored entry was not already rev<N>

A new revision enters the cache on the first run that sees it; a steady state writes nothing.

Correctness was never at risk either way — sdkmanager always installs the newest revision, so CI has never tested a stale image. This is purely about not paying for the same download repeatedly.

Current revision is 6, so the first run should restore via the prefix (matching an existing entry, no 4.4 GB download) and save sysimg-v1-android-37.0-google_apis_ps16k-x86_64-rev6. Watch for SYSIMG-CACHE restored-from= and SYSIMG-REVISION in the job log.

Weekly rotation bounded how long a stale entry could linger, but it still
left a window: within a week the exact key already exists, actions/cache
does not re-save on a hit, so a newly published image revision would be
re-downloaded by sdkmanager on every run until the week rolled over.

Split restore and save so the entry can be keyed on the revision that
actually ended up on disk, which is only knowable after sdkmanager has run.
Restore takes whatever copy exists via the key prefix, sdkmanager brings it
up to date, and save writes it back under rev<N> -- guarded so it only
writes when the restored entry was not already that revision. A new revision
therefore enters the cache on the first run that sees it, and a steady state
costs nothing.

Correctness was never at risk either way: sdkmanager always installs the
newest revision, so CI has never tested a stale image. This is purely about
not paying for the same download repeatedly.
@jpcottin
jpcottin merged commit 80fa251 into main Jul 26, 2026
13 checks passed
@jpcottin
jpcottin deleted the ci/revision-keyed-cache branch July 26, 2026 23:30
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.

1 participant