Skip to content

perf(gopls): lazy cache initialization - #2671

Closed
cljoly wants to merge 1 commit into
neovim:masterfrom
cljoly:lazy-go-cache
Closed

cljoly wants to merge 1 commit into
neovim:masterfrom
cljoly:lazy-go-cache

Conversation

@cljoly

@cljoly cljoly commented Jun 13, 2023 •

Copy link
Copy Markdown

On my machine, prior to this patch, gopls requires more than 38ms to
load (even after multiple starts of neovim):

077.729  038.355  038.355: require('lspconfig.server_configurations.gopls')

while the other servers take tens of millisecond.

After implementing this change, gopls takes about the same time as the
others:

033.563  000.163  000.163: require('lspconfig.server_configurations.gopls')

I have tried to replace go env GOMODCACHE with
echo /home/cjoly/go/pkg/mod but it’s just as slow. I suspect that the
call to system() is so slow because I use the fish shell. If I change
the 'shell' setting to 'sh', the issue disappears. Nonetheless, it’s
probably worth fixing, since this change is not very complex IMO, even
if my configuration is somewhat exotic.

I’ve checked that this change does not make using the 'sh' shell slower
and that the LSP still initializes properly.

On my machine, prior to this patch, gopls requires more than 38ms to
load (even after multiple starts of neovim):
```
077.729  038.355  038.355: require('lspconfig.server_configurations.gopls')
```
while the other servers take tens of millisecond.

After implementing this change, gopls takes about the same time as the
others:
```
033.563  000.163  000.163: require('lspconfig.server_configurations.gopls')
```

I have tried to replace `go env GOMODCACHE` with
`echo /home/cjoly/go/pkg/mod` but it’s just as slow. I suspect that the
call to `system()` is so slow because I use the fish shell. If I change
the 'shell' setting to 'sh', the issue disappears. Nonetheless, it’s
probably worth fixing, since this change is not very complex IMO, even
if my configuration is somewhat exotic.

I’ve checked that this change does not make using the 'sh' shell slower
and that the LSP still initializes properly.
@glepnir

glepnir commented Jun 14, 2023

Copy link
Copy Markdown
Member

if this command have performance issue can make it async in root_dir .

@glepnir

glepnir commented Jun 14, 2023

Copy link
Copy Markdown
Member

I have make it async in #2673 could you test it

@cljoly

cljoly commented Jun 17, 2023

Copy link
Copy Markdown
Author

Just seen your second comment, thank you!

Yes, your solution in #2673 does fix the issue as well.

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