-
-
Notifications
You must be signed in to change notification settings - Fork 32k
3.14t vs 3.13t cuts IOCP performance in half #134637
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
Comments
In 3.14, we made ctypes thread-safe, so this is probably the result of lock contention. I'm honestly surprised it's not crashing in 3.13. Would you mind benchmarking to find which lock is causing the problem? |
I think it is because of using critical section around |
Are you saying that my IOCP server, using 3.13t, shouldn't actually be working? Because it does. Flawlessly, even under load heavy enough to throttle the rest of the system. Is there anything I can do to help? |
Oh, yeah, that sounds problematic. I'd be ok with removing that critical section entirely (or only holding it in places where we actually access per-object state), because it should up to the user to serialize their own C calls. |
I have a fix at #134702 which makes it lock-free in the general case and fixes the performance regression. |
…inter in `free threading`. (#134702) Fix performance regression in calling `ctypes` function pointer in `free threading`.
…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]>
…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]>
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
This is about 3.14.0bl vs 3.13.1, free threaded in both cases.
Microsoft Windows [Version 10.0.19045.4529]
I run and maintain an IOCP server in python 3.13.1t.
There are no 3rd party libraries being used.
The Problem: Using the exact same code, running 3.14t vs 3.13t cuts the throughput in half.
I've made a badly written, working benchmark, extracted/simplified from my IOCP server.
Server:
Client:
The server uses 4 threads. if you don't see any output, try reducing the amount.
When I use 8 threads (on my 8 core machine), I don't get any output. d'uh.
No, SMT-Threads don't count for anything here.
Each script runs in its own cmd.exe window.
Please be aware that you'll have to kill the server-process manually.
I wanted to add a call to "taskkill/F /IM:pytho*",
but then realized I might cause someone big trouble with that.
>python3.13t server.py
:Client output:
205536
207128
206764
206504
204768
>python3.14t server.py
:Client output:
107468
105516
106032
107492
108472
Perplexity suggested I should post this here,
because this is a use-case you people might be interested in.
Thank you.
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Linked PRs
ctypes
function pointer infree threading
. (GH-134702) #134742The text was updated successfully, but these errors were encountered: