-
Notifications
You must be signed in to change notification settings - Fork 11
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
LSP Typescript is really slow on large projects #129
Comments
What makes you think an approach like in coc-tsserver is better? In what way is it better? Why is it faster? |
Both coc-tsserver and https://github.com/typescript-language-server/typescript-language-server (which this plugin uses) are mostly just wrappers around the typescript's And switching to https://github.com/neoclide/coc-tsserver is not an option because it's a nvim-specific implementation rather than a standard-compliant language server. You have to be more specific with your feedback on what exactly is faster in coc-tsserver. If there is something that can be improved then it's more likely that the work needs to be done in https://github.com/typescript-language-server/typescript-language-server rather then here though. |
I guess the same project opened in nvim using coc-nvim is much faster in completions matching vscode speed but the same project in sublime often takes a long time to show completions, etc. hence I was looking at the diff between the two. |
Without more specific information we won't be able to do anything. If you are serious about trying to solve this then I'd suggest providing: a) a video showing the difference of loading the project in both editors |
Actually, before anything else, I'd suggest checking if you can reproduce your issue in Safe Mode with just Package Control, LSP and LSP-typescript installed. I'm honestly skeptical about there being any meaningful difference in the performance of this package vs. coc-tsserver, knowing how both work... There might be something in your configuration that causes the issue though. |
Videos:Sublime with only LSP and LSP-typescript:Screen.Recording.2022-01-26.at.10.33.50.AM.mp4MacVim with coc-tsserver:Screen.Recording.2022-01-26.at.10.39.12.AM.mp4Even local autocompletion of the I will follow up with more logs. |
No, sorry, that's about diagnostics, not completions. |
Can you please try what I've mentioned above? |
This sounds a lot like #128 Big project = many dependencies = many autocompletions, that somehow kill Sublime's performance Can you check in lsp log panel if you are seeing logs like |
@Narretz Yes I do see a line like So coc-nvim and VS Code is doing something to prevent this as I don't see this issue in those two editors. |
Was checking out the vscode typescript language feature and this function filters some entries which I can't find in the language server used by LSP? Best I could find is https://github.com/typescript-language-server/typescript-language-server/blob/899bfa6353150de929821fdaf86dfa1970c68137/src/lsp-server.ts#L593 Seems like it is only some vs code config related filters though |
It filters out warnings which we also do here. It also filters out BTW. 20040 of bytes is not really much unless you have a very slow CPU. |
Maybe the VS Code extension caches the results somewhere? |
No, there is no way to cache those when you are typing text since the state is always different. In any case, you haven't provided full log so far. 20 KB of completions is really not that much so I'm not quite convinced that that's the problem. Do you have a very slow computer? |
Computer is fast. Also VS Code and coc-nvim works so I don't think it matters in this case. |
One thing I can see here is that the server responds to |
Were you pressing ctrl+space to trigger completions after typing each character? I don't see that happening on just typing "config". It seems like in your log the completions were triggered after |
Just before line 41 is when it takes the longest. I typed |
If you were not triggering completions manually (with ctrl+space) then I'm not sure how this happened. I can't seem to reproduce LSP triggering multiple completion requests like that. (Unfortunately the logs don't have timestamps so it's not possible to see where there are delays exactly. The |
Do you have some other plugin that forces more completion requests with the |
No I don't have other plugins. This is all in safe mode with only LSP and LSP Typescript. |
Is the project you are using for testing something that you could share? |
Unfortunately I can't share the whole project since it is private. It definitely is an exceptional case. Even the vscode repo opens and works without issues in Sublime with completions being near instant. The project I am working on has a lot of derived types based on Mobx State Trees and that is causing the slowdown. I will try narrowing it down more. In the meantime here is a VS Code log in case it helps in any way.
There is definitely different behaviours in the language servers somewhere. |
Setting:
in LSP-typescript settings would produce a big log in a That maybe would be useful but could contain private information so up to you if you want to share it. Although, I think, we more or less know that the issue is with too often triggered completion request but that's on the ST side so maybe we don't need a log, just figure out a way to reproduce... |
This is the sublime text .log directory log entry for the same completion:
Looks very similar to the VSCode ts extension. Maybe the problem lies in the way Sublime handles the completions then? |
Ok I noticed something else. There is a big pause around If I wait for the Is there a way for me to turn off diagnostics completely on the server and test? Maybe that is blocking something.
|
Hi, I'm experiencing the same. And as @ishanray said, there's a big pause around |
Slow response for If you have a project that works slowly in ST but not in VSCode then comparing the tsserver logs is probably gonna tell the most. In VSCode it's this option: In ST see #129 (comment) I'm not really gonna be able to help more unless proper/full logs are provided or a project that reproduces the difference. Note also that different versions of Typescript can also make a difference. ST shows the version used in the LSP log panel and VSCode show it in the status bar after clicking |
This is probably as close as I can get.. I just simply typed VSCode
SublimeText
|
I'd like to compare the tsserver logs. You've provided tsserver log from VSCode and LSP log from ST. That's like comparing apples to oranges. :) See #129 (comment) on how to enable same logs in ST. |
And also, disable |
That said, your log shows that ST triggered a completion request on Your VSCode log shows only the second one. Not sure if you just haven't included it or VSCode for some reason didn't trigger completions on BTW: I said "complete logs". :) It would help cut on time needed to investigate it, which I don't have that much of. |
Ah, sorry! If full logs, then okay. I'll restart the ts server and then do the exact same thing |
Then resolving this on the ST side could improve performance sublimehq/sublime_text#3796 |
Here are both logs. I performed exactly the same operations. Before that I restarted TSServer. Logs are too large so I uploaded them to Dropbox. |
Thanks. My observations:
|
Thanks for your observations, I'll try to turn off inlay hints. Also, any chance that the mentioned issue will be resolved? |
did it help @jansedlon ? How can I disable inlay hints actually? |
Options with |
I narrowed down my LSP-TypeScript slowness issues to the autocomplete, namely that there were a ton of suggestions populating the results in one of my large monorepo projects. Adding this to my LSP-typescript.sublime-settings has helped tremendously: {
"initializationOptions": {
"preferences": {
"includeCompletionsForModuleExports": false
}
}
} |
Nice! Do you know how to replicate this on neovim? |
ref: sublimelsp/LSP-typescript#129 ``` narrowed down my LSP-TypeScript slowness issues to the autocomplete, namely that there were a ton of suggestions populating the results in one of my large monorepo projects. Adding this to my LSP-typescript.sublime-settings has helped tremendously: { "initializationOptions": { "preferences": { "includeCompletionsForModuleExports": false } } } ````
Any updates regarding this or sublimehq/sublime_text#3796? Sublime is generally the slowest LSP out there even on smaller projects with the Volar LSP for Vue. |
LSP implemented a way to cancel completions requests sublimelsp/LSP#2177
The speed of LSP is affected by the server. Both the typescript language server and volar language server use tsserver underneath. |
The biggest contributor to this issue is ST freezing main thread due to large number of completions. At least VSCode doesn't have problems with same number of completions. I think that that issue is not even filed in ST bug tracker though. |
Yes. Rather than slow completions this issue has to do with ST UI freezing for a good couple of seconds depending on the system. Because there are no ETAs with ST development I eventually ended up switching back to VSC again temporarily. |
Autocompletion takes a good few seconds.
Digging into it, it seems like the Theia TypeScript Language Server might not be the best choice.
Can we consider switching to something like: https://github.com/neoclide/coc-tsserver?
This extension is a fork of
typescript-language-features
extension which is bundled with VSCode and is much faster.I can start working on it if this is something which might be useful.
Would it be better to do it as a different LSP plugin?
The text was updated successfully, but these errors were encountered: