Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-120144: Disable the CALL event when possible to achieve zero overhead pdb#131390

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@gaogaotiantian
Copy link
Member

@gaogaotiantiangaogaotiantian commentedMar 18, 2025
edited by bedevere-appbot
Loading

This is one line of well-thought code :)

We basically solved the debugger overhead in a big loop by disabling LINE events, the one (major) thing left was recursive calls - or rather, calls in general. We won't prevent CALL events from happening for every unrelated call because that would require a much larger change, but we can disable CALL events after we hit it once.

Notice that CALL event has a two effects which made it a bit more complicated:

  1. It could be the event that the user actually wants (only happens instep)
  2. It returns the local trace function that enables all the other events on thiscode object (not function/frame).

No 2. makes it a bit challenging and much more rewarding.

We need to make sure we don't need anynew events on this code object, before we can disable the CALL event.

First of all, if there's any breakpoint on the code object, we can't do that. But we already have check for that where the code was added.

Then we'll realize, if it's anext,until orreturn - it will just work fine, because they all rely on events onexisting frame and code objects. It's impossible for those commands to stop at a new frame.

The only command that could stop at a new frame, isstep - but if it's a step, it would either

  • hitstop_here() already on this specificCALL event so we can't reach to this point
  • or skip this function because of specifiedskip argument, which means it won't stop in this function in the future

So really, we don't need to care about anything. If we don't need to trace this function now, we won't need anynew events for this code object in the future (until the user interaction), so we can simply disable the CALL event.

This basically gives us a zero overhead debugger. There's no observable overhead for the recursive fib implementation.

@gaogaotiantiangaogaotiantian merged commite356468 intopython:mainMar 21, 2025
43 checks passed
@gaogaotiantiangaogaotiantian deleted the disable-more-events branchMarch 21, 2025 00:32
seehwan pushed a commit to seehwan/cpython that referenced this pull requestApr 16, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@iritkatrieliritkatrieliritkatriel approved these changes

@markshannonmarkshannonAwaiting requested review from markshannon

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@gaogaotiantian@iritkatriel

[8]ページ先頭

©2009-2025 Movatter.jp