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
Ways of caching for speeding up ephemeral CI/CD docker images? (Kotlin) #20449
Comments
Did you try Gradle GitHub action It should automatically cache cachable things between builds and it might solve your issue. Check README for details. |
I read that gradle-build-action@v2 uses |
I would still suggest trying with the I think slowness comes from the fact that Note that daemon is a process and as such, saving it to a file is not that easy. We would have to save all its state to a file for example. |
I have tried actions/cache and gradle-build-action and setup-java Every result is roughly 1min30sec Example of uses:
|
My analysis is still that it's the in-memory daemon that is the limiting factor. |
I also tried:
Setup java takes 0 sec :D and pipeline is still 1min30sec |
Sorry that you are seeing these issues, I could always be wrong here. I tried with a dummy Gradle project. I had a very basic setup:
and first-run took cca. 1m, while the second attempt was 22s. And Gradle part (starting daemon, running tests) of the second attempt was 13s. So from that I believe daemon start-up is not an issue. But I see that there might be some other issue in the play for your case (maybe compiling build logic/scripts takes long, or tasks are not cached?). But it's difficult to say what is an issue without a reproducer. Maybe it would be worth to ask also on the community Slack channel if anyone from the community that works with GitHub actions regularly would give a hint. |
Note that I noticed that tasks are not up-to-date since the project level cache is not reused. So to better cache tasks in between builds on CI, you would want to enable build cache like it's described here. But I am not sure if that solves anything for you. So for task caching in GitHub Actions you would need: |
Thanks for the pro guidance @asodja.
to Now my VM runs rebuild in 23 sec while CI/CD runs in 30 sec. But still 🤔 If I add a pointless Java class to my src files, on my VM it rebuilds in 35 sec, but in CI/CD it takes 1min21sec 🤔 I remember with some configuration I used to have, my "starting gradle daemon" step took like 50+ sec, but now I run |
If I remove the pointless class, then CI/CD is 30 sec run again and we have |
I believe that is an issue with the Kotlin compile task that doesn't support that case (yet). I think Kotlin plugin 1.6.20 has an experimental incremental compilation under the flag But note that this is still experimental as far as I know so I recommend you wait a stable release. |
Thank you for the incredibly insightful responses! Looking forward to Kotlin plugin 1.7.0 I can die happily now ❤️ |
In a persistant VM I can get my gradle build process down to 6-12 sec thanks to Gradle daemon already running.
In an ephemeral CI/CD Docker container (Github Actions) my build takes 1min29 sec due to Gradle daemon needing to start up.
Would it be possible to write a custom optional flag which would try to cache the Gradle daemon to a file, which could be passed as an artifact between the CI/CD pipeline runs?
The text was updated successfully, but these errors were encountered: