Skip to content
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

Allow sharing the Go cache directory for crossbuilds #178

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

simonpasquier
Copy link
Member

No description provided.

@sylr
Copy link
Contributor

sylr commented Feb 14, 2020

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

Signed-off-by: Simon Pasquier <[email protected]>
@simonpasquier
Copy link
Member Author

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

Signed-off-by: Simon Pasquier <[email protected]>
Signed-off-by: Simon Pasquier <[email protected]>
Signed-off-by: Simon Pasquier <[email protected]>
@simonpasquier
Copy link
Member Author

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 simonpasquier marked this pull request as ready for review February 14, 2020 16:08
@sylr
Copy link
Contributor

sylr commented Feb 14, 2020

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

@@ -23,14 +23,24 @@ jobs:
- run: git diff --exit-code

build:
executor: golang
machine:
image: ubuntu-1604:201903-01
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we use 1804?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not listed in the docs.

@sylr
Copy link
Contributor

sylr commented Feb 15, 2020

@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 ?

- restore_cache:
keys:
- v01-gocache-{{ checksum "go.mod" }}
- v01-gocache-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the v01-gocache- key ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's for testing

@simonpasquier
Copy link
Member Author

@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.

@sylr
Copy link
Contributor

sylr commented Feb 17, 2020

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 ?

@simonpasquier
Copy link
Member Author

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

@SuperQ
Copy link
Member

SuperQ commented Aug 25, 2020

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

@SuperQ
Copy link
Member

SuperQ commented Mar 14, 2021

Ping, should we finish this up?

@SuperQ
Copy link
Member

SuperQ commented May 31, 2023

Ping @simonpasquier, can you rebase this?

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a rebase

Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can revive and merge this @simonpasquier.

LGTM.

@@ -23,14 +23,24 @@ jobs:
- run: git diff --exit-code

build:
executor: golang
machine:
image: ubuntu-1604:201903-01
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
image: ubuntu-1604:201903-01
image: ubuntu-2204:2024.04.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants