Skip to content

Conversation

@johanneswuerbach
Copy link

Instead of loading the package and all its dependencies, load only the specified package, which significantly improves the performance in our case.

@CLAassistant
Copy link

CLAassistant commented Jan 3, 2025

CLA assistant check
All committers have signed the CLA.


cfg := &packages.Config{
Mode: packages.NeedDeps | packages.NeedImports | packages.NeedTypes | packages.NeedTypesInfo | packages.NeedEmbedFiles | packages.LoadSyntax,
Mode: packages.LoadSyntax,
Copy link
Author

@johanneswuerbach johanneswuerbach Jan 3, 2025

Choose a reason for hiding this comment

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

This was simplified according to https://pkg.go.dev/golang.org/x/tools/go/packages#pkg-constants, which states that LoadSyntax is essentially all other options except NeedDeps and NeedEmbedFiles.

Not sure why NeedEmbedFiles was used here, but NeedDeps is the biggest performance hit and the tests are still passing with it being removed and our mocks are generated just fine.

Choose a reason for hiding this comment

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

2025/03/18 13:14:21 internal error: package "encoding/json" without types was imported from "<package>"

We've just run into the (in our case) 2x performance degradation (15m -> 30m), unfortunately this change (specifically the removal of NeedDeps) doesn't seem to work as we're unable to find types for the third party packages that we're using.

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.

3 participants