Skip to content

gh-151436: Fix missing tstate->last_profiled_frame updates#151437

Open
maurycy wants to merge 2 commits into
python:mainfrom
maurycy:gh-151436
Open

gh-151436: Fix missing tstate->last_profiled_frame updates#151437
maurycy wants to merge 2 commits into
python:mainfrom
maurycy:gh-151436

Conversation

@maurycy

@maurycy maurycy commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Please see #151436 for more details.

The issue is fixed, drv_a is back:

def gen():
    while True:
        n = yield
        sum(range(n))

g = gen()
next(g)

def drv_a(): g.send(500)
def drv_b(): g.send(50000)

while True:
    drv_a(); drv_b()
2026-06-13T11:47:41.099330000+0200 maurycy@gimel /Users/maurycy/work/cpython (gh-151436 4eab5a0?) % sudo ./python.exe -m profiling.sampling run --collapsed -o /tmp/stacks.txt -d  10 genrepro.py&& cat /tmp/stacks.txt
Captured 10,000 samples in 10.00 seconds
Sample rate: 999.99 samples/sec
Error rate: 0.01
Collapsed stack output written to /tmp/stacks.txt
tid:13799271;<frozen runpy>:_run_module_as_main:201;<frozen runpy>:_run_code:87;genrepro.py:<module>:13;genrepro.py:drv_b:10;genrepro.py:gen:4 9945
tid:13799271;<frozen runpy>:_run_module_as_main:201;<frozen runpy>:_run_code:87;genrepro.py:<module>:13;genrepro.py:drv_a:9;genrepro.py:gen:4 48
tid:13799271;<frozen runpy>:_run_module_as_main:201;<frozen runpy>:_run_code:87;genrepro.py:<module>:13;genrepro.py:drv_b:10;genrepro.py:gen:3 3
tid:13799271;<frozen runpy>:_run_module_as_main:201;<frozen runpy>:_run_code:87;genrepro.py:<module>:13 1
tid:13799271;<frozen runpy>:_run_module_as_main:201;<frozen runpy>:_run_code:87;genrepro.py:<module>:13;genrepro.py:drv_a:9 1
tid:13799271;<frozen runpy>:_run_module_as_main:201;<frozen runpy>:_run_code:87;genrepro.py:<module>:13;genrepro.py:drv_b:10 1
2026-06-13T11:47:51.429974000+0200 maurycy@gimel /Users/maurycy/work/cpython (gh-151436 4eab5a0?) % 

0,5% (48/9996 = 0,48%) is roughly correct, since it shouldn't be exactly linear.

I can try to come up with reproduction for each miss.

Should it be a helper?

If you ask me, the whole mechanism smells me of ABA...

@maurycy maurycy marked this pull request as ready for review June 13, 2026 09:58
@maurycy maurycy requested a review from markshannon as a code owner June 13, 2026 09:58
@maurycy

maurycy commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

cc @pablogsal @savannahostrowski

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant