gh-134637: make PyCFuncPtr_call lock free in ctypes#134702
gh-134637: make PyCFuncPtr_call lock free in ctypes#134702kumaraditya303 merged 6 commits intopython:mainfrom
Conversation
encukou
left a comment
There was a problem hiding this comment.
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: SUCCESSNo refleaks |
|
Performance on this PR release build without pgo: ./python.bat client.py
Running Release|x64 interpreter...
0
Connected.
207440
203568
203348
200588
204112 |
ZeroIntensity
left a comment
There was a problem hiding this comment.
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 <zintensitydev@gmail.com>
|
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 <kumaraditya@python.org>
|
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 <kumaraditya@python.org>
…ion pointer in `free threading`. (python#134702) Fix performance regression in calling `ctypes` function pointer in `free threading`.
…ion pointer in `free threading`. (python#134702) Fix performance regression in calling `ctypes` function pointer in `free threading`.
This fixes the performance regression mentioned on the issue, it avoids acquiring the critical section in the general case of no contention.