Skip to content

Allow sharing the Go cache directory for crossbuilds#178

Open
simonpasquier wants to merge 7 commits into
prometheus:masterfrom
simonpasquier:enable-go-cache-sharing
Open

Allow sharing the Go cache directory for crossbuilds#178
simonpasquier wants to merge 7 commits into
prometheus:masterfrom
simonpasquier:enable-go-cache-sharing

Conversation

@simonpasquier

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@sylr

sylr commented Feb 14, 2020

Copy link
Copy Markdown
Contributor

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

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@simonpasquier

Copy link
Copy Markdown
Member Author

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

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@simonpasquier

Copy link
Copy Markdown
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

sylr commented Feb 14, 2020

Copy link
Copy Markdown
Contributor

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

Comment thread .circleci/config.yml
build:
executor: golang
machine:
image: ubuntu-1604:201903-01

Copy link
Copy Markdown
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
Copy Markdown
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

sylr commented Feb 15, 2020

Copy link
Copy Markdown
Contributor

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

Comment thread .circleci/config.yml
- restore_cache:
keys:
- v01-gocache-{{ checksum "go.mod" }}
- v01-gocache-

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

sylr commented Feb 17, 2020

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member Author

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

@SuperQ

SuperQ commented Aug 25, 2020

Copy link
Copy Markdown
Member

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

@SuperQ

SuperQ commented Mar 14, 2021

Copy link
Copy Markdown
Member

Ping, should we finish this up?

@SuperQ

SuperQ commented May 31, 2023

Copy link
Copy Markdown
Member

Ping @simonpasquier, can you rebase this?

@SuperQ SuperQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs a rebase

@kakkoyun kakkoyun left a comment

Copy link
Copy Markdown
Member

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.

Comment thread .circleci/config.yml
build:
executor: golang
machine:
image: ubuntu-1604:201903-01

Copy link
Copy Markdown
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