Repository navigation
Conversation
_remote_debugging: Stop reading the base frame sentinel on every sample_remote_debugging: Stop reading the base frame sentinel
_remote_debugging: Stop reading the base frame sentinel_remote_debugging: Stop rereading the base frame sentinel
maurycy
commented
Oct 10, 2026
Comment on lines
+329
to
+330
| if (frame_addr == ctx->base_frame_addr | ||
| && !(unwinder->gc && frame_addr == ctx->gc_frame)) { |
Contributor
Author
There was a problem hiding this comment.
Optionally:
Suggested change
| if (frame_addr == ctx->base_frame_addr | |
| && !(unwinder->gc && frame_addr == ctx->gc_frame)) { | |
| // Skip the base frame sentinel unless we need to emit a <GC> marker | |
| // because GC started with no Python frames on this thread. | |
| if (frame_addr == ctx->base_frame_addr | |
| && !(unwinder->gc && frame_addr == ctx->gc_frame)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Basically,
process_frame_chain()reads frames untilpreviousisNULL:cpython/Modules/_remote_debugging/frames.c
Lines 345 to 348 in 565f76f
The last one is always
tstate->base_framethat is the sentinel set up once per thread withprevious == NULLandowner == FRAME_OWNED_BY_INTERPRETER:cpython/Python/pystate.c
Lines 1589 to 1599 in 565f76f
Its address is already in the thread state buffer:
cpython/Modules/_remote_debugging/threads.c
Line 535 in 565f76f
so the remote read is not needed.
Tools/inspection/oracle_external_inspection.pywith--runs 3, PGO+LTO, Ubuntu 24.04, AMD EPYC 4484PX,mainat 182f323 vs the PR, on the same box one after another:182f323)182f323+ patchI'm not exactly sure why
basicordeep_staticare worse here. My guess it's just PGO noise.main (`182f323`)
PR (`182f323` + patch)
maurycy@taut cpython-B (182f323*) % ./python ./Tools/inspection/oracle_external_inspection.py --runs 3 3.16.0a0 (tags/v3.15.0b1-2187-g182f323154-dirty:182f323154, Oct 10 2026, 14:15:59) [GCC 13.3.0] cases=async_running_task,asyncio,basic,code_object_reuse,deep_recursion,deep_static,flat_alternating,gen_alternating,nested_alternating,oversized_chunk,shared_leaf,threads runs=3 duration=3.0 rate_khz=100.0 warmup=0.7 poisson_sampling=False async_running_task (get_async_stack_trace) ref_keys=46 mode samples stacks empty µs errors% impossible impossible% blocking-nocache 348511 697022 3379 23.11±0.11 0.00±0.00 0 0.00±0.00 live-nocache 460515 921009 3251 16.70±0.05 1.92±0.17 14318 1.56±0.31 asyncio (get_async_stack_trace) ref_keys=95 mode samples stacks empty µs errors% blocking-nocache 443576 553293 1683 18.90±0.10 0.00±0.00 live-nocache 594948 700929 2211 13.79±0.52 0.40±0.04 basic (get_stack_trace) ref_keys=32 mode samples µs errors% raw_tvd tvd_excess tvd_floor blocking-nocache 504897 16.63±0.03 0.00±0.00 ref ref - blocking-cache 617583 13.39±0.14 0.00±0.00 0.001±0.000 0.001±0.000 0.000 live-cache 899992 3.28±0.05 0.00±0.00 0.012±0.000 0.012±0.000 0.000 live-nocache 899995 6.05±0.05 0.00±0.00 0.013±0.000 0.013±0.000 0.000 code_object_reuse (get_stack_trace) ref_keys=22 mode samples µs errors% impossible impossible% raw_tvd tvd_excess tvd_floor blocking-nocache 620199 12.81±0.22 0.00±0.00 0 0.00±0.00 ref ref - blocking-cache 767626 10.07±0.25 0.00±0.00 0 0.00±0.00 0.001±0.000 -0.001±0.000 0.001 live-cache 899994 3.47±0.06 0.00±0.00 0 0.00±0.00 0.349±0.025 0.347±0.025 0.001 live-nocache 899991 6.36±0.01 0.00±0.00 0 0.00±0.00 0.005±0.000 0.004±0.000 0.001 deep_recursion (get_stack_trace) ref_keys=769 mode samples µs errors% impossible impossible% raw_tvd tvd_excess tvd_floor blocking-nocache 228284 18.90±0.24 0.00±0.00 0 0.00±0.00 ref ref - blocking-cache 220124 20.12±0.41 0.00±0.00 0 0.00±0.00 0.036±0.010 0.020±0.010 0.016 live-cache 83004 71.18±6.10 25.86±5.92 31325 38.01±2.84 0.693±0.046 0.666±0.048 0.028 live-nocache 192223 28.96±16.09 7.58±3.68 16518 9.73±6.10 0.850±0.019 0.832±0.017 0.017 deep_static (get_stack_trace) ref_keys=1 mode samples µs errors% raw_tvd tvd_excess tvd_floor blocking-nocache 56808 42.14±2.09 0.00±0.00 ref ref - blocking-cache 65545 17.24±0.94 0.00±0.00 0.000±0.000 0.000±0.000 0.000 live-cache 76141 5.82±0.08 0.00±0.00 0.000±0.000 0.000±0.000 0.000 live-nocache 63351 29.29±0.17 0.00±0.00 0.000±0.000 0.000±0.000 0.000 flat_alternating (get_stack_trace) ref_keys=6 mode samples µs errors% impossible impossible% raw_tvd tvd_excess tvd_floor blocking-nocache 614231 12.92±0.03 0.00±0.00 0 0.00±0.00 ref ref - blocking-cache 582285 13.73±0.02 0.00±0.00 0 0.00±0.00 0.024±0.005 0.021±0.005 0.002 live-cache 899991 7.13±0.02 0.00±0.00 4204 0.47±0.14 0.077±0.013 0.076±0.013 0.002 live-nocache 899999 6.37±0.01 0.00±0.00 5548 0.62±0.04 0.111±0.017 0.110±0.017 0.002 gen_alternating (get_stack_trace) ref_keys=19 mode samples µs errors% impossible impossible% raw_tvd tvd_excess tvd_floor blocking-nocache 590747 13.84±0.05 0.00±0.00 0 0.00±0.00 ref ref - blocking-cache 573287 14.31±0.09 0.00±0.00 0 0.00±0.00 0.036±0.011 0.032±0.011 0.004 live-cache 724332 7.36±0.03 19.52±0.68 154090 21.29±4.24 0.287±0.025 0.283±0.025 0.004 live-nocache 725428 7.02±0.03 19.40±0.96 372262 51.34±4.62 0.638±0.059 0.633±0.059 0.005 nested_alternating (get_stack_trace) ref_keys=12 mode samples µs errors% impossible impossible% raw_tvd tvd_excess tvd_floor blocking-nocache 584517 13.01±0.01 0.00±0.00 0 0.00±0.00 ref ref - blocking-cache 714155 10.23±0.03 0.00±0.00 0 0.00±0.00 0.030±0.006 0.028±0.006 0.002 live-cache 899992 3.65±0.01 0.00±0.00 30 0.00±0.01 0.037±0.040 0.035±0.040 0.002 live-nocache 899998 6.47±0.09 0.00±0.00 4 0.00±0.00 0.067±0.030 0.065±0.030 0.002 oversized_chunk (get_stack_trace) ref_keys=17 mode samples µs errors% impossible impossible% raw_tvd tvd_excess tvd_floor blocking-nocache 608009 13.03±0.04 0.00±0.00 0 0.00±0.00 ref ref - blocking-cache 714629 10.83±0.09 0.00±0.00 0 0.00±0.00 0.024±0.011 0.021±0.011 0.002 live-cache 899993 4.59±0.01 0.00±0.00 24505 2.72±0.28 0.066±0.013 0.064±0.013 0.002 live-nocache 899989 6.52±0.01 0.00±0.00 1 0.00±0.00 0.095±0.010 0.092±0.010 0.002 shared_leaf (get_stack_trace) ref_keys=10 mode samples µs errors% impossible impossible% raw_tvd tvd_excess tvd_floor blocking-nocache 617170 12.96±0.02 0.00±0.00 0 0.00±0.00 ref ref - blocking-cache 767359 10.12±0.02 0.00±0.00 0 0.00±0.00 0.032±0.024 0.031±0.024 0.001 live-cache 899993 3.52±0.01 0.00±0.00 685 0.08±0.06 0.071±0.047 0.070±0.047 0.001 live-nocache 899991 6.35±0.01 0.00±0.00 0 0.00±0.00 0.063±0.006 0.062±0.006 0.001 threads (get_stack_trace) ref_keys=8 mode samples stacks µs errors% raw_tvd tvd_excess tvd_floor blocking-nocache 62150 576377 159.09±86.15 0.00±0.00 ref ref - blocking-cache 76231 810134 113.85±35.56 0.00±0.00 0.035±0.037 0.034±0.037 0.001 live-cache 318426 2714810 19.70±2.44 0.00±0.00 0.042±0.017 0.041±0.017 0.001 live-nocache 127896 1394382 60.32±9.68 0.00±0.00 0.064±0.023 0.063±0.022 0.001_remote_debugging: reading whole pages over and over #149584