Title: Update lockbench.py · Issue #145230 · python/cpython · GitHub
Open Graph Title: Update lockbench.py · Issue #145230 · python/cpython
X Title: Update lockbench.py · Issue #145230 · python/cpython
Description: Feature or enhancement The lockbench.py benchmarks PyMutex and PyThread_type_lock for various number of threads and length of critical section. You'll see similar benchmarks for other mutex implementations: Rust parking_lot, WebKit. I'd ...
Open Graph Description: Feature or enhancement The lockbench.py benchmarks PyMutex and PyThread_type_lock for various number of threads and length of critical section. You'll see similar benchmarks for other mutex impleme...
X Description: Feature or enhancement The lockbench.py benchmarks PyMutex and PyThread_type_lock for various number of threads and length of critical section. You'll see similar benchmarks for other mutex imp...
Opengraph URL: https://github.com/python/cpython/issues/145230
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Update lockbench.py","articleBody":"# Feature or enhancement\n\nThe lockbench.py benchmarks `PyMutex` and `PyThread_type_lock` for various number of threads and length of critical section. You'll see similar benchmarks for other mutex implementations: [Rust parking_lot](https://github.com/Amanieu/parking_lot/tree/master/benchmark/src/bin), [WebKit](https://github.com/WebKit/WebKit/blob/main/Source/WTF/benchmarks/LockSpeedTest.cpp).\n\nI'd like to make a few updates to this benchmark:\n\n* Remove `PyThread_type_lock`. It's now based on `PyMutex`, so this isn't really useful anymore.\n* Add `--work-outside` to adjust the amount work done while *not* holding the lock. This helps simulate low and moderate contention scenarios.\n* Add `--num-locks`. So if we run with 8 threads and 2 locks, each group of 4 threads is independently contending for a lock. This adds more concurrency and helps demonstrate the limits of excessive spinning.\n* Make number of threads configurable\n* Add `--total-iters` which configures each thread to run for a fixed number of iterations instead of the default of running the whole benchmark for 1 second. With this mode, the benchmarks is only as fast as the slowest thread. It's another way to measure the effect of \"fairness\".\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-145231\n* gh-145271\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/colesbury","@type":"Person","name":"colesbury"},"datePublished":"2026-02-25T18:56:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/145230/cpython/issues/145230"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c4e1c932-9767-500d-579f-65d81d72a37a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D964:2371E7:1D64639:28A184A:6A502133 |
| html-safe-nonce | 000b4cd5a34847e4b94197ef8d85d0ea44791548ec10ac1b9a3d72e8973045ef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTY0OjIzNzFFNzoxRDY0NjM5OjI4QTE4NEE6NkE1MDIxMzMiLCJ2aXNpdG9yX2lkIjoiMzMyNjA4NTU3OTg5NzA1MzQ5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | acac050cb72ae5dc2035972906aba3ce68f8a39d06a3e9dd71e49ecf16248e37 |
| hovercard-subject-tag | issue:3991176199 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/145230/issue_layout |
| twitter:image | https://opengraph.githubassets.com/28e9087ff0f547b38aa4c57394ddaa503e4fe5eb4eb08cc3dbbccf6142328352/python/cpython/issues/145230 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/28e9087ff0f547b38aa4c57394ddaa503e4fe5eb4eb08cc3dbbccf6142328352/python/cpython/issues/145230 |
| og:image:alt | Feature or enhancement The lockbench.py benchmarks PyMutex and PyThread_type_lock for various number of threads and length of critical section. You'll see similar benchmarks for other mutex impleme... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | colesbury |
| hostname | github.com |
| expected-hostname | github.com |
| None | a08040246389072795e3b4e7b33c6d9a0c564eee02e829a809326d67c418b069 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d1b91b18e7330fc458dfd824c61eaed7daa830d6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width