Skip to content

gh-145230: Update lockbench.py and benchmark_locks API#145271

Closed
gourijain029-del wants to merge 1 commit intopython:mainfrom
gourijain029-del:improve-lockbench
Closed

gh-145230: Update lockbench.py and benchmark_locks API#145271
gourijain029-del wants to merge 1 commit intopython:mainfrom
gourijain029-del:improve-lockbench

Conversation

@gourijain029-del
Copy link

@gourijain029-del gourijain029-del commented Feb 26, 2026

PR Description
Updates

lockbench.py
and the internal

benchmark_locks
API to support more realistic PyMutex benchmarking.

Key Changes:

New Metrics: Added --work-outside, --num-locks, and --total-iters to simulate varying contention levels and measure fairness.
Redundancy: Removed PyThread_type_lock benchmarking as it now uses PyMutex.
CLI: Switched to argparse and made the number of threads configurable.
Efficiency: Added cache-line padding to mutex states in C to prevent false sharing during multi-lock tests.

- Remove PyThread_type_lock benchmark as it now uses PyMutex.\n- Add --work-outside to adjust work outside critical sections.\n- Add --num-locks to support benchmarking multiple independent locks.\n- Make number of threads configurable.\n- Add --total-iters for fixed iteration benchmarks.
@bedevere-app
Copy link

bedevere-app bot commented Feb 26, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@colesbury
Copy link
Contributor

Thank you, but I already have a PR that makes the changes I described.

@colesbury colesbury closed this Feb 26, 2026
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.

2 participants