-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Slow edits and completions when editing Python code #210528
Comments
How could Pylance be interfering with Jupyter execution? Unless the user only has a single core and not enough memory? That would be for the user to decide then to turn off Pylance or Jupyter. |
Hi @rchiodo I honestly don't know. Everything has been a mystery as it happens with a lot of users, especially with large notebooks and lot of markdowns. These are my Mac specs: System Info
These are the Jupyter logs I have retrieved for @DonJayamanne disabling Pylance, with and without markdown cells. 1-Jupyter-no-MD.log With MD it takes a bit longer to run, the computer warms up a little bit and it was done with Pylance deactivated. What most people has been reporting is Python/Jupyter being slow and only a couple of us have actually found out that Pylance was using a lot of resources (see #206119 (comment), #206119 (comment) and microsoft/pylance-release#5614). So yet again, no idea which one is it. I also tried to retrieve the logs from Pylance, although when just opening VSCode, the log files something around 30,000 lines and some of the final lines are the ones above. Below you can find the log file. Let me know if I can be of any help (although I only know Python for DS 😜) Best |
@rchiodo I assumed that the numbers were off, and based on the comments from @ale-dg disabling Pylance improved things. Feel free to close this issue if there's nothing to be done here, we're already looking into other issues reported by the user. |
Hi, Before closing the issue, I was about to comment that I just ran again the large notebook with markdowns and these extensions: Extensions (4)
After getting to where I wanted it (around coding cell 152), when typing in a function (i.e. OrdinalEncoder(), or any other from a library), the mini-window that pop-ups with hints loads VERY slow compared with other the previous versions when I downgraded, and it begins to lag. Also, when just beginning to type in the first parenthesis, it kind of stops everything else for loading the window (it stops around 3-5s). Then if we are lucky, it doesn't crash or lags or anything. The same happens for the "auto-complete" function (not sure what its name is... but is the one that loads below the code for choosing a previous function or variable or something else). Best |
@ale-dg Please can you confirm that disabling Pylance extension makes it faster.
Yes, you will no longer get completions, thats a different matter, however if it is still NOT faster, then we know for a fact that Pylance is not causing any delays and we can close this issue; |
@DonJayamanne it ran with the same speed, but the lag with typing just went away. Would it be worth it to close this issue as it is actually a bug with Pylance lagging VSCode? Best |
lets leave this issue open, basically completions is slow |
Well... just for the record, when I turned on Pylance again, I tested restarting the kernel to see what happens and all VSCode got stuck for some seconds (couldn't even scroll) and then it began to lag. In one of the issues was reported as well (and sometimes it crashes). I also tried it without Pylance and it didn't crash. It just took its time to start running the notebook again. Best P.S. Also the "Go To" button still doesn't work... |
@ale-dg can you try this? https://github.com/microsoft/pylance-release/wiki/Collecting-data-for-an-investigation.#collecting-cpuprofiles and provide us with *.cpuprofiles? by the way, to make things simpler first, try it with thank you |
ah, one more thing, if you are seeing the memory pressure log, your workspace might be too big for our default setup (using
Try this new setting (https://github.com/microsoft/pylance-release/pull/5602/files) we just added in |
My guess is this is a duplicate of the completion problem we found with Jupyter completions: |
I'd gladly confirm if it's the same, but it shows me a 404 error when opening.
I'll try it after a request of @bschnurr here microsoft/pylance-release#5614 (comment) |
Hi, I just completed the cpuprofile. I forgot to do the python.analysis.indexing: false because I have been doing so many changes and tests that I no longer know what I have changed or not, so my apologies for it. You will see a long time-gap somewhere between 14:00 and 14:12 (or somewhere around there), that is how long the notebook takes to run. After that it is all just typing to add some functions and it lagged. Just for the fun, I tried to open the profiles with VSCode, and it crashed 🤣🫠, so maybe something you'd like to check as well. Best |
The profiles don't show completions taking any time. Was it slow when you were typing? It shows like 150ms for completions to work: This likely means the slowdown is not in pylance but somewhere else. I'm guessing it's this code here: That code is getting completions from us too but also combining them with ones from the kernel. If the kernel is slow, (which I believe you said somewhere it was slow running cells?) then completions over all would be slow. |
They become slow after executing the cells. So, if I type without executing anything, they feel normal, like in old versions. When I begin executing cells, then the lags begins, something like this:
.. and so on for the rest of the time you are working on the file Hope it makes sense |
It makes it feel not normal, like there is a complete disconnection between the keyboard, the screen, VsCode, etc |
That sounds to me like it's the kernel completions then. If it works fine without running any cells, then just Pylance is involved. If it slows down only when the kernel is involved, then it's both Pylance and the Jupyter Kernel providing the completions. Given the cpu profile you sent, Pylance isn't taking any time to compute completions, so I'm going to transfer this issue to the Jupyter extension. |
Also there are some logs here, should you want to check them as well (coming from another issue microsoft/pylance-release#5614) microsoft/pylance-release#5614 (comment) |
Would this be related as well? Please see microsoft/pylance-release#5748 and microsoft/pylance-release#5173 |
@DonJayamanne @mjbvz @heejaechang as you can see above, I have referenced this issue to another in Pylance. I attached the same log (from stable versions - VSCode, Jupyter, Pylance, etc.) since even by opening the same notebook as above, Pylance crashed 🫠 Hope it helps Best |
@mjbvz & then I get a message similar to the following in the dev tools: Here's are the packages that need to be installed
Here is the first and second cell import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
import plotly.express as px
import plotly.graph_objects as go
import mplcatppuccin
import warnings
from scipy.stats import iqr
import scipy.stats as stats
import statsmodels.api as sm
from statsmodels.formula.api import ols
from pingouin import ttest
from sklearn.preprocessing import (
StandardScaler,
Normalizer,
PowerTransformer,
QuantileTransformer,
RobustScaler,
FunctionTransformer,
MinMaxScaler,
MaxAbsScaler,
)
from sklearn.pipeline import Pipeline
from statsmodels.graphics.gofplots import ProbPlot
from sklearn.compose import ColumnTransformer
from sklearn.model_selection import train_test_split, cross_validate
from sklearn.preprocessing import LabelEncoder
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import StratifiedKFold
warnings.simplefilter('ignore')
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
pd.set_option('display.max_columns', None)
pd.set_option('display.precision', 2)
pd.set_option('display.colheader_justify', 'left')
mpl.style.use('latte') & second cell to replic the issue from sklearn.preprocessing import OrdinalEncoder
ord = OrdinalEncoder() Adding brackets or parameters to For some reason it gets called multiple times (i could see this getting called almost 20-30 times). One of the Mardown content passed into sanitize call
Another sample of mardown content passed into another call
|
@DonJayamanne @mjbvz EDIT: Well... just in case, here they are, in case they re helpful: both the yml for Conda and the requirements txt for pip. Best |
@ale-dg Thank you very mcuh. |
@mjbvz I have no knowledge of the code, but found the following to be inresteing Given the fact taht the markdown has already been sanitialized a few lines earlier, why do we need to sanitize this again. |
@ale-dg I'm surprised you do not see these delays when you write the exact same code in a regular Python file (i.e. outside notebooks) pointing to the same Python environment. |
@DonJayamanne I haven't tried the exact same code because normally when working with ML I use notebook, not normal py files. I can try to do it tomorrow rendering the plots in the interactive window, just to see how it goes. Although your comment comes nicely because now I am writing a streamlit interface (on a completely different Python environment) in VSCode insiders which must be a py file and it SOMETIMES lags, not as frequently as with notebooks and not as dramatically, but it does. It's very light though, I don't think it would even show on a profile because I have tried to repro the exact same delay and it didn't happen. What I can tell you is that if I paste a piece of code from one window to another (I did it from a ipynb to a py), it lags for some seconds while IntelliSense recognises the code and the lag stays for a while, then it comes back to normal. Best |
From my test and t looking at code and taking into account you’re Jupyter extension works , this issue has no relation to Jupyter execution ie If you copy the exact same code (all the cells into a single python file), you will then run into the same perf issues anyways, that’s fine for now, I think we have all the information we need as I can replicate some of the delays at my end |
Alright then. Thanks for the help! Hope it also helps in solving the other issue regarding the speed of execution. Best |
Please can you provide a sample csv file used in your notebook |
Sure, attached the file. Best |
don't notebook vs regular hover/signaturehelp use different markdown renderer? |
From what I can tell they are the same, |
Yes the parameter hints widget is the same everywhere, it's only notebook output that uses a different markdown renderer |
Sometimes I have seen this taking 300ms when working on notebooks, we use markdown parser to build outlines and that ends up parsing markdown which results in 300ms sometimes. |
These are long issues so forgive me if this isn't new information, but I'm pretty sure I have the same problem described here and I've noticed something that might help? When I type code into a cell and then try to execute it, when I get this laggy behavior, I notice inlay error messages like this show up: As I watch (not touching anything, just waiting for the cell to execute), it progressively changes, as if it's analyzing prefixes of the content in the cell, or as if I were typing each character into the cell one by one very slowly. Here's another one (it made progress while I was typing): I also, in this notebook where I just reproduced it, had a perfectly fine experience when I started from an empty notebook, for about 13 cells worth of mixed code and markdown, then around the 14th cell something changed and it started doing the bad thing. It was very sudden, like I'd crossed a threshold or something, which surprised me because before I've only seen it sometimes, when opening notebooks I'd already authored (and this reminded me to try reading these issues again). I'd be happy to share a reproducer (my notebook is just 339KB including some plots), gather diagnostics, etc. but it looks like you have many? If you want, just point me to a message with instructions for gathering the ones that would help right now, I see you've done that quite a lot already. :) |
Thank you, let me know how it goes If you still run into issues please share the cpu logs while you are experiencing these same issues |
Hi Guys, I came across to this issue regarding the slowness of jupiter notebooks. I'm experiencing performance issues (extremely slow) when I try to print the shape of a dataframe or to show the head of the dataframe. It only happens when using: pd.set_option('display.max_columns', None) It tries to render but it takes so long. I'm not sure if the above is related to this issue. Thanks, |
Reported by @ale-dg here #206119 (comment)
Yes, but consider I did not use Pylance. Would you like me to test with it? I just activated it and opened the log trace for python and just for indexing it finishes its memory.
2024-03-13 17:51:01.092 [info] [Info - 17:51:01] (4192) Heap stats: total_heap_size=1220MB, used_heap_size=1156MB, total_physical_size=1218MB, total_available_size=2900MB, heap_size_limit=4096MB
2024-03-13 17:51:01.108 [info] [Warn - 17:51:01] (4192) Workspace indexing has hit its upper limit: 2000 files
The text was updated successfully, but these errors were encountered: