-
Notifications
You must be signed in to change notification settings - Fork 570
Fix: Don't bust cache so aggressively when compiling test sources #1110
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
Conversation
@@ -464,7 +464,6 @@ func NewSession(options *Options) (*Session, error) { | |||
GOPATH: options.GOPATH, | |||
BuildTags: options.BuildTags, | |||
Minify: options.Minify, | |||
TestedPackage: options.TestedPackage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that's not clear to me is if we should share a cache between gopherjs test
and gopherjs build
.
For example, let's say foo
depends on shared
, and you run gopherjs test foo/...
. This will create a cache for shared
. If you run a subsequent gopherjs build
, is it okay to reuse the cache for shared
?
I expect this would be fine as long as the rest of the BuildCache
args are the same.
99dddcb
to
35df1d2
Compare
Thanks for sending this PR. I agree that the current cache busting is more conservative than it has to be, although in this case it's better to be slow than produce invalid results. The fix looks good overall, but I'll need a bit of time to think all implications through. |
👍 Sounds great, thank you! I definitely agree it's better to be slow and correct than fast and incorrect. I'm definitely not an expert on the go/gopherjs build system by any means -- I appreciate the consideration. |
Unfortunately I found a case where this change would lead to incorrect results 😟 Consider package In practical terms this means that the I do have a long-term goal of making the build process consider build graph more explicitly (which would unlock smarter build caching strategies among other things), but there are quite a few steps to get there. #693 (comment) is the first of them, so I'll take this opportunity to advertise https://github.com/nevkontakte/gopherjs/tree/syscall2 branch and encourage early testing 🙃 |
🤯 that's a good catch. That answers my uncertainty here In addition to this change, would it make sense to also add an (That said, I don't want to propose a change if you're just going to take things in a completely different direction and it's going to create more work for you that you'll just have to rip out. Perhaps my solution is just patching holes and opening us up to other issues rather than fixing the core problem) I'll definitely check out your syscall2 branch tomorrow (we use darwin locally, so I'm excited to drop |
Unfortunately, a boolean And so we do really have to partition build cache by That said, I'm really surprised that the compilation itself increases your CI time by whole 10 minutes. In my experience test execution dominates build time by a good margin. Is your code base open source by any chance? It could be a good material to profile the compiler against and maybe find the root cause of the slowness. |
👍 Gotchya, that makes sense 😞 I don't think we have the resources to contribute in a big way right now, but I can bring it up. I'm certainly interested in the health of gopherjs. Unfortunately, our code base is not open source. We have a pretty large codebase (about 250k lines of production and test code each, not counting dependencies). If you think it would help, I can look into scrubbing "sensitive" output from the info logs during a run of FWIW, we do run the gopherjs tests in parallel with the rest of our build/tests, and this is not the bottleneck in our total CI time. I was just hoping this was a relatively easy fix, but clearly it's not 😆 |
Thanks for the offer, info logs gopherjs currently produces are not very helpful for performance analysis. The best option would be to capture a pprof CPU profile of the gopherjs tool. I thought I added a flag for that but apparently I didn't ¯_(ツ)_/¯ I guess we could park it until I have more time to look at performance and I might request your assistance then 🙂 As for this pull request, I think it is clear that it can't be merged without compromising output correctness, so I am going to close it. I do appreciate the effort and we will be happy to accept future contributions, big or small! |
👍 Sounds great, I appreciate the guidance on this. |
When using latest gopherjs master, we noticed that the time to run
gopherjs test
in CI for our package increased from ~3m13s (on 1.17.1+go1.17.3) to ~14m36s - This appears to have started occurring after #1105After turning on info level logs, we noticed that we were consistently getting cache misses for packages that were shared.
Example:
Further investigation showed that the build cache generates a cache key based on the package being tested.
This means that if 2 packages share a dependency, they will not share the cache for that dependency.
I updated the cache key to:
*_test.go
sources are compiled into that cache.By doing this, our
gopherjs test
CI time is back down to ~3m11s