Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
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:
fromctypesimportwindll,create_string_buffer,c_void_p,c_ulong,c_ulonglong,Structure,byref,cast,addressof,POINTER,c_charfromctypes.wintypesimportDWORD,HANDLEkernel32=windll.kernel32CreateNamedPipeW=kernel32.CreateNamedPipeWCreateIOCompletionPort=kernel32.CreateIoCompletionPortConnectNamedPipe=kernel32.ConnectNamedPipeGetQueuedCompletionStatusEx=kernel32.GetQueuedCompletionStatusEx;ReadFile=kernel32.ReadFileGLE=kernel32.GetLastErrorclassOVERLAPPED(Structure):_fields_= (("0",c_void_p),("1",c_void_p),("2",DWORD),("3",DWORD),("4",c_void_p),("5",c_void_p),("6",c_void_p),("7",c_void_p),("8",c_void_p))Overlapped= (OVERLAPPED*10)()__Overlapped=byref(Overlapped)IOCP=CreateIOCompletionPort(HANDLE(-1),None,0,4)flag1=1|1073741824;flag2=4|2|0|8Pipe=CreateNamedPipeW("\\\\.\\pipe\\IOCPBenchMark",flag1,flag2,255,32,0,0,None)ifnotCreateIOCompletionPort(Pipe,IOCP,1,0):print("ERROR!")ReadBuffer=create_string_buffer(1024)__ReadBuffer=byref(ReadBuffer)OverlapEntries=create_string_buffer(32*128)ove=byref(OverlapEntries);Completed=c_ulong(0)__Completed=byref(Completed)def__IOCPThread():whileTrue:whilenotGetQueuedCompletionStatusEx(IOCP,ove,255,__Completed,0,False):continueReadFile(Pipe,__ReadBuffer,32,None,__Overlapped)fromthreadingimportThreadThreads= []fortinrange(4):Threads.append(Thread(target=__IOCPThread))success=ConnectNamedPipe(Pipe,__Overlapped)ifnotsuccess:ifGLE()!=997:print("ERROR 2")whilenotGetQueuedCompletionStatusEx(IOCP,ove,255,__Completed,1,False):continueprint("Connected.")ReadFile(Pipe,__ReadBuffer,32,None,__Overlapped)fortinThreads:t.start()fromtimeimportsleepwhileTrue:sleep(1)
Client:
fromctypesimportwindll,c_char_p,byreffromctypes.wintypesimportDWORDfromtimeimportperf_counteraspfckernel32=windll.kernel32CreateFileW=kernel32.CreateFileWWriteFile=kernel32.WriteFileGLE=kernel32.GetLastErrorwritten=DWORD()__written=byref(written)print(GLE())GENERIC_WRITE=1073741824Pipe=kernel32.CreateFileW("\\\\.\\pipe\\IOCPBenchMark",GENERIC_WRITE,0,None,3,0,None)ifGLE()==0:print("Connected.")test=b"test"t=pfc()+1whileTrue:forCountinrange(1000000):ifnotWriteFile(Pipe,test,4,__written,None):print("ERROR ",GLE())ifnotWriteFile(Pipe,test,4,__written,None):print("ERROR ",GLE())ifnotWriteFile(Pipe,test,4,__written,None):print("ERROR ",GLE())ifnotWriteFile(Pipe,test,4,__written,None):print("ERROR ",GLE())ifpfc()>=t:t=pfc()+1print(Count*4)break
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