From 046b7b5f6603084d648f8978520b3a6fded5a10d Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Mon, 17 Mar 2025 21:44:21 -0400 Subject: [PATCH 1/2] Disable the CALL event when possible to achieve zero overhead pdb --- Lib/bdb.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/bdb.py b/Lib/bdb.py index d32a05f59ad692..ba5cacc2a54cbc 100644 --- a/Lib/bdb.py +++ b/Lib/bdb.py @@ -342,7 +342,12 @@ def dispatch_call(self, frame, arg): self.botframe = frame.f_back # (CT) Note that this may also be None! return self.trace_dispatch if not (self.stop_here(frame) or self.break_anywhere(frame)): - # No need to trace this function + # We already know there's no breakpoint in this function + # If it's a next/until/return command, we don't need any CALL event + # and we don't need to set the f_trace on any new frame. + # If it's a step command, it must either hit stop_here, or skip the + # whole module. Either way, we don't need the CALL event here. + self.disable_current_event() return # None # Ignore call events in generator except when stepping. if self.stopframe and frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS: From 2a62328290bd89ae23b2be02cfa04fa54f5b744e Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 02:11:36 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2025-03-18-02-11-33.gh-issue-120144.dBLFkI.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2025-03-18-02-11-33.gh-issue-120144.dBLFkI.rst diff --git a/Misc/NEWS.d/next/Library/2025-03-18-02-11-33.gh-issue-120144.dBLFkI.rst b/Misc/NEWS.d/next/Library/2025-03-18-02-11-33.gh-issue-120144.dBLFkI.rst new file mode 100644 index 00000000000000..35d577e235102f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-03-18-02-11-33.gh-issue-120144.dBLFkI.rst @@ -0,0 +1 @@ +Disable ``CALL`` event in :mod:`bdb` in ``monitoring`` backend when we don't need any new events on the code object to get a better performance.