Repository navigation
Benchmarks on Apple M5 #280
dex4er
started this conversation in
Benchmarks
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Prefork, Prethread and other Python servers under concurrency
The results of #257, measured with
benchmarks/workers.shof #258 (benchmarks/README.md), in one place.Setup
Pyjo.HelloWorldandPyjoyment.HelloWorldfor Pyjo, the smallest application of each framework for the othersPyjo on
Pyjo.Reactor.Asyncio, the defaultLoad average: 2.33 before, 2.03 after; the spread of the rounds is 1.2% in the median, 5.6% at most.
Pyjo on
Pyjo.Reactor.PollPYJO_REACTOR=Pyjo.Reactor.Poll. Load average: 2.29 before, 1.82 after; the spread of the rounds is 1.4% in the median, 9.4% at most.Pyjo.Reactor.PollagainstPyjo.Reactor.Asyncio, the table above against the one before:The other servers
On CPython 3.15 with the GIL: processes for uvicorn, granian, gunicorn, aiohttp (in the workers of gunicorn) and tornado (
fork_processes), 4 processes with 4 threads each forgunicorn-threads(gthread), and the threads of one process forhttp.serverand the development server of Flask. gunicorn with its sync workers and Flask close the connection after every response, so they have no keep-alive numbers. The last two columns compare a server with Pyjo onPyjo.Server.Preforkon CPython 3.15, on each reactor, at the same mode and number of connections. Load average: 2.32 before, 2.75 after.Observations
Pyjo.Reactor.Pollis faster thanPyjo.Reactor.Asyncioin every scenario: 2-16% on the processes of Prefork and on the threads of the free-threaded Prethread, 27-45% on the threads of Prethread with the GIL; the layer of asyncio between the reactor and the selector is Profiling: reactor Asyncio vs Poll and the cost of a request in Pyjo #129.Pyjo.Reactor.Asyncioand 49141 onPyjo.Reactor.Poll, against 45192 and 43839. The servers with a parser in C or Rust, granian, aiohttp and uvicorn with uvloop and httptools, make 81-103 thousand.gunicorn-threads,http.serverand the development server of Flask, stays at 4-11 thousand at any number of connections.PyPy
A shorter look at PyPy 3.12 (PyPy 8.0.0 of uv) against CPython 3.15, with keep-alive only:
Pyjo.Server.Daemon, one process, andPyjo.Server.Preforkwith 4 workers, on both reactors, at 1, 4 and 16 connections, after a warmup of 20000 requests, which the JIT needs, 2 rounds of 5 seconds. Every request succeeded, and the workers of PyPy did not crash after their fork on macOS. Load average: about 1.7 at the start of each run and 5 at its end, mostly the benchmark itself. The daemon gave the same in both rounds, so its numbers are the averages of the rounds; Prefork lost up to 30% in the second round of both runs, of a cause not measured yet, so its numbers are those of the first round.Pyjo.Server.DaemonPyjo.Server.Prefork, 4 workersPyjo.Reactor.Pollgains on PyPy about what it gains on CPython, 7-19% on the daemon: the JIT handles the pure Python of asyncio well.Pyjo.Reactor.Pollon Prefork makes 80989 with Pyjo at 16 connections, as uvicorn with uvloop and httptools above, and twice CPython 3.15 withPyjo.Reactor.Asyncio, the default.All reactions