GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-120144: Disable the CALL event when possible to achieve zero overhead pdb by gaogaotiantian · Pull Request #131390 · python/cpython

Conversation

@gaogaotiantian

@gaogaotiantian gaogaotiantian commented Mar 18, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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 in step)
  2. It returns the local trace function that enables all the other events on this code object (not function/frame).

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

We need to make sure we don't need any new 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 a next, until or return - it will just work fine, because they all rely on events on existing 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, is step - but if it's a step, it would either

  • hit stop_here() already on this specific CALL event so we can't reach to this point
  • or skip this function because of specified skip 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 any new 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.

  • Issue: Make it possible to use sys.monitoring for pdb/bdb #120144

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gaogaotiantian
Disable the CALL event when possible to achieve zero overhead pdb
046b7b5
@gaogaotiantian
gaogaotiantian requested a review from iritkatriel March 18, 2025 02:09
@bedevere-app bedevere-app Bot added the awaiting core review label Mar 18, 2025
@gaogaotiantian
gaogaotiantian requested a review from markshannon March 18, 2025 02:09
@bedevere-app bedevere-app Bot mentioned this pull request Mar 18, 2025
Make it possible to use sys.monitoring for pdb/bdb #120144
Closed
@blurb-it
📜🤖 Added by blurb_it.
2a62328
iritkatriel
iritkatriel approved these changes Mar 18, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Mar 18, 2025
@gaogaotiantian
gaogaotiantian merged commit e356468 into python:main Mar 21, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 21, 2025
@gaogaotiantian
gaogaotiantian deleted the disable-more-events branch March 21, 2025 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iritkatriel iritkatriel iritkatriel approved these changes
@markshannon markshannon Awaiting requested review from markshannon

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@gaogaotiantian @iritkatriel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.