Skip to content
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

Improve package mode performance #230

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

@@ -147,7 +147,7 @@ func (p *packageModeParser) loadPackage(packageName string) (*packages.Package,
}

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.

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.

2 participants