]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-123358: Use `_PyStackRef` in `LOAD_DEREF` (gh-130064)
authorSam Gross <colesbury@gmail.com>
Wed, 26 Mar 2025 16:08:20 +0000 (12:08 -0400)
committerGitHub <noreply@github.com>
Wed, 26 Mar 2025 16:08:20 +0000 (12:08 -0400)
commit3d4ac1a2c2b610f35a9e164878d67185e4a3546f
tree3f5c5a1347accef950ebfce5d7204864daaf0b41
parent1b8bb1ed0c4243796af531a35de982bc4f028215
gh-123358: Use `_PyStackRef` in `LOAD_DEREF` (gh-130064)

Concurrent accesses from multiple threads to the same `cell` object did not
scale well in the free-threaded build. Use `_PyStackRef` and optimistically
avoid locking to improve scaling.

With the locks around cell reads gone, some of the free threading tests were
prone to starvation: the readers were able to run in a tight loop and the
writer threads weren't scheduled frequently enough to make timely progress.
Adjust the tests to avoid this.

Co-authored-by: Donghee Na <donghee.na@python.org>
12 files changed:
Include/internal/pycore_cell.h
Include/internal/pycore_opcode_metadata.h
Include/internal/pycore_uop_metadata.h
Lib/test/test_free_threading/test_dict.py
Lib/test/test_free_threading/test_func_annotations.py
Lib/test/test_free_threading/test_gc.py
Lib/test/test_free_threading/test_list.py
Lib/test/test_free_threading/test_monitoring.py
Lib/test/test_free_threading/test_type.py
Python/bytecodes.c
Python/executor_cases.c.h
Python/generated_cases.c.h