bazel-contrib / setup-bazel

GitHub Action to configure Bazel
MIT License
42 stars 7 forks source link

Cache is slow to save #36

Closed chrismgrayftsinc closed 1 month ago

chrismgrayftsinc commented 1 month ago

Recently a run of Post Setup bazel took around 4 minutes. I wonder if it could be related to actions/toolkit#1578

The workaround mentioned there is to call process.exit() after the caches are saved.

p0deje commented 1 month ago

@chrismgrayftsinc Can you try building a version with process.exit() and see if it helps in your case?

chrismgrayftsinc commented 1 month ago

I tried and it didn't make much of a difference.

2024-09-23_08-58

I don't really know what is happening in the 2 minutes between when "Successfully saved cache" is printed and the next step is started.

p0deje commented 1 month ago

@chrismgrayftsinc Do you have a public fork to see how you built setup-bazel?

chrismgrayftsinc commented 1 month ago

https://github.com/chrismgrayftsinc/setup-bazel/tree/exit-after-caches

chrismgrayftsinc commented 1 month ago

Oh whoops I forgot to run npm run build. I'll try again.

chrismgrayftsinc commented 1 month ago

Okay, that did make a huge difference.

2024-09-23_09-22

I'll create a pull request with the change.

michaelschuett-tomtom commented 1 month ago

I had seen this for about a month but never had time to look into it. Getting a version with this published would be awesome. My bazel build takes 5 minutes but the saving cache takes 4 and a half almost all of that is after seeing Successfully saved cache.

p0deje commented 1 month ago

@chrismgrayftsinc Thanks! I made a release 0.9.0 with this fix. Can you try it out?

michaelschuett-tomtom commented 1 month ago

@chrismgrayftsinc Thanks! I made a release 0.9.0 with this fix. Can you try it out?

Just verified on my builds. This is a huge improvement. reduced a lot of my lint github action run time by over 50%. Thank you!

michaelschuett-tomtom commented 1 month ago

Although just one thing to note I just see Post job cleanup. message now and not the other messages anymore. Not sure if it's somehow killing the process too early or this is expected.

chrismgrayftsinc commented 1 month ago

Hmm, I am seeing the other messages with my test version. I haven't tried the released version yet.