Benchmarks
m0serve against uvicorn and Granian: where it wins, where it loses, and how the numbers were taken.
Every table renders from a dated, environment-stamped artifact in
bench/results/, and the prose recomputes its
figures from the same artifacts. A figure that no artifact backs carries
an observed: marker in the page's source.
m0serve ties Granian on bare WSGI. On bare ASGI it serves more requests per second than uvicorn, and about as many per core as uvloop. Its clearest lead is the tail: a fast request stays fast while slow work is in flight.
How to read this page
- Compare rows inside one table. Identical binaries move ~1.5x in absolute rps across sessions on this hardware, from thermal and load state alone. Whether a ratio holds on Linux is under What this page does not measure.
- Each table's
corescolumn is sampled%cpuof the pids on the listen socket. A comparator run as--workers 1uses ~1.80 cores across its runtime's I/O threads, and rps/core corrects for it. - The box has performance and efficiency cores (Apple M4, 4P + 6E), and an E-core serves this workload 4.4x slower (18.6k rps against a P-core's 81.7k, measured by pinning a worker to background QoS). Per-core rows are comparable only where server plus load generator fit in the P-cores: 1 and 2 workers. The 4-worker rows measure the scheduler.
- An explicit
--workers Nturns the zero-config handler pool off, so every row names its handler threads. - Every table renders from the newest committed artifact. CI refuses an
artifact that lacks a version stamp, was recorded on a dirty tree, or is
more than one minor version behind
pyproject.toml. Each table's Environment line names its Python; the slow-view table is on free-threaded 3.14t because its--threadsrows need that build. - Each wrk figure is a median across rounds, because one round per run
lands well off the others; each artifact records the rounds behind
every row. The medians of three recorded runs agree to within 0.03 on
the per-core ratio. The fast-request tail table is one run of
scripts/bench_asgi.py.
The comparators are Granian, at the version each table's Environment line names, and uvicorn, both run with their own recommended settings, and every row is a single process unless the label says otherwise. Where a comparator wins, the row stays.
The short version
| question | answer |
|---|---|
| Fastest on bare WSGI? | A tie — one worker and one handler thread each, Granian to m0serve is ~0.98x per core and 1.00x in requests per second, inside the spread between recordings, which have put each of the two a few percent ahead in turn. On Linux m0serve leads this row: 1.11x Granian in requests per second in the aarch64 container at 1.17.0, and 1.04x on rented x86-64 hardware on 2026-10-06 |
| Fastest on bare ASGI? | In requests per second, yes: 1.63x uvicorn with uvloop (what pip install uvicorn[standard] runs) and 2.28x uvicorn --loop asyncio at 16 connections, the executor's two threads using 1.6 cores where uvicorn has one. Per core against uvloop, about level on this box: 0.98x, the second thread buying throughput rather than efficiency. On Linux the default is a little behind per core, 0.91x in a container and 0.94x on rented x86-64 hardware, and the one-thread loop (M0_INVERTED=1) is the per-core answer: 1.31x uvloop on this box, 1.42x in the container and 1.27x on the rented box, at 16 connections, where it also serves more than the default on Linux and less on this box. Against --loop asyncio the executor leads per core by ~1.37x everywhere measured |
| Fastest fast-request tail under mixed load? | Yes against uvicorn --loop asyncio: p99 ahead in every recorded run. uvloop is not in this bench. |
The HTTP layer, and the bridge
Splitting the server into the part that parses HTTP and the part that calls Python prices each layer:
Source: layer-split-20261106T212053Z.json — 2026-11-06T21:20:53+00:00, commit 5f069aec.
Environment: Python 3.14.7; granian 2.8.7; Apple M4 (10 cores: 4P+6E); 16 GB; macOS 27.0.1 (26A434); AC Power; wrk -c16 -d10s, 3 rounds, medians.
| row | rps | cores | rps/core |
|---|---|---|---|
apps/hello — mojo-http HTTP layer, zero Python |
229,872 | 0.99 | 232,193 |
m0serve + bare WSGI, 1 worker, app inline on the loop (no handler thread) |
129,065 | 0.99 | 130,369 |
m0serve + bare WSGI, 1 worker, 1 handler thread |
197,699 | 1.77 | 111,694 |
granian + bare WSGI, 1 worker, 1 blocking thread |
196,925 | 1.80 | 109,403 |
m0serve + bare WSGI, zero-config (what m0serve app.wsgi runs) |
198,377 | 1.77 | 112,078 |
m0serve + bare WSGI, 4 workers, 1 handler thread each |
155,321 | 4.60 | 33,765 |
granian + bare WSGI, 4 workers, 1 blocking thread each |
153,491 | 4.05 | 37,899 |
Cores: sampled %cpu of the pids on the listen socket.
The one-worker rows:
- the HTTP layer with no Python at all (
apps/hello) runs at 232.2k rps/core, above Granian's end-to-end 109.4k - the same bare WSGI application run inline on that loop, one thread, runs at 130.4k rps/core, so the bridge costs 1.78x
- give the worker one handler thread, Granian's shape, and m0serve serves 197.7k rps on 1.77 cores against Granian's 196.9k on 1.80: 1.02x per core, 1.00x in throughput
- zero-config, what
m0serve app.wsgiruns, serves 198.4k rps on a pool of eight handler threads
What the split prices is the bridge: the 1.78x on the inline row is m0serve's own. Rps per core averages two threads that do different work, so it cannot say which thread bounds the one-handler-thread row. Measured per thread, the loop thread costs what Granian's tokio thread does per request (notes/loop-thread-bound.md, notes/loop-user-space.md), and the two rows are 0.4 % apart in throughput. The bridge itself, the environ build and the response read, was cheaper per request than Granian's PyO3 crossing in every per-thread measurement. Bridge work was never the lever.
This table cannot say how much Granian's own bridge costs, because there is no Granian-without-Python row to divide by. Per thread it can be read off a profile, and the loop-thread note does that for both servers' Python threads. Quoting the hello row against Granian would be comparing a server that runs no Python to one that does. The row prices the bridge.
ASGI throughput
apps/asgi_bare under wrk with browser-shaped headers, byte parity
asserted between the two responses, single process each:
Source: asgi-wrk-hello-20261119T074508Z.json — 2026-11-19T07:45:08+00:00, commit 55606c80.
Environment: Python 3.14.7; Apple M4 (10 cores: 4P+6E); 16 GB; macOS 27.2.1 (26B131); AC Power; wrk -t2 -c16 -d8s, browser headers; executor loop: uvloop.
| row | rps | cores | rps/core |
|---|---|---|---|
m0serve — zero-config executor (its loop is stamped above) |
140,267 | 1.65 | 85,010 |
uvicorn --loop asyncio |
61,526 | 0.99 | 62,148 |
uvicorn with uvloop — what pip install uvicorn[standard] runs by default |
86,063 | 0.99 | 86,932 |
Cores: sampled %cpu of the pids on the listen socket.
The loop holds no thread state while it serves
(notes/detached-loop.md), so its parsing and
writing overlap the executor's Python, and this row runs at
1.65 cores:
2.28x uvicorn --loop asyncio
and 1.63x uvicorn with uvloop in
requests per second, 1.37x
and 0.98x per core. The
executor can use two cores, and uvicorn one. The 2026-08 concurrency
tables and the loop-by-loop comparison are in
The ASGI executor against uvicorn.
Fast-request tail under mixed load
The measurement the executor exists for: how fast is a fast request while
slow ones are in flight. Four threads measure / while two hammer
/slow?ms=200. The comparator is uvicorn --loop asyncio.
Source: asgi-executor-20261119T074545Z.json — 2026-11-19T07:45:45+00:00, commit 55606c80.
Environment: Python 3.14.7; Apple M4 (10 cores: 4P+6E); 16 GB; macOS 27.2.1 (26B131); AC Power; seconds=8, threads=8.
| server | rps | fast p50 | fast p99 | errors |
|---|---|---|---|---|
m0serve — asyncio executor |
29,012 | 143 µs | 356 µs | 0 |
uvicorn |
22,853 | 182 µs | 406 µs | 0 |
Fast-request latency is measured while slow requests are in flight; rps and the two percentiles come from the same run, so they trade against each other rather than being separately optimised rows.
The fast-request p99 is ahead of uvicorn's in every recorded run. Awaits overlap on the loop, and the Mojo acceptor never runs application code. This bench records no cores column; the wrk rows above say the executor uses 1.6 cores where uvicorn uses one, and that is where the p50 came from.
The await-concurrency underneath is unambiguous in a way the percentiles are not: eight concurrent 1.5 s awaits complete in 1.51 s on one loop with zero threads, where the buffered bridge takes 12 s.
Slow-view isolation
A synchronous view that blocks holds the connections pinned to its event
loop; --blocking-threads N puts a pool of handler threads behind each
loop so it stops doing that.
Read the first two rows across, then the next two. Without the pool the fast-route p99 climbs from 0.6 ms to 195 ms as slow views are added, most of the 200 ms hold. With the pool it stays at 1.4 ms. That is a 144x change. Prefork and threads fail the same way and are fixed the same way.
Source: mixed-workload-20261119T080649Z.json — 2026-11-19T08:06:49+00:00, commit 55606c80.
Environment: Python 3.14.7 free-threading build; granian 2.8.8; Apple M4 (10 cores: 4P+6E); 16 GB; macOS 27.2.1 (26B131); AC Power; wrk -c16 -d10s, 3 rounds, medians.
| configuration | slow=0 | slow=1 | slow=2 |
|---|---|---|---|
--workers 4 |
0.6 ms (0.6–0.6) | 190.2 ms (189.4–191.0) | 195.0 ms (194.6–197.1) |
--threads 4 |
0.7 ms (0.7–0.7) | 192.9 ms (191.9–194.9) | 199.5 ms (198.4–199.7) |
--workers 4 +bt=4 |
1.4 ms (1.4–1.4) | 1.4 ms (1.4–1.4) | 1.4 ms (1.3–1.5) |
--threads 4 +bt=4 |
1.0 ms (0.9–1.2) | 0.9 ms (0.8–0.9) | 0.9 ms (0.9–1.0) |
--workers 1 +bt=4 |
0.5 ms (0.5–0.5) | 0.4 ms (0.4–0.4) | 0.5 ms (0.5–0.5) |
granian bt=4 |
0.5 ms (0.5–0.6) | 0.5 ms (0.5–0.5) | 0.5 ms (0.5–0.5) |
Fast-route p99 as concurrent slow requests are added: the median across 3 rounds, with the min–max across those rounds in parentheses. A row that stays flat isolated the slow work; a row that climbs toward the slow view's hold time had its connections stranded behind it. Both halves run in one pass, because a control that stops failing has stopped measuring anything.
Granian's own --blocking-threads is the architecture this feature
follows, and its row is one worker with a pool of four. The --workers 4
and --threads 4 rows are four loops with a pool of four each, so the
--workers 1 +bt=4 row is the like-for-like comparison. The four-loop
rows carry four processes' worth of parallel Python threads beside the
client on one ten-core laptop. The keep-alive cap is
--max-keepalive-requests (RUNNING.md
says how it reaches a client's tail, and
notes/pool-tail.md has the A/B).
A compressed stream
DatastarStream.open(compress=True) (SPEC I45) sends a stream in zstd
when its request accepts zstd, one context per subscriber. It was measured by
scripts/bench_hello_ab.py, and by scripts/bench_blobs_modes.py with
--arms before,loop,loop+zstd on the blobs demo's image, pinned to one
core. The artifacts are in
bench/results/zstd-stream-2026-10/,
and the tables are in
notes/compressing-a-stream.md.
- A server that compresses nothing did not move:
apps/hellobuilt before the binding and after, interleaved over six rounds on performance cores, served 1.002x the requests per second (0.99 to 1.01 by round) on the same cores. - An uncompressed stream did not move either: blobs before and after, at 1, 10, 100 and 400 viewers, used 0.93 to 1.00x the CPU and delivered every frame.
- Compressed, blobs's whole-state frames go 3.42:1, 23.1 kB/s a viewer down to 6.75, at every count.
- Compression costs a loop more than the ratio suggests. At 100 and 400 viewers on one core it took 2.6 to 2.7 times the loop's CPU and 160 KB a stream. Beside 400 compressed streams a fast request's p99 was 20.5 ms, against 5.0. Natively, on a performance core, a push costs about 14 µs, where one hot context takes 5. Each subscriber's context is cold by its next frame.
- On Fly's shared-cpu-1x x86, each compressed viewer cost about 12 times a plain one, about 120 µs a push. 150 compressed viewers took 21 % of a core, and 400 plain ones took 6 %.
- A stream that repeats its markup compresses much further: a Datastar game's seat, captured for 240 s with its own tools, reached the page at 25.1:1, 3.03 MB in 121 KB. Its bytes decoded to the plain capture exactly.
What this page does not measure
- m0serve has neither TLS nor HTTP/2; terminate at a proxy, as gunicorn does. A comparison against servers that have them would be measuring the proxy.
- Every row above serves a bare handler, because a Django view's own work
dominates and would hide the server difference entirely. That cuts both
ways: it makes these gaps visible, and it makes them a smaller fraction
of any real request than they look here. Two framework rows, FastHTML
and Django ASGI at
/, were re-measured on 2026-11-16. They are in WSGI_PERFORMANCE.md ("Framework rows"). - Every
artifact on this page is macOS arm64; CI builds and smoke-tests Linux
x86-64 and aarch64, and the benchmark box is one machine.
uv run poe bench-linux-conclusionsre-measures the page's conclusions on Linux before each release, and on 1.17.0 all of them held in direction. Two differ in size there: bare WSGI leans to m0serve, and the ASGI default is further behind uvloop per core. The short version gives both figures, and the note has the tables and the per-arm spreads.
Reproducing
Each table's artifact comes from one script, run on a clean checkout with nothing else busy on the machine:
| table | recorded on | run |
|---|---|---|
| The HTTP layer, and the bridge | the default venv, Granian from uv sync --group bench |
scripts/bench_layer_split.sh, with apps/hello built to /tmp/bench_hello_server |
| ASGI throughput | the default venv | poe bench-asgi-wrk |
| Fast-request tail under mixed load | the default venv | poe bench-asgi |
| Slow-view isolation | free-threaded 3.14t, poe py314t-try |
scripts/bench_mixed_workload.sh |
The prerequisites, the swap's rules, and the procedures for that page's own tables are in WSGI_PERFORMANCE.md.
After recording a new artifact, uv run poe render-bench-docs rewrites
the tables.