-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Recreate uvloop, aiofiles and fetch using CFFI or HPy #18
Comments
Asyncio support for now is a mess see #11, works using workarounds instead of an fully integration with libuv Windows status for uvloop: MagicStack/uvloop#14 Also aiofiles or aiofile is really slow in PyPy3 using libuv for io should solve this issue. The performance hit with the current asyncio solution is 50% (not acceptable) |
Removing asyncio workarounds we get a performance boost from 770k to 880k req/s still much lower than 1.3 million req/s, i will do some performance checks in older version but at first seems that having a bigger Response and Request object with more functions is impacting performance (but we need all this features), so we will integrate all features first, measure the impact again, integrate your own aiofiles and fetch API with libuv and after this i will start an "uvloop" like project to fully integrate asyncio with libuv, removing the workarounds. Giving it at least 12% to 30% more raw performance. Adding Http3 will improve much more performance than replacing the workaround right now, and its way less effort for some one like me that is working only a few hours per week in this project (until i get support). Migration to HPy in future will bring Python3 performance up a lot. |
Compiling an static version of curl for cross platform async http requests with libuv using an similar interfacee that fetch API import json
from socketify import fetch
options = {
'method': 'POST',
'headers': {
'Content-Type': 'application/json',
},
'body': json.dumps(data).encode("utf-8")
}
response = await fetch("https://example.com/profile", options)
print(response.json())
response = await fetch("http://example.com/movies.json")
print(response.text()) |
Implementing an experimental, SelectorEventLoop for macOS or Linux is the next step |
implement SelectorEventLoop using libuv and HPy and also check if rewriting the whole asyncio will give the async performance boost that we need. Custom Task in HPy will be needed too target 900k req/s with CPython async Today numbers: We need HPy or Cython to compete with japronto and vibora in CPython, in PyPy we are already faster in sync and async than japronto. Neither japronto or vibora supports PyPy because of uvloop dependency. CFFI really hurts performance in CPython. wrk -H "Host: tfb-server" -H "Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,/;q=0.7" -H "Connection: keep-alive" --latency -d 5 -c 4096 --timeout 8 -t 8 http://localhost:8000/ -s pipeline.lua -- 16 |
I am getting some serious slow down with async request handlers:
pypy latest 3.9 Darwin arm64 To avoid drivers, libraries, cffi and other stuff, I have tested this with a GQL query that just returns an empty list and I am using the graphiql helper in the docs. 1 socketify process benchmarksSYNC performance: ~5ms Is this a known problem? Update: |
We use native async in both PyPy and CPython only socketify itself uses libuv internally (only in C/C++ not in python) |
Here is the issue tracking the strawberry problem: |
uvloop dont support windows, this library have libuv static linked on windows so... we can support windows with no problem
The text was updated successfully, but these errors were encountered: