-
Notifications
You must be signed in to change notification settings - Fork 768
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
Code snippet makes the Semantic highlighting very slow #2366
Comments
Same issue here. The highlighting is running very slow after I updated Pylance extension in VS Code. |
My, that's quite an expression you have! Performing type analysis for such a deeply nested expression is computationally expensive. I can look at ways we might be able to speed up this case, but I'll need additional repro steps. This expression is referencing a bunch of symbols whose origin are not clear. For example, I don't know where If you're looking for a workaround, you can break up the expression into separate expressions that are saved to intermediate variables. |
Thanks For the answer! from dash import dash, dash_table, dcc, htm
import dash_bootstrap_components as dbc app = dash.Dash(
__name__,
external_stylesheets=[dbc.themes.LUMEN],
) |
I have a large file (almost 3800 lines) where 2022.2.1 took almost 5 minutes to check the file (as reported by the output log) @erictraut - something funky has happened with the 2022.2.1 release |
@Dr-Irv, the issue you're seeing is probably unrelated to this bug report. If you can provide more details (preferably in a separate bug report), that would be appreciated. I have a theory about why you might be seeing this with 2022.2.1, but I'll need additional details to help confirm. I suspect it's this: microsoft/pyright#3008. |
I can open up a new issue but not sure what to provide. I can't share the code. I just know the performance got significantly worse, and we are seeing this on many files. The output log from the server shows the analysis time grew. Tell me what you need and I can open a new issue. |
Ah, I was hoping you'd be able to provide a repro case that I could look into. If it's not too much to ask, could you see whether the problem started happening between Pyright 1.1.218 and 1.1.219? |
How? I only use it within VS Code. How can I specify the pyright version with VS Code? And if it is command-line, how do I do it so that it uses the VS Code provided type stubs? You have to give me more precise instructions on how to do that test. |
@Dr-Irv, I found a different repro that confirmed my theory. I have a fix in place, and it will be included in the next release. As I mentioned, I don't think your performance slow-down is related to the issue in this particular bug report. |
So we have to wait 5 days to get the release? Should we go back to 2022.2.0 to avoid this? Or is there some other workaround? It's killing our developer productivity right now. |
So here is a repo with the original file and a modified file which still has nested expressions. Funnily enough the modified file runs way faster so something i removed is causing a massive slowdown. test.py
vs dashboard.py
|
@Goldensteev, thanks for preparing the repro. Unfortunately, I'm not able to reproduce the problem you're seeing. The performance looks fine to me (nearly instantaneous semantic highlighting) when using the latest version of pylance. So there must be some additional context I need. I was able to figure out all of the sources of imports except for the package called Do you have any other non-default "python.analyzer" settings configured in your workspace? |
Same issue here! Semantic highlighting, code completion, parameter suggestions, etc., get super-slowed with 100% cpu usage in Pylance version 2022.2.1. I downgrade to 2022.2.0 and it seems to work fine. |
@erictraut So I have been doing a bit of investigation on my own after what you said and I have discovered what is making the semantic highlighting super slow and it's the local import import dataprep
all_data = dataprep.DashboardData("query_results/new_query.pkl") So this import combined with something in the
I have updated the repo and added |
I'm still not able to repro the slow behavior with the code you provided in your repo. The |
Here's another sample. Just pull the pandas repo at https://github.com/pandas-dev/pandas . Open up
With pylance 2022.2.0, it's 3 times faster:
Not as dramatic a difference on my private code, but still significant. Or for
pylance 2022.2.0:
Almost 10 times slower. |
@Dr-Irv, we understand the issue you're seeing, and it should be addressed in this week's Pylance release. @Goldensteev, I'm still not seeing the same behavior you're reporting. Here are the steps I'm using to try to reproduce the issue. Please let me know if I have these correct.
Here's what I see prior to uncommenting the import:
Here's what I see after uncommenting the import:
Both of these times are long, but I'm not seeing anything approaching 5 minutes. Is there anything in the above steps that I missed? Or anything else about your configuration that might be relevant? For example, are you editing remotely over ssh? Perhaps another member of the Pylance team could try to repro following these steps (@debonte, @heejaechang)? |
Yes those steps are indeed correct! |
this new patch did not fix my issue unfortunately |
The new patch did fix both the issues I reported above #2366 (comment) and #2366 (comment) |
The issues are fixed in the new version, 2022.2.3. Thank you! |
@radu-ion, could you post a minimal, self-contained piece of code that reproduces the problem? We won't be able to debug an issue like this from partial screen shots. Thanks! |
@erictraut Unfortunately, I am not able to reproduce the bug with simple, random Python code. But I will attach the Python file I am currently working on that is producing the bug with Pylance 2022.2.3. It works fine with Pylance 2022.2.0. Steps to reproduce on Windows 10, 64 bit (latest updates installed), Python 3.9.9, VS Code: Install the following with standard pip install commands: Create a test folder, copy the kcats.py (unzip it first) to the test folder and open the test folder with VS Code. You are not expected to run the code, just make sure Pylance is working as expected. |
@radu-ion, thanks for the repro steps. I was able to find and fix the underlying cause. This will be addressed in the next release of pylance. I'll note that this issue was unrelated to the issue that was initially reported in this bug report even though the symptoms were superficially similar. |
This issue has been fixed in version 2022.3.0, which we've just released. You can find the changelog here: CHANGELOG.md |
@Goldensteev, thanks for posting — and for the repro steps. Would you mind opening a new issue? This one has already been fixed and closed. While the symptoms you're seeing are similar, it's clearly a different issue, and I don't want it to get lost. |
Never mind, I just realized that this is probably the same issue that you reported at the start of this thread, which was obscured by several other unrelated bug reports. I'll re-open this issue. If other pylance users experience performance problems with seemingly-similar symptoms, please open a new issue rather than adding to this one. |
Since this is a core type checking issue, I've created a tracking bug in the pyright repo: microsoft/pyright#3145 |
@Goldensteev, I was able to repro the perf issue. I found the underlying cause. It will be fixed in the next release. Thanks again for reporting the problem. |
This issue has been fixed in version 2022.3.1, which we've just released. You can find the changelog here: CHANGELOG.md |
Environment data
Expected behaviour
Expect Pylance to hightlight my code in seconds as it's been doing for the past few weeks with even longer code snippets
Actual behaviour
Semantic Highlighting has been very slow or stuck
Logs
Python Language Server Log
Code Snippet / Additional information
slowdown coming from this local import
The text was updated successfully, but these errors were encountered: