-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
gh-120144: Make it possible to use sys.monitoring
for bdb and make it default for pdb
#124533
base: main
Are you sure you want to change the base?
Conversation
And of course we need documentation updates, I will do it later when the feature is accepted and the interface is decided. |
direct pdb usage
Its after midnight so will test much later today. If all ok using default, will patch IDLE to pass 'monitoring'. |
Ran fine with default backend. Not fine with EDIT: The remote execution process crashes because of an unrecoverable exception in the rpc code. Monitoring does not seem to work across the socket connection. Some of the debugger code likely needs a change (as pdb does). (But IDLE does not have to use 'monitoring'. |
Right - the most important thing is I think at least part of the issue is multi-threading. For |
Hi @terryjreedy , I "fixed" the multi-threading issue. Well by "fixed" I meant making it the same behavior as before. Let me know if you have some time to test it out :) |
With |
This is the most conservative attempt ever to utilize
sys.monitoring
inbdb
andpdb
.Highlights:
test_pdb
andtest_bdb
at all with the new backendbdb
will still default tosys.settrace
, which keeps all the old behavior. Users can opt-in to the newsys.monitoring
backend, and the interface is still the same, even fortrace_dispatch
(that's howtest_bdb
passes).bdb
where user can disable certain events to improve the peformance.pdb.Pdb
will usesys.settrace
by default too, and is configurable withpdb.Pdb.DEFAULT_BACKEND
pdb
CLI andbreakpoint()
uses themonitoring
backend and no noticable difference I can observe at this point.Solution:
Basically, I mimicked the behavior of
sys.settrace
withsys.monitoring
to keep the old behavior as much as possible. But I had the chance to use the new API ofsys.monitoring
to disable certain events.Performance:
It's not as impressive as the original proposal, but for the following code:
On my laptop, without debugger, it takes 0.025s. With the new pdb attached (
b f
thenc
), it takes the same amount of time, and with Python 3.12 pdb, it takes 1.04s(4100%+ overhead). The performance improvement is significant to say at least.And as you can tell from the diff, the actual changes to
pdb
is minimal - just changesys.settrace(tracefunc)
toself.start_trace(tracefunc)
andsys.settrace(None)
toself.stop_trace()
. That's what the debugger developers need to do to onboard.sys.monitoring
for pdb/bdb #120144