You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix performance issues when caching maven repository #204
There are huge performance issues with the caching mechanism of maven repositories
In the middle of the day, when building a maven artefact, to fetch the cache when my actions run can take from 2-3 minutes (!)
Then my maven build is done in 20-30 seconds...
After my build, then It takes approx one and a half minute before the cache is saved...
When the performance of the caching of the repository is so bad, it is better to run without caching (!). This is a serious setback in performance when developing and it is difficult to deliver code to our production environments in a quick manner.
Hi @jactor-rises, thanks for reporting this. Looking at our server-side telemetry for your repos, I'm not seeing any indication that calls to the cache server are slow. 95% of calls are completing in < 0.2 seconds. It's likely either (1) slowness downloading the cache content from storage, or (2) slowness processing the cache action on the runner.
There are a couple of things you can try:
Enable debug logging and see if you can determine where the time is spent. You can also post a sample log here, or e-mail the log to dhadka (at) github (dot) com, and we can take a look.
There is a known issue where the hashFiles function can take a long time if it's scanning a bunch of files. See Post actions/cache@v1 takes 4+ hours to complete #203, for example. Hopefully getting the debug logs will help determine if that's the cause.
Check the size of the cache. If the cache is large, the time spent downloading and extracting the contents can add up. The debug logs should show the file size + the time to untar. If the issue is the time spent extracting the file, there is work underway to help improve that (Use zstd instead of gzip #184).
Is the slowness you see occurring in all runs, or does it only occur periodically?
Make sure you're using the latest version of the cache action. Using uses: actions/cache@v1 will always point to the latest version. I'm seeing a (very) small number of calls using an older (slower) version.
if you can see our repos, then check all repos where the name starts with bidrag-
I will debug tomorrow and check out #203 (even though this issue is talking about "post action"-step)
Set up job 2s
Run actions/checkout@v2 1s
Run actions/[email protected] 4m 20s
Run mvn release:update-versions 8s
Run mvn help:evaluate -Dexpression=project.version -q -DforceStdout > .new-version 2s
Run navikt/bidrag-actions/[email protected] 3s
Post actions/[email protected] 0s
Post actions/checkout@v2 1s
Complete job
I constantly update versions, so the cache grows bigger and bigger
Interesting, I'm guessing Maven doesn't have a mechanism to clean up unused dependencies? I would recommend either:
Finding a way to clean up unused dependencies in ~/.m2/repositories.
Remove the restore-keys. Essentially, when you change a version, restore-keys lets you download an older copy of the cache, Maven updates with the new version(s), and a new cache is created with the old+new version. This may cause the cache to slow down when you change versions, since it needs to re-download all dependencies, but might be worth it to reduce the cache size.
It appears remove-project-artifact removes artifacts of the project which is currently built, so I assume your GitHub workflow builds with mvn install (or mvn deploy).
Out of curiosity, if that is indeed the case, is this really needed in your use-case, or would mvn verify already suffice?
So if using that plugin fixed your performance issue, I assume your workflow is running either mvn install or mvn deploy (which implies mvn install) and therefore keeps installing new versions of the artifacts to the local Maven repository.
Is that not the case?
yes it only discards old versions no longer stated in the pom. it only cashes the dependencies used in your pom so that the cache do not grow more than what is actually needed
it only cashes the dependencies used in your pom so that the cache do not grow more than what is actually needed
I am rather certain that this is not the case. It only removes older versions of the currently built project. This would match what the documentation says, how the code of the plugin looks and what it did when I ran it locally (it did not remove older versions of dependencies). You should be able to verify this by looking at the workflow log (the plugin describes there which packages it deleted).
Sorry for driving this issue off-topic, my intention was to point out that the Maven command (possibly mvn install?) used here might not be ideal and that using that plugin is not necessarily required. However, that turned into this rather long discussion.
...hmm... I have misread the documentation in that case... but it works for my purpose... it reduced the .m2-cached files from over 900 mb to amount 100 mb...
Activity
[-]Performance issues when caching maven repository[/-][+]Fix performance issues when caching maven repository[/+]dhadka commentedon Mar 4, 2020
Hi @jactor-rises, thanks for reporting this. Looking at our server-side telemetry for your repos, I'm not seeing any indication that calls to the cache server are slow. 95% of calls are completing in < 0.2 seconds. It's likely either (1) slowness downloading the cache content from storage, or (2) slowness processing the cache action on the runner.
There are a couple of things you can try:
Enable debug logging and see if you can determine where the time is spent. You can also post a sample log here, or e-mail the log to dhadka (at) github (dot) com, and we can take a look.
There is a known issue where the
hashFilesfunction can take a long time if it's scanning a bunch of files. See Post actions/cache@v1 takes 4+ hours to complete #203, for example. Hopefully getting the debug logs will help determine if that's the cause.Check the size of the cache. If the cache is large, the time spent downloading and extracting the contents can add up. The debug logs should show the file size + the time to untar. If the issue is the time spent extracting the file, there is work underway to help improve that (Use zstd instead of gzip #184).
Is the slowness you see occurring in all runs, or does it only occur periodically?
Make sure you're using the latest version of the cache action. Using
uses: actions/cache@v1will always point to the latest version. I'm seeing a (very) small number of calls using an older (slower) version.jactor-rises commentedon Mar 4, 2020
if you can see our repos, then check all repos where the name starts with
bidrag-I will debug tomorrow and check out #203 (even though this issue is talking about "post action"-step)
jactor-rises commentedon Mar 6, 2020
Some prints from a recent workflow:
from the log archive for the action
Is this due to the cache size? The performance are really unstable. Sometimes it takes about 30 sec... How can I reduce my cache?
jactor-rises commentedon Mar 10, 2020
my delay is caused by the cache size:
How to I remove stuff from the cache which is no longer needed? I constantly update versions, so the cache grows bigger and bigger...
dhadka commentedon Mar 10, 2020
Interesting, I'm guessing Maven doesn't have a mechanism to clean up unused dependencies? I would recommend either:
~/.m2/repositories.restore-keys. Essentially, when you change a version,restore-keyslets you download an older copy of the cache, Maven updates with the new version(s), and a new cache is created with the old+new version. This may cause the cache to slow down when you change versions, since it needs to re-download all dependencies, but might be worth it to reduce the cache size.jactor-rises commentedon Mar 12, 2020
testing if the following plugin will reduce the cache size:
jactor-rises commentedon Mar 12, 2020
great success!!!
Marcono1234 commentedon Jun 1, 2020
It appears
remove-project-artifactremoves artifacts of the project which is currently built, so I assume your GitHub workflow builds withmvn install(ormvn deploy).Out of curiosity, if that is indeed the case, is this really needed in your use-case, or would
mvn verifyalready suffice?jactor-rises commentedon Jun 2, 2020
the
build-helper.-maven-pluginremoves artefacts no longer used (older version than these used when building)from
apache.org:the purpose of
man verifyis to "verify" that your dependencies is doing what they are supposed to...Marcono1234 commentedon Jun 2, 2020
If I understood remove-project-artifact correctly, it only removes older artifacts of the project which is currently built, see also the source code of it.
So if using that plugin fixed your performance issue, I assume your workflow is running either
mvn installormvn deploy(which impliesmvn install) and therefore keeps installing new versions of the artifacts to the local Maven repository.Is that not the case?
jactor-rises commentedon Jun 3, 2020
yes it only discards old versions no longer stated in the pom. it only cashes the dependencies used in your pom so that the cache do not grow more than what is actually needed
Marcono1234 commentedon Jun 4, 2020
I am rather certain that this is not the case. It only removes older versions of the currently built project. This would match what the documentation says, how the code of the plugin looks and what it did when I ran it locally (it did not remove older versions of dependencies). You should be able to verify this by looking at the workflow log (the plugin describes there which packages it deleted).
Sorry for driving this issue off-topic, my intention was to point out that the Maven command (possibly
mvn install?) used here might not be ideal and that using that plugin is not necessarily required. However, that turned into this rather long discussion.jactor-rises commentedon Jun 5, 2020
...hmm... I have misread the documentation in that case... but it works for my purpose... it reduced the .m2-cached files from over 900 mb to amount 100 mb...