-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Everything runs slowly after debugger is called #20571
Comments
Hey @battaglia01, thanks for reporting. I was able to reproduce your problem following your instructions. @impact27, do you know what could be happening in this case? |
Well the debugger needs to check if there is a breakpoint at each instruction, and this is a pathological case python does almost no computations and a lot of instructions. optimising the debugger should be possible but it won’t eliminate the problem completely |
From what I see, most of the time is spent in |
You can check by executing |
Hi @impact27 some responses
Thank you! |
spyder-kernels depends on ipython so any bug there will be here as well. You can use a tool like https://github.com/benfred/py-spy to check what is taking time for your setup. (The command is But do keep in mind that the debugger will always add overhead and that you will never be as fast as not having a debugger. |
Not sure what to say; I get you are saying this is an upstream IPython bug but it doesn't happen at all in regular IPython for me... |
So there must be something different with your setup. If I:
2 - run in the spyder console So if your problem is that the spyder kernel is much slower than ipython, then I can't reproduce your bug unfortunately. |
Ah! You replaced the pdb.set_trace() with the IPython debugger. OK, yes, very interesting. So to be clear, this doesn't cause any problems for me on ipython
But this does
So you are right, this does seem to be upstream. I guess the only reason it was happening in Spyder is because Spyder seems to turn pdb.set_trace() calls into ipdb calls. |
Ha! The difference is that IPython disables the debugger when there is no breakpoints left, as there is no way of adding a breakpoint after pressiong |
@impact27, what if we add a command to our debugger that doesn't check for breakpoints on every frame? That could be entered by users like @battaglia01 that wouldn't like to rely on that check. That command could be run using the exclamation magic ( |
So you want a command to exit the debugger completely? We can add a "exit debugger" command which would remove the debugger overhead. But I am not sure I am convinced? We can also try to optimise the debugger, which would improve the situation a bit |
Hello, I am on a MAC (Pro M1 MAX) too and face the same problem as @battaglia01 when using spyder's debugger. With the comments in this thread and an old stackoverflow thread (https://stackoverflow.com/questions/53381373/ipython-console-in-spyder-extremely-slow-in-anaconda) I could pin down the problem to ipython 8.x. I testet ipython 8.9 and 8.10 and benched it against 7.34. Here is what I did. I used a slightly modified code
Without a breakpoints the runtime of the code withipython 7.34 and 8.x is about 0.01 seconds on my machine. However, Here is what I did to set up both environments: The default environment with ipython 8.11 was created via
And the benchmark env was created by installing ipython 7.34 like so
As a result I have the follwing packages installed
Hopefully my small test helps to understand the runtime problem a little bit better. In the meantime, I'll downgrade ipython on my machine as a workaround. EDIT: |
I can confirm reverting to ipython 7.33 made debug run much faster. |
This was already reported to the IPython team (see issue ipython/ipython#13972), but we haven't received an answer yet. However, we're considering how to solve this problem on our side. |
Hey guys, I think the situation will be improved in our next version (5.4.4) because we disabled some IPython functionality that was making our debugger quite slow. So, the situation should be similar to what you experienced with Spyder 5.3.3 However, more improvements will come in Spyder 6 about this (that's why this issue is marked for that version). |
I'm not 100% sure this is correct as technically the value of __debugger_skip__ could change in the current frame while we are stepping into it, but that is likely super rare, and the slowdown that this create is problematic. There is still a small overhead for me, but this should make the experience much better. See spyder-ide/spyder-kernels#458, #13972, spyder-ide/spyder#20571, #14382
Issue Report Checklist
conda update spyder
(orpip
, if not using Anaconda)jupyter qtconsole
(if console-related)spyder --reset
Problem Description
After calling the debugger and pressing "c", things seem to run slowly in Spyder. Here is a very simple script to show this:
When this script is run, it will count up to 1000000, printing the value of x every 10000 counts, and then call
pdb.set_trace()
for the first time. This happens fast enough to be almost instaneous on my computer; of course it doesn't take much time for Python to count to 1000000.Once you are in pdb, you can press "c" to resume execution, and then you will see the counts of 10000 being printed extremely slowly in comparison. On my computer, it's about one or two every second.
This also seems to happen if, for instance, you replace the
pdb.set_trace()
above withpass
and set a debugger breakpoint there instead.Versions
Versions:
Dependencies
I don't see any "Dependencies" menu entry on Mac. Where is this??
The text was updated successfully, but these errors were encountered: