go-langserver icon indicating copy to clipboard operation
go-langserver copied to clipboard

Take 3s to go to definition for symbol of internal package

Open anphung opened this issue 7 years ago • 9 comments

In vscode: For symbol of internal package (the package that I'm coding), it takes 3s to jumps to the definition. For symbol of external packages (packages that are in vendor) , it jumps nearly instantly.

macOS High Sierra 10.13.16

$ go-langserver -version
v3-dev
$ code --version
1.27.2
f46c4c469d6e6d8c46f268d1553c5dc4b475840f
x64

anphung avatar Oct 05 '18 14:10 anphung

Can you include your go config for vscode? Any diagnostic output to help diagnose? Is this in OSS, so I can try reproduce?

keegancsmith avatar Oct 08 '18 17:10 keegancsmith

Here is my go config

  "go.docsTool": "gogetdoc",
  "go.languageServerExperimentalFeatures": {
    "autoComplete": true,
  },
  "go.languageServerFlags": [
    "-diagnostics",
  ],
  "go.useLanguageServer": true,

go-langserver output:

langserver-go: reading on stdin, writing on stdout
Passing an initialize rootPath URI ("file:///Users/anphung/go/src/github.com/anphung/mypackage") is deprecated. Use rootUri instead.

If sub package (e.g.: github.com/anphung/mypackage/controller) inside mypackage contains small number of files (around ~20 files), It jumps fast. If sub package contains big number of files (> 150 files, each file has 10 definitions), it jumps slow. I guess that's the limit.

Sorry, It's not OSS.

anphung avatar Oct 09 '18 08:10 anphung

If you remove the -diagnostics flag is it faster?

keegancsmith avatar Oct 09 '18 09:10 keegancsmith

It was running slow without it. tried to add it to see if there is some info, but no info.

anphung avatar Oct 09 '18 09:10 anphung

Thanks for the information. This should still be fast regardless. I'll check if we have regressed on which j2d engine we use with your flags (we have a slower one which is more correct, but by default we should be using a godef based j2d).

keegancsmith avatar Oct 09 '18 09:10 keegancsmith

Thanks for checking :)

anphung avatar Oct 09 '18 09:10 anphung

We haven't regressed here. I'm unsure how deep you want to get into this, but a pprof profile of what its doing to take that long would be amazing. https://github.com/sourcegraph/go-langserver#profiling

keegancsmith avatar Oct 11 '18 13:10 keegancsmith

Here we go.

"go.languageServerExperimentalFeatures": {
    // "autoComplete": true,
  },
  "go.languageServerFlags": [
    "-pprof",
    "localhost:6060",
  ],
  "go.useLanguageServer": true,
  1. Click on a symbol in vscode
  2. Immediately go to terminal and run the go tool pprof...

pprof.zip

anphung avatar Oct 12 '18 08:10 anphung

Ah, it's like this, try to jump to Definition of:

  1. definitionGodef https://github.com/sourcegraph/go-langserver/blob/master/langserver/definition.go#L25 and
  2. Location https://github.com/sourcegraph/go-langserver/blob/master/langserver/definition.go#L29

Location got jumped into immediately, definitionGodef has a little delay. Maybe it's because package github.com/sourcegraph/go-langserver/langserver is more complex than package github.com/sourcegraph/go-langserver/pkg/lsp.

I guess if a package (excluding children package) is to big, it'll be slow because of i/o bottle neck. So, it's not about internal vs. external package.

anphung avatar Oct 12 '18 09:10 anphung