Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Improve performance of mock generation (#396) #397

Merged
merged 3 commits into from
Feb 22, 2020
Merged

Improve performance of mock generation (#396) #397

merged 3 commits into from
Feb 22, 2020

Conversation

plakhotnii
Copy link
Contributor

Fixes #396. This PR optimise resolving correct package name with go list command. Instead of calling go list for each import in file, now we do it for all imports in one call.

Time consuming by mockgen:

Source mode

(v1.4.0)
time ../mockgen -source user.go -destination mock_user/mock_user.go Index,Embed,Embedded
../mockgen -source user.go -destination mock_user/mock_user.go   2.09s user 2.83s system 280% cpu 1.756 total
(with optimizations)
time ../mockgen -source user.go -destination mock_user/mock_user.go Index,Embed,Embedded
../mockgen -source user.go -destination mock_user/mock_user.go   0.54s user 0.63s system 320% cpu 0.364 total

Reflection mode

(v1.4.0)
time ../mockgen -destination mock_user/mock_user.go github.com/golang/mock/sample Index,Embed,Embedded
../mockgen -destination mock_user/mock_user.go  Index,Embed,Embedded  1.73s user 1.72s system 199% cpu 1.731 total
(with optimizations)
time ../mockgen -destination mock_user/mock_user.go github.com/golang/mock/sample Index,Embed,Embedded
../mockgen -destination mock_user/mock_user.go github.com/golang/mock/sample  0.96s user 0.53s system 153% cpu 0.972 total

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@plakhotnii
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Member

@codyoss codyoss left a comment

Choose a reason for hiding this comment

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

Like the idea overall, lets just work through a couple of my nitpicks. Thanks!

mockgen/mockgen.go Outdated Show resolved Hide resolved
mockgen/parse.go Outdated Show resolved Hide resolved
mockgen/mockgen.go Outdated Show resolved Hide resolved
mockgen/mockgen.go Outdated Show resolved Hide resolved
mockgen/mockgen_test.go Show resolved Hide resolved
mockgen/mockgen.go Outdated Show resolved Hide resolved
Copy link
Member

@codyoss codyoss left a comment

Choose a reason for hiding this comment

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

Thanks for making the updates. Just a couple more things and then we can get this merged!

mockgen/mockgen.go Outdated Show resolved Hide resolved
mockgen/mockgen.go Outdated Show resolved Hide resolved
mockgen/mockgen.go Outdated Show resolved Hide resolved
@codyoss codyoss added this to the v1.5.0 milestone Feb 22, 2020
@codyoss codyoss merged commit b48cb66 into golang:master Feb 22, 2020
@codyoss
Copy link
Member

codyoss commented Feb 22, 2020

Thanks for working through this with me @plakhotnii and thank you for your contribution! 🎆

@rafaeljusto
Copy link

@codyoss Could you please release the v1.5.0? This fix here will help me a lot. 🙂

@codyoss
Copy link
Member

codyoss commented Feb 25, 2020

@rafaeljusto I can cut a version later today or tomorrow. Will just be a path: v1.4.1.

@rafaeljusto
Copy link

Perfect, thanks!

@codyoss codyoss removed this from the v1.5.0 milestone Feb 27, 2020
@codyoss
Copy link
Member

codyoss commented Feb 28, 2020

@rafaeljusto I did a release last night 😺

@rafaeljusto
Copy link

Thank you! 😄

stevendanna added a commit to chef/automate that referenced this pull request Apr 16, 2020
This release of mockgen has an important speed improvement:

 golang/mock#397

Signed-off-by: Steven Danna <steve@chef.io>
stevendanna added a commit to chef/automate that referenced this pull request Apr 16, 2020
This release of mockgen has an important speed improvement:

 golang/mock#397

On linux, with tools already installed and a primed cache, we go from:

    > time compile_client_mocks
    ...
    real	0m55.859s
    user	1m39.088s
    sys 	1m40.395s

to

    > time compile_client_mocks
    ...
    real	0m9.133s
    user	0m12.420s
    sys 	0m7.568s

Unfortunately, on macOS+Docker, the impact isn't as dramatic:

    > time compile_client_mocks
    ...
    real	1m32.170s
    user	1m46.861s
    sys 	2m31.633s

to

    > time compile_client_mocks
    ...
    real	1m8.510s
    user	0m21.225s
    sys 	0m24.807s

Signed-off-by: Steven Danna <steve@chef.io>
stevendanna added a commit to chef/automate that referenced this pull request Apr 16, 2020
This release of mockgen has an important speed improvement:

 golang/mock#397

On linux, with tools already installed and a primed cache, we go from:

    > time compile_client_mocks
    ...
    real	0m55.859s
    user	1m39.088s
    sys 	1m40.395s

to

    > time compile_client_mocks
    ...
    real	0m9.133s
    user	0m12.420s
    sys 	0m7.568s

Unfortunately, on macOS+Docker, the impact isn't as dramatic:

    > time compile_client_mocks
    ...
    real	1m32.170s
    user	1m46.861s
    sys 	2m31.633s

to

    > time compile_client_mocks
    ...
    real	1m8.510s
    user	0m21.225s
    sys 	0m24.807s

Signed-off-by: Steven Danna <steve@chef.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve performance of generation
4 participants