]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-145230: Update lockbench (gh-145231)
authorSam Gross <colesbury@gmail.com>
Fri, 27 Feb 2026 19:09:05 +0000 (14:09 -0500)
committerGitHub <noreply@github.com>
Fri, 27 Feb 2026 19:09:05 +0000 (14:09 -0500)
commit72eca2af59043c78647b0e6be3777a947ea9ef0f
tree9cdfd77755868a859d0b30ab7aa3ad48feb2ec5d
parent4d89056ed0f0975e786d859993786a33144cade5
gh-145230: Update lockbench (gh-145231)

Remove PyThread_type_lock (now uses PyMutex internally).

Add new benchmark options:
- work_inside/work_outside: control work inside and outside the critical section to vary contention levels
- num_locks: use multiple independent locks with threads assigned round-robin
- total_iters: fixed iteration count per thread instead of time-based, useful for measuring fairness
- num_acquisitions: lock acquisitions per loop iteration
- random_locks: acquire random lock each iteration

Also return elapsed time from benchmark_locks() and switch lockbench.py to use argparse.
Modules/_testinternalcapi/clinic/test_lock.c.h
Modules/_testinternalcapi/test_lock.c
Tools/lockbench/lockbench.py