promu icon indicating copy to clipboard operation
promu copied to clipboard

Allow sharing the Go cache directory for crossbuilds

Open simonpasquier opened this issue 4 years ago • 11 comments

simonpasquier avatar Feb 14 '20 13:02 simonpasquier

@simonpasquier I am massively rewriting cmd/crossbuild.go in #177

sylr avatar Feb 14 '20 14:02 sylr

@sylr yes I know but I'm not sure it's the right direction...

simonpasquier avatar Feb 14 '20 14:02 simonpasquier

I've managed to make it work (though a few things need to be cleaned up). The build job with a prefilled buildcache goes down from 13m40s to 1m28s. One concern is that the build cache's size for this repository (which isn't too big) is approximately 390MB while Circle CI recommends keeping it under 500MB.

simonpasquier avatar Feb 14 '20 16:02 simonpasquier

When does the build cache prove effective ? if "our" go sources are modified from one commit to another will it still improve things ?

sylr avatar Feb 14 '20 18:02 sylr

@simonpasquier As I rewrote crossbuild entirely to not use docker anymore in #177 (I created a crossbuild-docker command) would you mind to only commit the tweak you made in the .circleci/conf.yml to save the GOCACHE dir ?

sylr avatar Feb 15 '20 17:02 sylr

@sylr

When does the build cache prove effective ? if "our" go sources are modified from one commit to another will it still improve things ?

Obviously it would need to be tested on Circle CI but this is what I get with my local machine when crossbuilding different versions of github.com/prometheus/prometheus.

# crossbuild the release-2.15 branch without cache.

real    23m53.257s
user    0m3.456s
sys     0m7.881s

# crossbuild the master branch with the cache directory from the previous step.

real    14m23.807s
user    0m6.726s
sys     0m13.227s

# crossbuild the master branch with the cache directory from the previous step.

real    11m38.822s
user    0m6.661s
sys     0m13.647s

So the difference between a fresh cache and an outdated cache isn't huge. Note that it assumes that go.mod hasn't changed between master and release-2.15 which isn't true. We can also have a per-project context variable keeping the cache's version number and bump it to force a refresh of the cached data.

simonpasquier avatar Feb 17 '20 16:02 simonpasquier

OK, thank you for this.

I also did some tests on my side and running crossbuild on prometheus on my mac generated 6GB of data in the cache dir, do you roughtly have the same number ?

sylr avatar Feb 17 '20 16:02 sylr

I've reached 8.5GB of build cache after the runs I've described.

simonpasquier avatar Feb 17 '20 16:02 simonpasquier

How's this going? It's approved, but there's a lot of un-resolved threads.

SuperQ avatar Aug 25 '20 16:08 SuperQ

Ping, should we finish this up?

SuperQ avatar Mar 14 '21 14:03 SuperQ

Ping @simonpasquier, can you rebase this?

SuperQ avatar May 31 '23 07:05 SuperQ