-
Notifications
You must be signed in to change notification settings - Fork 7.8k
.github/workflows/push.yml: enable ccache #10395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8c01d4e
to
3915f92
Compare
.github/workflows/push.yml
Outdated
- name: ccache | ||
uses: hendrikmuhs/ccache-action@v1.2 | ||
with: | ||
key: ${{github.job}}-${{matrix.debug}}-${{matrix.zts}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can a job name be used here? if not, you can use https://docs.github.com/en/actions/learn-github-actions/expressions#tojson on whole matrix
also the cache key should contain the minor PHP version/branch, you can use hash of https://github.com/php/php-src/blob/master/main/php_version.h file - https://docs.github.com/en/actions/learn-github-actions/expressions#hashfiles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do! (This evening or so.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should contain the branch name? This is targetting master but it would make sense to backport. In that case the cache key should be different to avoid invalidating the cache of other branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2x yes - master will be branch cutted someday and PHP-8.1/8.2 CI will benefit from this PR as well
this is a nice addition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thought about this just yesterday 🙂
Can we add the same for the nightly builds?
I would prefer non-cached build in nightly. A few more minutes in nightly are not critical and it represents a standard/clean build. |
@mvorisek Also burns lots of CI time, given how many jobs there are. If we have problems we can always remove it. Sadly, barely anybody looks at nightly anyway. And tests are so flaky there are few days when I don't wake up with an e-mail. |
This is why I am also a little concerned about introducing caching in CI: It is another possible failure mode. Is the build step sufficiently stable that caching won't introduce another failure mode, because some file wasn't rebuilt despite some dependency changing? |
Using ccache locally, I've never had caching issues due to it. The only time I need to do a full rebuild is if autoconf stuff changes, but I still never have to manually clear ccache. IMO this is certainly worth a try. If we encounter issues we can always revert it. |
It looks like Travis already uses ccache. While not being exactly the most stable, cache never seemed to be the cause for that. |
Agree with @iluuu1994 - I've been using ccache for many years, and it was never the cause of a problem. It's very mature and saved me so much lifetime. Now if we could only speed up all those unit tests... the C compiler is only a small part of the CI run. |
Implemented two suggestions by @mvorisek:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hashFiles('main/php_version.h')
is a nice approach, thanks! Would you like to add nightly here or in a separate PR? I'm happy either way. Could you rebase this onto PHP-8.1?
True, but since it wasn't used for the job name, I didn't use it here either. |
# This duplicates the "job.name" expression above because | ||
# GitHub has no way to query the job name (github.job is the | ||
# job id, not the job name) | ||
key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}-${{hashFiles('main/php_version.h')}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# This duplicates the "job.name" expression above because | |
# GitHub has no way to query the job name (github.job is the | |
# job id, not the job name) | |
key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}-${{hashFiles('main/php_version.h')}}" | |
key: "${{ github.workflow }}-${{ github.job }}-${{ toJSON(matrix) }}-${{ hashFiles('main/php_version.h') }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's better because it doesn't duplicate the expression, but it's worse because a hash is more obscure. I don't have a real opinion on what to choose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no hash added and json is quite readable :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's JSON, not hash of a JSON ... yes, that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't work:
Error: Restoring cache failed: ValidationError: Key Validation Error: ccache-Push-LINUX_X64-{
"debug": true,
"zts": false
}-10c280ee69e81a8f532bab2756a061cccc70829ec83708c23eb95d1f14f49c53- cannot contain commas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hash of JSON would solve that, but no hash function exists :( :) What about moving the ccache step into separate file and calculating the cache key there using bash?
see https://github.com/atk4/core/blob/develop/.github/workflows/test-unit.yml l37 and l42 for how data can be passed between steps, ie. from bash step to GH action step
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's worth the complexity.
Any idea where the compiler spents the rest of the time and if something can be further cached or improved? |
I/O and the linker. The linker output can't be cached. Switching to mold will give a big performance boost here. mold however isn't available in Ubuntu 20.04; 22.04 contains an old version of mold. |
I'd be ok with switching to |
This reduces the LINUX_X64_RELEASE_ZTS build time from 9-10 minutes to less than 3 minutes.
Agree. I'll submit a PR to upgrade |
@MaxKellermann Let's merge this like this, Ubuntu/mold can be done in a separate PR. You don't have to rebase, I'll do that when I merge this. |
New PR, I meant exactly that. |
Thanks again! And sorry for the delay. |
in the CI there are warnings like: https://github.com/php/php-src/actions/runs/4077782444/jobs/7027216607#step:8:9
|
This has nothing to do with ccache; maybe this is just now more likely to happen now that the compiler is faster. Less percentage of the time spent in the compiler, more spent in administrative stuff like making directories, and now conflicts are more likely to happen.
Build of As I said, |
This seems to use too much cache storage. https://github.com/php/php-src/actions/caches
It seems like we need to set We also seem to have some caching issues, e.g. here. |
btw. here's a fix that finally allows using |
This reduces the LINUX_X64_RELEASE_ZTS build time from 9-10 minutes to less than 3 minutes.