GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — CI: Cache config.cache across runs to speed up build by hugovk · Pull Request #104800 · python/cpython Conversation
|
| Job | Without cache | With cache | Times faster | Seconds saved |
|---|---|---|---|---|
| check_generated_files | 22 | 4 | 5.5 | 18 |
| build_macos | 96 | 17 | 5.6 | 79 |
| build_ubuntu | 23 | 4 | 5.8 | 19 |
| build_ubuntu_ssltests (1.1.1t) | 24 | 4 | 6.0 | 20 |
| build_ubuntu_ssltests (3.0.8) | 25 | 8 | 3.1 | 17 |
| build_ubuntu_ssltests (3.0.8) | 25 | 7 | 3.6 | 18 |
| test_hypothesis | 24 | 4 | 6.0 | 20 |
| build_asan | 29 | 5 | 5.8 | 24 |
| Total: | 268 | 53 | 5.1 | 215 |
| link | link |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
where is the cache file stored? is it using per-repo or per-org storage? I'm not familiar with config.cache - are the configure and configure.ac files the only relevant inputs? I also tried thinking about cross-branch and cross-PR interactions, but since the key uses the hash of the input files then if the hashes are identical across branches and PRs then it should be ok to reuse the cached file. one concern is implicit inputs that are not captured by the current key:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
https://github.com/actions/cache does it per-org, so it won't be shared with forks. Forks will have their own copies.
Let's ask @erlend-aasland :)
I ran this PR twice: once with no cache, and second time with cache present.
Could you give an example?
I think the action will invalidate the cache itself if they change something, but I couldn't find anything to confirm. I also don't think the action's version is exposed, anyway. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Also, environment variables:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@arhadthedev provided examples :) the result can also be affected by the exact OS version (I don't know how granular regarding the implementation - hashFiles can operate on multiple files, so use |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
👍
https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context I added the workflow file to hashFiles, so it will invalidate and make a new cache when things defined in the file change, for example the env vars and CLI flags. There's a
Possibly but I'm not sure if it's worth the complexity: we can just have hashFiles computed each time. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
LG!
this will be over-conservative, invalidating for any change in the workflow file, even if it doesn't affect the result (which is probably most changes). probably a fair trade off (preferring correctness over CI latency).
agreed. I'd suggest at least refactoring the list of files to be a shared constant. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. With the workflow file in the cache key, we're pretty safe regarding any environment change.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I guess we want this CI speedup in the other branches as well. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Do you know how to do this? I tried a few things, but didn't get it working. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I think workflow-level environment variable can work for this https://docs.github.com/en/actions/learn-github-actions/variables |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I tried that like: env: CONFIG_CACHE_HASH_FILES: ${{ hashFiles('configure', 'configure.ac', '.github/workflows/build.yml') }} and: key: ${{ github.job }}-${{ runner.os }}-${{ env.CONFIG_CACHE_HASH_FILES }} But it said "The workflow is not valid ", "Unrecognized function: 'hashFiles'" I also tried: env: CONFIG_CACHE_HASH_FILES: ('configure', 'configure.ac', '.github/workflows/build.yml') and: key: ${{ github.job }}-${{ runner.os }}-${{ hashFiles(env.CONFIG_CACHE_HASH_FILES) }} But it couldn't read the env var: Let me try again with https://github.com/orgs/community/discussions/25761#discussioncomment-4626908 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hmm, no luck, because it formats into strings, and we need a sort of tuple of strings. We might be able to do something like: env: CONFIG_CACHE_HASH_FILE1: 'configure' CONFIG_CACHE_HASH_FILE2: 'configure.ac' CONFIG_CACHE_HASH_FILE3: '.github/workflows/build.yml' And then format it something like this: key: ${{ github.job }}-${{ runner.os }}-${{ hashFiles(format('{0}', env.CONFIG_CACHE_HASH_FILE1))-${{ hashFiles(format('{0}', env.CONFIG_CACHE_HASH_FILE2))-${{ format('{0}', env.CONFIG_CACHE_HASH_FILE3)) }} But it feels like a backward refactor... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
yeah, I agree, this doesn't improve anything. let's leave it as explicit lists of files, I might give it another try separately after this merges. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Backport through all security branches? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry @hugovk, I had trouble checking out the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…-104800) (cherry picked from commit 1080c43) Co-authored-by: Hugo van Kemenade <[email protected]>
|
GH-104967 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-104968 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…-104800).\n(cherry picked from commit 1080c43)\n\n\nCo-authored-by: Hugo van Kemenade <[email protected]>
|
Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, @hugovk, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry @hugovk, I had trouble checking out the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, @hugovk, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry @hugovk, I had trouble checking out the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Actually, maybe we should skip the security branches? They've already diverged quite a bit, and don't get built (or backported) as often, so there's less benefit. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yeah, makes sense. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… (#104968) Co-authored-by: Hugo van Kemenade <[email protected]>
I think it worked out nicely in gh-105008 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.