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

Cache debugger skip frame predicate #14386

Merged
merged 3 commits into from Apr 2, 2024
Merged

Conversation

Carreau
Copy link
Member

@Carreau Carreau commented Apr 2, 2024

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

Those were likely recently removed.
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.
@Carreau Carreau added this to the 8.24 milestone Apr 2, 2024
@Carreau Carreau merged commit a3074b8 into ipython:main Apr 2, 2024
18 of 21 checks passed
@Carreau
Copy link
Member Author

Carreau commented Apr 9, 2024

Here is a quick way to test:

$ ipython
Python 3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:21:25) [Clang 14.0.4 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.24.0.dev -- An enhanced Interactive Python. Type '?' for help.

In [1]: !cat test.py
from time import perf_counter

now = perf_counter()
for x in range(1000000):
    if x % 100_000 == 0:
        print(x)
print("done", perf_counter() - now)

In [2]: %run -d test.py
Breakpoint 1 at /Users/bussonniermatthias/test.py:1
NOTE: Enter 'c' at the ipdb>  prompt to continue execution.
> /Users/bussonniermatthias/test.py(1)<module>()
1---> 1 from time import perf_counter
      2
      3 now = perf_counter()
      4 for x in range(1000000):
      5     if x % 100_000 == 0:

ipdb> skip_predicates debuggerskip true
ipdb> c
0
100000
200000
300000
400000
500000
600000
700000
800000
900000
done 3.4291042499244213

In [3]: %run -d test.py
Breakpoint 1 at /Users/bussonniermatthias/test.py:1
NOTE: Enter 'c' at the ipdb>  prompt to continue execution.
> /Users/bussonniermatthias/test.py(1)<module>()
1---> 1 from time import perf_counter
      2
      3 now = perf_counter()
      4 for x in range(1000000):
      5     if x % 100_000 == 0:

ipdb> skip_predicates debuggerskip false
ipdb> c
0
100000
200000
300000
400000
500000
600000
700000
800000
900000
done 3.189767000032589

On 8.23, the version with skip_predicates debuggerskip true, will be unbearably slow (18sec vs 3.5sec on my machine)

You can try to change the values of debugger skip before entering the debugger.

ip = get_ipython()
if not ip.InteractiveTB.pdb:
    ip.InteractiveTB.pdb = ip.InteractiveTB.debugger_cls()

ip.InteractiveTB.pdb._predicates['debuggerskip'] = False # True by default.

Carreau added a commit to Carreau/ipython that referenced this pull request Apr 25, 2024
I hope in deep code this makes things faster.

Complement to ipython#14386, but a bit of a blind fix.
Carreau added a commit that referenced this pull request Apr 26, 2024
I hope in deep code this makes things faster.

Complement to #14386, but a bit of a blind fix.
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

Successfully merging this pull request may close these issues.

None yet

1 participant