-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-134637: make PyCFuncPtr_call lock free in ctypes #134702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine for 3.14 backport, but... ideally ctypes
should, where possible, look like a “normal” C extension that a third-party could write.
I'm worried about it reaching more and more into rather obscure internal APIs.
❯ ./python -m test -R 3:3 test_ctypes
Using random seed: 4211406380
0:00:00 load avg: 0.24 Run 1 test sequentially in a single process
0:00:00 load avg: 0.24 [1/1] test_ctypes
beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more)
123:456
XX. .1.
test_ctypes leaked [0, 1, 0] memory blocks, sum=1 (this is fine)
0:00:15 load avg: 0.41 [1/1] test_ctypes passed
== Tests result: SUCCESS ==
1 test OK.
Total duration: 15.4 sec
Total tests: run=600 skipped=34
Total test files: run=1/1
Result: SUCCESS No refleaks |
Performance on this PR release build without pgo: ./python.bat client.py
Running Release|x64 interpreter...
0
Connected.
207440
203568
203348
200588
204112 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Let's run the FT buildbots just in case.
Misc/NEWS.d/next/Library/2025-05-26-17-06-40.gh-issue-134637.9-3zRL.rst
Outdated
Show resolved
Hide resolved
!buildbot nogil |
🤖 New build scheduled with the buildbot fleet by @ZeroIntensity for commit 095e1cb 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F134702%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
…-3zRL.rst Co-authored-by: Peter Bierma <[email protected]>
Thanks @kumaraditya303 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…ion pointer in `free threading`. (pythonGH-134702) Fix performance regression in calling `ctypes` function pointer in `free threading`. (cherry picked from commit 3c05251) Co-authored-by: Kumar Aditya <[email protected]>
GH-134742 is a backport of this pull request to the 3.14 branch. |
…tion pointer in `free threading`. (GH-134702) (#134742) gh-134637: Fix performance regression in calling `ctypes` function pointer in `free threading`. (GH-134702) Fix performance regression in calling `ctypes` function pointer in `free threading`. (cherry picked from commit 3c05251) Co-authored-by: Kumar Aditya <[email protected]>
This fixes the performance regression mentioned on the issue, it avoids acquiring the critical section in the general case of no contention.