Skip to content

fix: key melange cache by cargo profile - #68

Merged
falcorocks merged 1 commit into
ethereum-optimism:mainfrom
geoknee:geoknee/melange-cache-key-profile
Oct 9, 2026
Merged

falcorocks merged 1 commit into
ethereum-optimism:mainfrom
geoknee:geoknee/melange-cache-key-profile

Conversation

@geoknee

@geoknee geoknee commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Problem

melange-build.yaml keys the GHA cache on melange-v2-<stack>-<arch>-<lockfile hash>. The cargo profile isn't part of the key. In optimism, the op-stack-rust leg builds maxperf on develop/tags (the only runs that save) and fast-build on PRs (restore-only). So every internal PR restores the multi-GB maxperf cache as an exact hit (cache-hit=true) and then reuses nothing:

run profile cache crates compiled
develop 37809128424 (x86_64) maxperf hit, 3.5 GB 103
PR 37811171082 (x86_64) fast-build hit, same key 2002

Change

  • The cargo profile goes into the key and the restore-keys prefix: melange-v2-<stack>-<arch>-<profile>.<lockfile hash>. Callers with no profile get none.
  • The segment ends in . rather than -. . can't appear in a cargo profile name, so …-release. never prefix-matches …-release-perf.….

Effect / caveats

  • PRs stop downloading a cache they can't use (~1–1.5 min per leg).
  • This alone doesn't warm PR builds. No default-branch run in optimism builds fast-build today, so nothing writes a fast-build cache. That needs a consumer-side change: a default-branch leg that builds the PR profile. It's tracked separately because it costs runner time and Actions cache space (the repo already holds ~9 GB of melange cache).
  • The key shape changes, so each consumer gets one cold default-branch build after bumping its pin. Old melange-v2-* entries age out unused.

Testing

  • actionlint 1.7.12: clean.
  • Shell simulation of the key/prefix logic for maxperf, fast-build, release, release-perf and empty: distinct keys, no cross-profile prefix match.

🤖 Generated with Claude Code

The melange cache key hashed only the lockfiles, so caches saved by
default-branch maxperf builds were restored by fast-build PR builds as an
exact hit. Nothing in a maxperf target/ is reusable under fast-build, so
PRs paid the multi-GB restore and then recompiled every crate (2002 crates
on optimism's op-stack-rust leg).

Include the cargo profile in both the key and the restore-keys prefix,
terminated with '.' so one profile's prefix never matches another's.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@falcorocks
falcorocks merged commit ef84847 into ethereum-optimism:main Oct 9, 2026
1 check passed
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