Skip to content

Slow edits and completions when editing Python code #210528

Open

Description

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

Activity

  1. added
    bug
    on Mar 14, 2024
  2. changed the title [-]Pylance chewing up resources when running cells in Jupyter notebooks[/-] [+]Resource usage of Pylance slowing Jupyter notebooks[/+] on Mar 14, 2024
  3. rchiodo commented on Mar 14, 2024

    @rchiodo
    Contributor

    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.

  4. ale-dg commented on Mar 14, 2024

    @ale-dg

    Hi Rich Chiodo (@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
    Item Value
    CPUs Apple M1 Pro (10 x 24)
    GPU Status 2d_canvas: enabled
    canvas_oop_rasterization: enabled_on
    direct_rendering_display_compositor: disabled_off_ok
    gpu_compositing: enabled
    multiple_raster_threads: enabled_on
    opengl: enabled_on
    rasterization: enabled
    raw_draw: disabled_off_ok
    skia_graphite: disabled_off
    video_decode: enabled
    video_encode: enabled
    webgl: enabled
    webgl2: enabled
    webgpu: enabled
    Load (avg) 3, 3, 3
    Memory (System) 16.00GB (5.96GB free)
    Process Argv
    Screen Reader no
    VM 0%

    These are the Jupyter logs I have retrieved for Don Jayamanne (@DonJayamanne) disabling Pylance, with and without markdown cells.

    1-Jupyter-no-MD.log
    1-Jupyter-with-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.

    Pylance.log

    Let me know if I can be of any help (although I only know Python for DS 😜)

    Best

  5. DonJayamanne commented on Mar 14, 2024

    @DonJayamanne
    ContributorAuthor

    Rich Chiodo (@rchiodo) I assumed that the numbers were off, and based on the comments from ale-dg disabling Pylance improved things.
    However there are other things that slow Jupyter as well, but Pylance was reported as being one of them, e.g. if CPU/Memory is used, then VS Code tends to slow down, which slows down Jupyter extensions & others.

    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.

  6. ale-dg commented on Mar 14, 2024

    @ale-dg

    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)
    Extension Author (truncated) Version
    python ms- 2024.2.1
    vscode-pylance ms- 2024.3.1
    jupyter ms- 2024.2.0
    jupyter-renderers ms- 1.0.17

    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

  7. DonJayamanne commented on Mar 14, 2024

    @DonJayamanne
    ContributorAuthor

    ale-dg Please can you confirm that disabling Pylance extension makes it faster.
    I.e. the following issue no longer exists

    e mini-window that pop-ups with hints loads VERY slow compared with other the previous versions when I

    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;

  8. changed the title [-]Resource usage of Pylance slowing Jupyter notebooks[/-] [+]Possibly high Resource usage of Pylance[/+] on Mar 14, 2024
  9. ale-dg commented on Mar 14, 2024

    @ale-dg

    Don Jayamanne (@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

  10. DonJayamanne commented on Mar 14, 2024

    @DonJayamanne
    ContributorAuthor

    but the lag with typing just went away.

    lets leave this issue open, basically completions is slow

  11. changed the title [-]Possibly high Resource usage of Pylance[/-] [+]Slow completions[/+] on Mar 14, 2024
  12. ale-dg commented on Mar 14, 2024

    @ale-dg

    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...

  13. 97 remaining items

  14. changed the title [-]Slow completions when editing Python code[/-] [+]Slow edits and completions when editing Python code[/+] on Apr 17, 2024
  15. ale-dg commented on Apr 17, 2024

    @ale-dg

    Alright then. Thanks for the help! Hope it also helps in solving the other issue regarding the speed of execution.

    Best

  16. DonJayamanne commented on Apr 17, 2024

    @DonJayamanne
    ContributorAuthor

    Please can you provide a sample csv file used in your notebook

  17. ale-dg commented on Apr 17, 2024

    @ale-dg

    Sure, attached the file.

    Best

    palmerpenguins_extended.csv

  18. heejaechang commented on Apr 18, 2024

    @heejaechang

    don't notebook vs regular hover/signaturehelp use different markdown renderer?

  19. DonJayamanne commented on Apr 18, 2024

    @DonJayamanne
    ContributorAuthor

    don't notebook vs regular hover/signaturehelp use different markdown renderer?

    From what I can tell they are the same,

  20. mjbvz commented on Apr 18, 2024

    @mjbvz
    Contributor

    Yes the parameter hints widget is the same everywhere, it's only notebook output that uses a different markdown renderer

  21. DonJayamanne commented on Apr 18, 2024

    @DonJayamanne
    ContributorAuthor

    Matt Bierner (@mjbvz)

    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.
    So, this is definitely happening in other places too, but not 100% of the time.
    The issue does definitely repro for me (again not 100% of the time), please let me know if CPU profiles (however we have this from the user) will help and what else information you need.

  22. leifwalsh commented on Apr 20, 2024

    @leifwalsh

    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:

    image

    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):

    image

    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. :)

  23. DonJayamanne commented on Apr 20, 2024

    @DonJayamanne
    ContributorAuthor

    Thank you,
    We have made a lot of performance improvements in vscode for editing and executing notebooks
    Please can you install the latest vscode insiders and the latest pre-release version of Jupyter extension and test this out

    let me know how it goes

    If you still run into issues please share the cpu logs while you are experiencing these same issues
    Instructions here #210528 (comment)

  24. carlos-andrade8 commented on Oct 27, 2024

    @carlos-andrade8

    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)
    pd.set_option('display.max_rows', None)
    pd.set_option('display. width', 1000)

    It tries to render but it takes so long. I'm not sure if the above is related to this issue.

    Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugperf

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions