-
Notifications
You must be signed in to change notification settings - Fork 14
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 server extremely slow to respond since v1.13.0 (20+ times slower than Pyright) #461
Comments
that's odd, i don't think there were any changes in 1.13 that would effect performance (and i personally haven't noticed any slowdown). the only thing that comes to mind is that its loading more docstrings than it used to in some cases. if you update to 1.13.0 and use the typeshed version from 1.12.6 (by setting the |
The typeshed information under Just tested both ways of providing the path to the LSP server: a) as an argument of the LSP CLI command and b) as a config parameter. (a) [language-server.basedpyright]
command = "basedpyright-langserver"
args = ["--stdio", "--verbose", "--typeshedpath", "/Users/adriaan/.local/pipx/venvs/basedpyright/lib/python3.12/site-packages/basedpyright/dist/typeshed-fallback/"] (b) [language-server.basedpyright.config]
basedpyright.analysis.diagnosticMode = "openFilesOnly"
basedpyright.analysis.typeCheckingMode = "standard"
basedpyright.analysis.autoSearchPaths = true
basedpyright.analysis.useLibraryCodeForTypes = true
basedpyright.analysis.typeshedPaths = ["/Users/adriaan/.local/pipx/venvs/basedpyright/lib/python3.12/site-packages/basedpyright/dist/typeshed-fallback/"] # v1.12.6 installed here with pipx I'm afraid that in neither case did I notice a speed up. |
In case it helps, here are the --stats from running the basedpyright CLI (not basedpyright-langserver): v1.2.16:
v1.13.0
v1.13.1
Main culprit appears to be the 'check' step. Also interesting to note that from v13.0.0 onward more files are parsed and bound. |
It seems I was mistaken. As the stats above show, the major slowdown didn't hit until v1.13.1 – although I remember noticing some sluggishness in v1.13.0. |
I wonder if this could be |
Just in case you missed it, @KotlinIsland, I'm running with According to the table comparing the default diagnostic rules, the Your comment got me thinking though. I just did another experiment, this time with |
its either that or the thanks for all the effort you put in to help us narrow this down! |
I'm having performance issues as well but it seems for a longer time. The culprit for me is 1.2.0 (45 sec warm up) vs 1.1.0 (1-2 sec warm up). The latter is similar to what I have with pyright. This is especially annoying when wanting to move around in the code and jump to definition.
For information I'm on a very large codebase so performance issues are exacerbated. |
|
@Diaoul no need to apologize. my guess is that your issue was caused by an upstream change since we haven't touched any code related to import cycles @lemontheme can you see if #464 fixes it?
if that works, and if you have the time, if you want to check against each commit and let me know which one fixed it that would be appreciated:
thanks! |
@DetachHead, thanks for taking the time to look at this! I'm having some trouble pip installing from the first commit. When I launch the language server, I'm presented with this error message:
Seems like I'm missing a build step somewhere. Problem is, I don't know enough about Node to know where to start digging. By contrast, when I pip install from the latest release tag, the language server starts up without error. Let me know what I'm missing and I'll try out each of those commits :) |
that can happen if the language server is locked by your editor while pip is trying to uninstall it and replace it with the new one. if you close your editor, uninstall basedpyright, delete any folders starting with special characters from your venv (eg. |
Still nothing, I'm afraid. What strikes me is that when installing from the release tag, pip really takes its take on the wheel building step, i.e. on |
jeez, turns out i completely broke the build in 1baf3ec and never noticed. no idea how that went undetected by the ci. it seems to behave differently depending on whether you're builing the wheel or building+installing it... man i despise the python build system can you try installing fc161d9 and see if that works? (if it does and you want to also try those other commits from my comments above, their hashes have changed to 71b1189 and 13aef28) |
Whoops! Haha, yeah, it never quite works the way you expect it to. Anyway, all three commits install properly now. :) Below are the --stats of each. I took special care to run pip install with the --no-cache-dir and --force-reinstall flags. For each commit, I installed in 3 different ways: a) in my main venv, b) in a clean venv, c) with pipx. The --stats results were always the same. The conclusion, I'm sorry to report, is that the issue persists. Results:
|
damn. do you mind also checking against #466? there were some upstream performance fixes i think, maybe that could fix it is the repo you're testing against public? |
Sure thing. Below are the --stats results again when installing from db6568c: Good news and bad news. Good news: the LSP is fast again! – which resolves this issue.
The 3 commits compared in my previous comment didn't exhibit the same discrepancy between LSP and CLI speed. The repo I'm testing on is proprietary code that belongs to my company. |
thats unfortunate. i think some upstream changes to the primer may have uncovered the same performance issue(s) as well, so i'll try and use that to narrow down exactly when this started happening, assuming it's the same issue. |
so i spent the last few days trying to narrow this down and came to the conclusion that the performance issues uncovered by the primer were an unrelated upstream regression that had already been fixed in the latest release. unfortunately that means i'm back to square 1 and have no idea what the issue could be :( the only thing i can suggest is trying to create a minimal repro of the issue that you are able to share. if that's not possible, perhaps you could try installing each commit from between 1.12.6 and 1.13.1 and narrowing down exactly which commit introduced the issue |
Edit: I have no idea what shortcut I accidentally pressed. I did not mean to close this issue as complete. Thanks for sticking with this issue! I fully appreciate how little satisfication it brings to try to diagnose problems while driving blind. What we need is something to benchmark against – a large open-source code base that has all the complexities of real-life Python code, such as varying degrees of type completeness, strange (potentially dynamic) imports, and dependencies on non-Python code. 'Real-life' for me at least, as someone working in the ML space. I believe I've found the ideal candidate: https://github.com/huggingface/transformers. Running pyright and basedpyright with (I also tried Django, another fairly large codebase, but the time spent of the various steps is distributed differently: 'Check' and 'Detect Cycles' both take 8 seconds.) Here is the result of --stats:
Literally unable to complete. Or at least, it's been running for about 10 minutes now and it's still stuck on analyzing one of the modules. So... That's interesting! =p What I'll do now is, as you suggest, run through each of the commits between 1.12.6 and 1.13.1 and test against both the Transformers repo and my private repo. |
I've started collecting a few benchmarks in this Google Sheet. I'm evaluating on my private code base, Django, HF Transformers, and Scikit-learn. Key takeaways:
|
glad to hear your original issue is resolved. as for the outstanding issue with transformers, i was able to reproduce it on pyright 1.1.370 by turning on all diagnostic rules: [tool.pyright]
typeCheckingMode = "strict"
deprecateTypingAliases = true
enableExperimentalFeatures = true
reportCallInDefaultInitializer = true
reportImplicitOverride = true
reportImplicitStringConcatenation = true
reportImportCycles = true
reportMissingSuperCall = true
reportPropertyTypeMismatch = true
reportShadowedImports = true
reportUninitializedInstanceVariable = true
reportUnnecessaryTypeIgnoreComment = true
reportUnusedCallResult = true feel free to raise another issue for that if you want. though i would probably suggest raising it on the upstream repo instead, as i don't really have the experience with the pyright codebase to know where to begin diagnosing and fixing such performance issues. thanks again for your help and patience |
Interesting... So that probably means there are one or more rules that are by default enabled in basedpyright but disabled in pyright. I'll play around with them a bit before opening an issue. Likewise, thanks for helping me out :) |
all rules are enabled by default in basedpyright (the motivation for that decision is explained here). pyright also doesn't have the |
I use basedpyright's LSP server with Helix. It's a wonderful, low hassle combination that I've already converted one or two colleagues to. Thanks to basedpyright, I feel like I can finally get the best of Pyright without the feeling of missing out (on arbitrarily VS Code-exclusive features). So thanks! :)
Unfortunately, basedpyright's LSP has gotten slower. It's particularly noticeable in large modules. There are a few such files that I work on on a frequent basis. They range in the 1000–2000 lines of code. They are only partially typed, and they import from utterly horribly typed first-party and third-party dependencies. In short, these modules are a nightmare for type checkers. (I won't be able to share them to repro though, as the code is 100% proprietary.)
A completion request sent in the context of these files takes between 15 and 50 seconds to complete. Other requests take similarly long until the server has been running for a few minutes. For example, 'go to definition' requests speed up after a while. But completion requests remain slow to the point where they make basedpyright unusable. (I think we can both agree that completions need to resolve fairly quickly, seeing as the idea is to be faster than typing everything out.)
Some investigating later, I've arrived at the conclusion in the title: v1.12.6 was the last version that didn't suffer from these slow response times. Something changed in v1.13.0 and up.
What I did to arrive at this conclusion:
useLibraryCodeForTypes = false
. The Helix logs confirm that the settings were correctly acknowledged by the LSP server.So, while I'm sure the files I'm working in aren't great from a type checking standpoint, it appears that they didn't always pose an issue for basedpyright.
Let me know if there's anything I can do to help you diagnose this regression. For now I'll be downgrading to v1.12.6, saying goodbye to those sweet, sweet docstrings for builtins. :'(
The text was updated successfully, but these errors were encountered: