]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-149584: Fix excessive overhead in the Tachyon profiler regarding the cache behavio...
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Wed, 20 May 2026 11:32:08 +0000 (04:32 -0700)
committerGitHub <noreply@github.com>
Wed, 20 May 2026 11:32:08 +0000 (04:32 -0700)
commit661df25692fd3d56ccca715e38656fdb565b4661
tree0f9a9b74c096b68184c9e49d01c74a8010fd7767
parent06a2830aa8ea181b664ef04a930011e6e4591ab8
gh-149584: Fix excessive overhead in the Tachyon profiler regarding the cache behavior (#149649)

Use exact remote reads for interpreter state, thread state, and
interpreter frame structs instead of pulling full remote pages into the
profiler page cache. This matches the core change from
python/cpython#149585.

The profiler clears the page cache between samples, so live entries are
always packed at the front. Track the live count and only clear/search
that prefix instead of scanning all 1024 slots on the hot path.

Use the frame cache to predict the next thread state and top frame
address, then batch interpreter/thread/frame reads with process_vm_readv
when profiling a Linux target. Reuse prefetched frame buffers in the
frame walker when the prediction is valid.

Cache the last FrameInfo tuple per code object/instruction offset, reuse
cached thread id objects, and append cached parent frames directly on
full frame-cache hits. This cuts Python allocation churn in the
steady-state profiler path.
12 files changed:
Lib/profiling/sampling/sample.py
Lib/test/test_external_inspection.py
Misc/NEWS.d/next/Library/2026-05-10-19-26-50.gh-issue-149584.x7Qm9A.rst [new file with mode: 0644]
Modules/_remote_debugging/_remote_debugging.h
Modules/_remote_debugging/clinic/module.c.h
Modules/_remote_debugging/code_objects.c
Modules/_remote_debugging/frame_cache.c
Modules/_remote_debugging/frames.c
Modules/_remote_debugging/module.c
Modules/_remote_debugging/threads.c
Python/remote_debug.h
Tools/inspection/benchmark_external_inspection.py