Let only main write the Gradle cache - #32
Merged
Merged
Conversation
Measured on run 32030544289: the Plugin Verifier job spent 1m44s and the test job 32s in `Post Setup Gradle` — i.e. uploading cache — on top of both runs starting cold. The cause was the cache-read-only condition, which excluded forks only, so every same-repo pull request wrote its own copy of the Gradle home. That put the repository at 24GB across 60 entries against GitHub's ~10GB per-repo budget (refs/heads/main=14, refs/pull/28=18, refs/pull/29=17), so entries were LRU-evicted before they could be reused. Runs therefore paid twice: cold restores plus ~2min/run of pointless uploading. Pull requests are now read-only and only pushes to main write, which is the documented setup-gradle pattern. PRs can still restore the default branch's cache, and main already holds a full set of entries. It is also strictly safer, since same-repo PRs can no longer poison the shared cache. Also correct a comment added in #29 claiming the extracted IDEs are not cached and would need a cache action of their own. They are: setup-gradle covers both the installers under caches/modules-2 and the extracted trees (there is a `gradle-transforms-v1` entry, ~1.4GB). Pinning verification to a single IDE is what bounds the size, not any absence of caching.
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.
Summary
Follow-up to #29, found by measuring the slow CI run you flagged (run
32030544289):Verify plugin(3 IDEs, pre-#29)Post Setup Gradle— uploading cacheTest(cold cache)Post Setup Gradle#29 fixed the verifier side (one pinned IDE). This fixes the other half, which is systemic.
The cause
cache-read-onlywaspull_request && head.repo != base repo— i.e. it excluded forks only, so every same-repo PR wrote its own copy of the Gradle home. Measured state:Over budget means LRU eviction, so entries were thrown away before they could ever be reused. Every run therefore paid twice: a cold restore and ~2 min of pointless uploading.
The change
PRs are read-only; only pushes to
mainwrite. This is the documentedsetup-gradlepattern,mainalready holds a full set of entries, and PRs can still restore the default branch's cache. It's also strictly safer — same-repo PRs can no longer poison the shared cache.Also corrects a comment I added in #29 claiming the extracted IDEs aren't cached and would need their own cache action. They are —
setup-gradlecovers both the installers incaches/modules-2and the extracted trees (there's agradle-transforms-v1entry, ~1.4 GB). Pinning verification to one IDE is what bounds the size, not any absence of caching. The reasoning in #29's commit message was wrong on that point even though its conclusion (don't add a second cache action) happened to be right.Test plan
setup-gradlesteps now resolve tocache-read-only: ${{ github.event_name == 'pull_request' }}; no stale fork condition remains.Post Setup Gradleshould be short (no save) instead of 1m44s/32s.mainpush reseeds the cache; the run after that should show a warm restore and a materially fasterTeststep than the 6m13s baseline.Note the stale
refs/pull/*cache entries should be pruned so the next run isn't competing with them for the budget — GitHub reclaims them when PRs close, but not promptly.