-
Notifications
You must be signed in to change notification settings - Fork 905
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
Don't rerun mockgen if it's already up-to-date #5620
Conversation
01b19de
to
d53dd74
Compare
I would guess that's the overhead of General comment: I'm fine with this for interactive use, but I would prefer if there was a way to make sure CI always did the full generation ignoring mod times. Mostly because I don't trust git to set mod times correctly in all cases. Could we do that with an environment variable or something that's set in CI but not interactive use? |
Great insight. I just made it use the prebuilt binary, and it now only takes 7 seconds instead of 22!
That should definitely be possible, and I agree that it's a good idea. I'll look into it. |
I set a new |
…al into snowden/cached-mockgen
## What changed and why? Revert most of the changes from #5620 since this doesn't properly detect stale files and we don't want to take the time to fix it at the moment.
What changed?
I added time-based caching to our mockgen invocations in go:generate directives. The tool gets bypassed in the CI.
Why?
I run
make ci-build-misc
a lot during development, and I noticed thatmake go-generate
is a huge bottleneck there, taking about 45s-1min for me. I tested our other generate directives like the rpcwrapper, but that one seems fast, it looks likemockgen
is the real culprit. I tried upgrading our dep to the latest version in the Uber fork to see if there was a quick win there, but it seems even slower now somehow. I considered batching our commands as well, but there isn't a way to batch mockgen commands in source mode (multiple-source
and-destination
flags). So, I figured I would borrow whatMake
does and just only runmockgen
if the generated code is stale when compared to the source code.How did you test it?
Running
make go-generate
locally now takes about7.7s
, down from44.0s
, so it's about 6x as fast:I also added unit tests which check cases like the destination file not being present, and it tested that manually as well.
Finally, I also deleted all
_mock.go
files and reran the command to verify that it works ok even when everything is out-of-date. In that case, there is a slight regression in time, up to 1 minute. I don't know why that's the case, but it should still be faster when there's no mocks.Potential risks
Documentation
Is hotfix candidate?