Skip to content

gh-149521: Do not update last_profiled_frame if it's not changed#149522

Open
maurycy wants to merge 2 commits intopython:mainfrom
maurycy:remote-debugging-last-profiled-frame
Open

gh-149521: Do not update last_profiled_frame if it's not changed#149522
maurycy wants to merge 2 commits intopython:mainfrom
maurycy:remote-debugging-last-profiled-frame

Conversation

@maurycy
Copy link
Copy Markdown
Contributor

@maurycy maurycy commented May 8, 2026

With the patch applied, the number of process_vm_writev for this script:

def f():
    x = 0
    while True:
        x += 1
f()

went from 118241 to 2:

2026-05-07T23:57:57.377240168+0000 maurycy@weiss /home/maurycy/cpython (remote-debugging-last-profiled-frame 1a07c4a*) # ./python.exe /tmp/spin.py & TGT=$!
sleep 0.5
strace -c -f -e trace=process_vm_writev,process_vm_readv,pwritev,pwritev2 \
  ./python.exe -m profiling.sampling attach -r 100khz -d 30 \
  --pstats -o /tmp/out.pstats $TGT
kill $TGT; wait 2>/dev/null
[1] 136124
Captured 158384 samples in 30.00 seconds
Sample rate: 5279.46 samples/sec
Error rate: 0.00
Warning: missed 2841621 samples from the expected total of 3000005 (94.72%)
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ------------------
100.00    1.180278           2    475164           process_vm_readv
  0.00    0.000007           3         2           process_vm_writev
------ ----------- ----------- --------- --------- ------------------
100.00    1.180285           2    475166           total
[1]  + terminated  ./python.exe /tmp/spin.py

Note how process_vm_readv went up!

Closes #149521

@pablogsal pablogsal added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label May 8, 2026
@pablogsal pablogsal enabled auto-merge (squash) May 8, 2026 01:20
@pablogsal
Copy link
Copy Markdown
Member

Excellent catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_remote_debugging: no need to update last_profiled_frame if no change

2 participants