Skip to content
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

VSCode python debugger incredibly slow / unresponsive / slow repr / spinning icons in "Variables" pane #1391

Closed
apmoore499 opened this issue Sep 21, 2023 · 4 comments

Comments

@apmoore499
Copy link

Debugging python scripts has become very slow in the last few days, I don't know why. Rolling vscode back to previous version didn't fix anything. The performance is very laggy whereas previously it worked very fast.

Steps to reproduce:

  1. Run debug with basic config:
    {
    "name": "Python: Current File",
    "type": "python",
    "request": "launch",
    "program": "${file}",
    "console": "integratedTerminal",
    "justMyCode": true,
    "logToFile": true
    },
  2. Click on arrow to start debug

The following issues are encountered:

  • Breakpoints take ages to hit. However, the script contents are simple and should not take this long, so it seems the problem is with debugger.
  • Messages indicating slow repr computation: "pydevd warning: Computing repr of da (ConfigDict) was slow (took 141.01s) ". I have never seen this message before. The script I am debugging runs fine if I call 'python script_name.py' without debug. ConfigDict object is from ml_collections package. I have used this package for months without any issues.
  • After code has hit a breakpoint, if I try to query any variables by calling 'print(variable_name)' to the debug console, it prints no output. The cursor is still blinking. If I leave it for a few minutes, it might print the variable. It doesn't appear to be completely frozen, just going very slow.
  • In debug panel on right hand side, under the 'Variables' section, there are only two displayed items: locals, and globals. These two items are accompanied by a spinning icon that never stops, even when a breakpoint is hit. Additionally, there are no variables listed underneath if I try to click the dropdown arrow. Again, if I leave it for a few minutes, a list of variables may populate eventually.

I have attached debug.log files.
debugpy.adapter-7080.log
debugpy.launcher-6365.log
debugpy.launcher-7104.log
debugpy.pydevd.6370.log
debugpy.server-6370.log

debugpy.adapter-6340.log

@apmoore499
Copy link
Author

Issue has been fixed.

The issue was caused by an instance of ml_collections ConfigDict() class. A neural net was added to the dict which caused the slowdown. The network has ~22million weights. I believe this causes slowdown in repr as vscode debugger may be running repr query for all parameters in network. Have not confirmed if this is the exact cause, regardless I have changed code and no slowdown.

Example of code which throws the issue:

import ml_collections
cdict=ml_collections.ConfigDict()
neural_net=load_my_neural_net()
cdict.neural_net=neural_net```

@int19h
Copy link
Contributor

int19h commented Sep 22, 2023

To clarify, debugger uses repr() to compute the representation of variables that it needs to show in Variables, Watch etc. If you have a breakpoint, this happens every time that breakpoint is hit.

@poedator
Copy link

poedator commented Nov 6, 2024

in my case this did not help.
Somehow debugger continues trying to calculate repr for heavy variables, even though the variables panel was switched off...
There was noting in the watches either.

@rchiodo
Copy link
Contributor

rchiodo commented Nov 6, 2024

That would depend upon VS code (or Visual Studio) or whatever your IDE is sending a variables request. If you turn on logging, the vscode log should show if there is a variables request or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants