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

x/tools/gopls: 5x slowdown in cmd tests #37365

Closed
findleyr opened this issue Feb 21, 2020 · 3 comments
Closed

x/tools/gopls: 5x slowdown in cmd tests #37365

findleyr opened this issue Feb 21, 2020 · 3 comments

Comments

@findleyr
Copy link
Contributor

@findleyr findleyr commented Feb 21, 2020

While investigating #37318, I noticed that tests for golang.org/x/tools/internal/lsp/cmd were also timing out. For example: https://build.golang.org/log/a7e57b48b2eb87387651b04e268638d5b1b25f9d

Looking into this, it appears that cmd tests got significantly slower recently. Bisecting, it looks like this is a result of golang/tools@6dcdf1d. These tests went from ~6s to ~30s on my workstation. That's surprising.

[nyc:tools2]> go test -count=1 ./internal/lsp/cmd                                                                     
ok      golang.org/x/tools/internal/lsp/cmd     5.937s                                                                
[nyc:tools2]> git bisect good                                                                                         
6dcdf1db2c06ad0ebe311c58b8cda17392eb42c2 is the first bad commit
commit 6dcdf1db2c06ad0ebe311c58b8cda17392eb42c2
Author: Rebecca Stambler <rstambler@golang.org>
Date:   Thu Jan 30 21:29:41 2020 -0500
                                                           
    internal/lsp/cache: refactor functions that return PackageHandles

CC @stamblerre @ianthehat

@gopherbot gopherbot added this to the Unreleased milestone Feb 21, 2020
@golang golang deleted a comment from gopherbot Feb 21, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.4.0 Feb 21, 2020
@findleyr
Copy link
Contributor Author

@findleyr findleyr commented Feb 21, 2020

Highlight tests appear to be the main contributors to the slowdown. For example:

nyc:tools2]> go test -run=TestCommandLine/Modules/../testdata/lsp/Highlight -count=1 ./internal/lsp/cmd
ok      golang.org/x/tools/internal/lsp/cmd     12.115s
[nyc:tools2]> git checkout HEAD~1
Previous HEAD position was 6dcdf1db internal/lsp/cache: refactor functions that return PackageHandles
HEAD is now at 009580c4 internal/lsp/source: export FindFileInpackage
[nyc:tools2]> go test -run=TestCommandLine/Modules/../testdata/lsp/Highlight -count=1 ./internal/lsp/cmd
ok      golang.org/x/tools/internal/lsp/cmd     2.363s
@ridersofrohan
Copy link

@ridersofrohan ridersofrohan commented Feb 26, 2020

go test -run=TestCommandLine/Modules/../testdata/lsp/Highlight -count=1 ./internal/lsp/cmd

Ran this test with some logging to see how long segments of code take to run and the part that takes up the most amount of time is running packages.load, which takes on average 200ms. The main difference is that now running this test calls packages.load 52 times, once for each highlight marker.

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 26, 2020

Change https://golang.org/cl/221107 mentions this issue: internal/lsp: remove unknown dependency from highlight tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.