-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: too slow on large package #33531
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
Comments
Some additional info... When compiling the latest (master) locally I see a whole list of
|
The panic was easy enough to fix, I'll open a PR for that. Now that the panic is gone, I only see a bunch of |
Just opened a PR for the panic part of this report: https://go-review.googlesource.com/c/tools/+/189397 |
Thanks for reporting this issue and fixing the nil pointer error. I'll investigate this as soon as I get a chance. |
When I open this directory in VSCode, it seems like it works, but it is just very slow. The output I see for the check command is:
|
@stamblerre almost, but I'm also getting some I think your staying below the 1024 limit because of the worker in the telemetry package having a limit of 1000. The actual code that is causing the issue is here. If I update this loop so it uses a semaphore with a limit below 256, the problem goes away:
But I'm not sure if you think this is the correct place to fix this problem? And also I'm not sure if 250 is low enough as it's pretty close to 256 and I'm not sure what other files could possibly be open at this point in the code? Example output$gopls -rpc.trace -v check aws/resource_aws_rds_cluster.go 2019/08/08 09:07:19 Info:137.714259ms for GOROOT= GOPATH=/Users/svanharmelen/GoCode GO111MODULE=on PWD=/Users/svanharmelen/GoCode/src/github.com/terraform-providers/terraform-provider-aws go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "builtin", stderr: <<>> 2019/08/08 09:07:19 Info:Build info ---------- golang.org/x/tools/gopls v0.1.3 golang.org/x/tools/gopls@(devel) golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/tools@v0.0.0-20190723021737-8bb11ff117ca => ../ golang.org/x/xerrors@v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= |
Of course the semaphore could also just be a simple |
Limiting the number of open files to the correct OS-specific values does sound like a reasonable solution, though perhaps we could build tag the constants per-OS to avoid unnecessarily constraining Linux. If you'd like to contribute this fix, please feel free to send me a CL for it. |
Though, I'm actually surprised that this fix works. The number of files being parsed simultaneously should be constrained here, with a maximum limit of 20. |
Ah... I think I found it... It seems the semaphore is used, after the file is being read:
So all the reads are done at (more or less) the same time. And while the telemetry worker has a throttling side effect, it's limit is too high for the MacOS limit. Do you agree this is the root cause? If so the fix is pretty straight forward (just swapping a few lines), so I can make a PR for that. |
Oh wow, thanks for catching that. I can't believe we missed it in review. Please do send a PR if you can! |
Created a PR just now: https://go-review.googlesource.com/c/tools/+/189437 |
Now that the |
Ah, thanks for updating the issue! I just asked about this on Slack as well (didn't saw you updated this already) 👍 |
One issue here is almost certainly the LSP protocol forcing us to send a notification per file. More often than not, diagnostic updates will be package-oriented, and even then the availibility of diagnostics is more a function of the architecture of For example, type checking in response to a change results in diagnostics for a package and its reverse dependencies. The results from type checking are not incremental. When type checking is complete, all diagnostics for all files are known at that point in time: having to send separate diagnostic notifications per file is just overhead. This per-file approach also places overhead on the LSP client as well. In @stamblerre - any thoughts on this? Have you discussed a change/addition to the LSP spec on this point? |
Checking back in - |
I would say that it's OK to close this one. At least for me things work reasonably ATM... |
@stamblerre |
Reopening to investigate if we've regressed. |
The issue is no longer happening on https://github.com/terraform-providers/terraform-provider-aws repository as it has been split into multiple smaller packages recently. |
Thanks @kamilturek; just going through old performance bugs now that gopls@v0.12.0-pre.1 has been released (a major rewrite for memory usage and performance). Closing this as resolved. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, it does.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
A successful check without errors. What let me to start debugging is actually that completion started to take very long (several seconds). I assume this will at least be part of the reason, but regardless these errors are unexpected.
What did you see instead?
The text was updated successfully, but these errors were encountered: