Skip to content

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented Oct 15, 2024

@colesbury
Copy link
Contributor Author

colesbury commented Oct 15, 2024

Lockbench results are within the noise margin:

Tools\lockbench\lockbench.py

Before:

C:\Users\Administrator\cpython>PCBuild\amd64\python.exe Tools\lockbench\lockbench.py
Lock Type           Threads           Acquisitions (kHz)   Fairness
PyMutex             1                 67954                1.00
PyMutex             2                 36700                1.00
PyMutex             3                 14673                0.99
PyMutex             4                 24245                1.00
PyMutex             5                 12929                1.00
PyMutex             6                  7775                1.00
PyMutex             7                  5316                1.00
PyMutex             8                  3868                1.00
PyMutex             9                  2791                1.00
PyMutex             10                 1947                1.00
PyThread_type_lock  1                 28604                1.00
PyThread_type_lock  2                 19378                1.00
PyThread_type_lock  3                  6893                0.99
PyThread_type_lock  4                  3620                1.00
PyThread_type_lock  5                  2222                1.00
PyThread_type_lock  6                  1464                1.00
PyThread_type_lock  7                  1391                1.00
PyThread_type_lock  8                  1339                1.00
PyThread_type_lock  9                  1092                1.00
PyThread_type_lock  10                 1141                1.00

After:

C:\Users\Administrator\cpython>PCBuild\amd64\python.exe Tools\lockbench\lockbench.py
Lock Type           Threads           Acquisitions (kHz)   Fairness
PyMutex             1                 67936                1.00
PyMutex             2                 38318                0.98
PyMutex             3                 14288                0.99
PyMutex             4                 22348                1.00
PyMutex             5                 13601                1.00
PyMutex             6                  8422                1.00
PyMutex             7                  5346                1.00
PyMutex             8                  4194                1.00
PyMutex             9                  2776                1.00
PyMutex             10                 1937                1.00
PyThread_type_lock  1                 28766                1.00
PyThread_type_lock  2                 14875                0.96
PyThread_type_lock  3                  5971                0.95
PyThread_type_lock  4                  3149                1.00
PyThread_type_lock  5                  2008                1.00
PyThread_type_lock  6                  1473                1.00
PyThread_type_lock  7                  1378                1.00
PyThread_type_lock  8                  1425                1.00
PyThread_type_lock  9                  1252                1.00
PyThread_type_lock  10                 1168                1.00

@colesbury colesbury marked this pull request as ready for review October 15, 2024 19:03
@colesbury colesbury requested review from gpshead, pitrou and zooba October 15, 2024 19:03
@colesbury colesbury requested a review from pitrou October 16, 2024 14:45
Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'm not a Windows developer. Did you manually check that this works @colesbury ?
(I suspect it's not really possible to write an automated test for this?)

@colesbury
Copy link
Contributor Author

Yes, I manually tested on Windows with variations of the following script:

import threading
import time

l1 = threading.Lock()
l2 = threading.Lock()

def thread_run():
    l2.acquire()
    l1.acquire()

t = threading.Thread(target=thread_run)
t.start()

time.sleep(0.1)
l1.acquire()
l2.acquire()

t.join()

@pitrou pitrou merged commit d8c8648 into python:main Oct 17, 2024
39 checks passed
@colesbury colesbury deleted the gh-125541-windows-ctrl-c branch October 17, 2024 18:11
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants