Two sittings of bench/run.sh on this tree. muro_plug, Bandit, and
Cowboy serve the same BenchHello.Plug (HTTP/1.1, 200 with body
hello, text/plain). Phoenix mode mounts that Plug on
BenchHello.Endpoint and swaps only the adapter
(MuroPlug.PhoenixAdapter, Bandit.PhoenixAdapter,
Phoenix.Endpoint.Cowboy2Adapter).
The first sitting is the tree before the compile-time inline. The
second is the same script after Mix.Tasks.Compile.MuroStep inlines
the emitted word-sized predicates. lib/muro_plug/step.ex is still the
bytes mix muro.gen writes (body sha256
30fccbe9885cf662357fecda7a915474f2fd74e22eb4ef6e068fba3aba4cbc1d).
HTTP decisions still come from that book.
Machine
| Host | omarzo |
| CPU | Intel Core i7-7820HQ @ 2.90 GHz, 1 socket, 4 cores, 8 threads |
| SMT siblings | 0/4, 1/5, 2/6, 3/7 |
| RAM | 16,214,764 kB (~15.5 GiB) |
| Governor | powersave (/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor). Not changed. |
| Elixir / OTP | 1.20.4 / OTP 29 (erts 17.1) |
| Load generator | oha 1.17.0 (/home/rcc/.local/bin/oha) |
taskset -c 0-3 pins the server. taskset -c 4-7 pins oha. Those are
not two physical cores each: each server thread shares a physical core
with an oha thread (sibling pairs above). Both sides get one SMT thread
of every physical core. The same split was used for an earlier sitting.
The BEAM is started without +S.
The box was shared with other work. Each row records 1-minute loadavg at the start of that case. Absolute req/s move with that load. Compare servers inside one mode, and compare the two sittings only where the load bands match. The first Plug ladder started near load 9–13. The first Phoenix ladder started near 1.6 and climbed toward 7. The second sitting started at load 2.40 and stayed near 5–6.
Packages
From bench/mix.lock, except muro_plug, which is a path dependency
on this tree (0.1.0).
| Package | Version |
|---|---|
| muro_plug | 0.1.0 |
| muro | 0.22.63 |
| bandit | 1.15.0 |
| plug_cowboy | 2.9.0 |
| cowboy | 2.21.0 |
| cowlib | 2.22.0 |
| ranch | 2.4.0 |
| phoenix | 1.8.17 |
| thousand_island | 1.6.0 |
| plug | 1.20.4 |
| hpax | 1.1.0 |
Bandit 1.15.0 HTTP/1 defaults: max_header_count 50,
max_header_length 10_000. Cowboy defaults: 100 headers, header value
4,096 bytes. The dripped request stays under both.
How to run
From bench/, with openssl unnecessary here and no MIX_BUILD_PATH:
bash ./run.sh plug # Plug ladder, then the drip
bash ./run.sh phoenix # Phoenix ladder
bash ./run.sh drip # drip only
MIX_ENV=prod. The script refuses to start when the port is taken.
Default port is 4017 (BENCH_PORT). Duration is 15s (BENCH_Z) after
a 3s warmup (BENCH_WARM).
Server:
MIX_ENV=prod BENCH_SERVER=muro BENCH_MODE=plug BENCH_PORT=4017 \
taskset -c 0-3 mix run --no-halt
BENCH_SERVER is muro, bandit, or cowboy. BENCH_MODE is
plug or phoenix.
oha (HTTP/1.1, keep-alive left on; --disable-keepalive is not
passed). Warmup, then the measured run:
taskset -c 4-7 oha --no-tui --http-version 1.1 \
-c 64 -z 3s --output-format quiet \
http://127.0.0.1:4017/
taskset -c 4-7 oha --no-tui --http-version 1.1 \
-c 64 -z 15s --output-format json \
-o /tmp/plug1-bench/plug-muro-c64.json \
http://127.0.0.1:4017/
The ladder is concurrencies 16, 32, 64, 128. At each concurrency the
script runs muro, then Bandit, then Cowboy. The many-headers case is
the same GET at -c 64 plus 30 headers, x-extra-01 through
x-extra-30, each value 32 h characters.
Every measured response in the tables was status 200 only.
Plug mode, before the inline
Started 2026-11-30T13:04:08-06:00. req/s is oha summary.requestsPerSec.
Latency is summary.average, latencyPercentiles.p50, and p99,
converted from seconds. load is the first field of /proc/loadavg.
| c | server | req/s | avg µs | p50 µs | p99 µs | load | responses |
|---|---|---|---|---|---|---|---|
| 16 | muro_plug | 7,405.51 | 2,156 | 1,950 | 6,901 | 9.52 | 111,093 |
| 16 | Bandit | 13,617.35 | 1,171 | 640 | 5,176 | 10.91 | 204,305 |
| 16 | Cowboy | 11,268.36 | 1,415 | 1,114 | 5,183 | 12.83 | 169,080 |
| 32 | muro_plug | 16,646.78 | 1,918 | 1,818 | 4,850 | 12.58 | 249,719 |
| 32 | Bandit | 36,107.95 | 882 | 823 | 2,273 | 12.24 | 541,930 |
| 32 | Cowboy | 24,635.90 | 1,295 | 1,137 | 4,110 | 11.56 | 369,638 |
| 64 | muro_plug | 19,788.11 | 3,230 | 3,082 | 7,544 | 11.00 | 296,840 |
| 64 | Bandit | 42,324.44 | 1,508 | 1,416 | 3,032 | 9.57 | 635,000 |
| 64 | Cowboy | 22,902.99 | 2,791 | 2,377 | 9,911 | 8.28 | 343,545 |
| 128 | muro_plug | 21,103.07 | 6,062 | 5,685 | 12,763 | 8.80 | 316,502 |
| 128 | Bandit | 41,897.26 | 3,051 | 2,888 | 6,391 | 7.83 | 628,494 |
| 128 | Cowboy | 32,299.49 | 3,959 | 3,594 | 9,974 | 9.28 | 484,474 |
Many headers, c=64:
| server | req/s | avg µs | p50 µs | p99 µs | load | responses |
|---|---|---|---|---|---|---|
| muro_plug | 7,542.64 | 8,481 | 7,765 | 19,908 | 8.07 | 113,101 |
| Bandit | 25,141.44 | 2,541 | 2,354 | 5,397 | 7.41 | 377,125 |
| Cowboy | 15,476.27 | 4,130 | 3,790 | 11,124 | 6.81 | 232,118 |
At c=64 Bandit is 2.14× muro_plug and Cowboy is 1.16×. Thirty extra headers widen that to 3.33× and 2.05×.
Phoenix mode, before the inline
Started 2026-11-30T13:11:16-06:00, finished 13:16:21.
| c | server | req/s | avg µs | p50 µs | p99 µs | load | responses |
|---|---|---|---|---|---|---|---|
| 16 | muro_plug | 23,358.84 | 682 | 655 | 1,185 | 1.64 | 350,424 |
| 16 | Bandit | 44,111.59 | 360 | 356 | 589 | 2.43 | 661,799 |
| 16 | Cowboy | 32,510.18 | 489 | 449 | 1,197 | 3.24 | 487,741 |
| 32 | muro_plug | 21,505.97 | 1,485 | 1,419 | 3,154 | 4.26 | 322,588 |
| 32 | Bandit | 41,788.93 | 762 | 750 | 1,707 | 5.59 | 626,890 |
| 32 | Cowboy | 30,487.60 | 1,046 | 950 | 2,964 | 5.83 | 457,317 |
| 64 | muro_plug | 19,006.14 | 3,364 | 3,182 | 7,746 | 5.81 | 285,084 |
| 64 | Bandit | 37,891.59 | 1,685 | 1,519 | 4,323 | 5.86 | 568,492 |
| 64 | Cowboy | 29,043.18 | 2,199 | 2,021 | 5,548 | 6.64 | 435,796 |
| 128 | muro_plug | 20,846.29 | 6,136 | 5,827 | 13,031 | 7.09 | 312,629 |
| 128 | Bandit | 41,383.11 | 3,089 | 2,869 | 7,275 | 7.76 | 620,769 |
| 128 | Cowboy | 30,518.74 | 4,190 | 3,696 | 11,129 | 7.36 | 457,762 |
Many headers, c=64:
| server | req/s | avg µs | p50 µs | p99 µs | load | responses |
|---|---|---|---|---|---|---|
| muro_plug | 7,711.66 | 8,295 | 7,642 | 18,357 | 7.25 | 115,633 |
| Bandit | 23,020.34 | 2,774 | 2,574 | 7,015 | 6.48 | 345,374 |
| Cowboy | 15,123.85 | 4,226 | 3,938 | 10,186 | 6.47 | 226,839 |
At c=64 Bandit is 1.99× muro_plug and Cowboy is 1.53×. Thirty extra headers widen that to 2.99× and 1.96×.
Phoenix does not beat Plug for muro_plug once load is taken into account. Plug c=64 was 19,788 req/s at load 11.00. Phoenix c=64 was 19,006 req/s at load 5.81. The quiet c=16 Phoenix row (23,359 req/s at load 1.64) against the busy Plug c=16 row (7,406 req/s at load 9.52) is the load difference, not an adapter win.
Dripped request, before the inline
BenchHello.Drip runs in the server VM (taskset -c 0-3,
BENCH_MODE=plug). It is not an oha run. oha's CPU split does not
apply: the client and the server share cores 0–3.
The request is 6,692 bytes. header_count is 42 nonempty lines: the
request line plus 41 header lines. Values are at most 160 bytes, so
the count stays under Bandit's default of 50 headers and Cowboy's
default of 100. A one-shot send of the same bytes is full_red. The
drip sends 64-byte chunks with a 1 ms pause after each chunk (~105
pauses). Eleven drips are taken, the first is dropped, and the median
of the other ten is reported.
Reductions are the sum of Process.info(pid, :reductions) deltas for
every process except the client, taken after the response is fully
read and before :gen_tcp.close/1. Closing first lets the keep-alive
handler exit and drops its reductions.
| server | one-shot reductions | drip median | drip min | drip max | wall µs median |
|---|---|---|---|---|---|
| muro_plug | 30,102 | 402,862 | 402,847 | 408,912 | 212,116 |
| Bandit | 9,601 | 18,429 | 18,119 | 24,185 | 212,010 |
| Cowboy | 15,160 | 32,808 | 32,765 | 34,426 | 211,949 |
Wall time is ~212 ms on all three. That is the client's pause schedule, not server time, so it does not rank the servers.
The hottest process on the largest muro_plug sample had 402,391 of
the 402,862 reductions (proc_lib.init_p/5 initial call, a
gen_server). Bandit's hottest had 17,663 of 18,429, the same shape.
Cowboy's hottest had 32,408 of 32,808 and its initial call was
cowboy_http. The connection process is the cost.
A full buffer already costs muro_plug 3.1× Bandit's reductions (30,102 / 9,601). Dripping the same bytes costs 21.9× (402,862 / 18,429). muro_plug's drip is 13.4× its own one-shot. Bandit's drip is 1.9× its one-shot. Cowboy's is 2.2×. Resuming the header scan parks a cursor, and the book still re-walks the partial block on each chunk. A partial header is not cheap.
What the inline changes
Mix.Tasks.Compile.MuroStep in mix.exs compiles lib/muro_plug/step.ex
again with @compile {:inline, ...} on the word-sized predicates
(u64eq, u8eq, muro__and, muro__or, and the other scan flags).
The emitter writes every helper as an exported function, so the Erlang
compiler leaves those calls in the first beam. The book source stays
the mix muro.gen output, and mix muro.gen --check still passes.
A single-process count on this host (median, the loop's own reductions included) before that compile step and after it:
| path | before | after |
|---|---|---|
one GET, Book.step | 4,221 | 2,176 |
| 30 extra headers | 22,646 | 13,790 |
| carried-cursor drip, same 6,692 bytes | 388,324 | 185,583 |
The bench/run.sh drip below counts the connection process the same
way as the first sitting. It moved with these figures. Bandit's drip
median was 18,429 both times.
The host already stores the parked header cursor across recvs and keeps
one buffer. A trial that cleared the cursor and full-scanned every
chunk was slower: drip median 905,002 reductions, against 388,388 with
the cursor kept. The date header is already cached per second in the
handler process. eprof of 1,500 keep-alive GETs, taken before the
inline, put the time in the generated helpers: port_command 12.95%,
binary:match/2 106,500 calls and 5.98%, u64eq 279,000 calls and
5.59%. binary:compile_pattern/1 ran about twice per request inside
the generated module. muro 0.22.63 has no emit flag that hoists that
pattern.
Plug mode, after the inline
Started 2026-11-30T14:36:05-06:00. Same columns as the first sitting. Every counted response was status 200.
| c | server | req/s | avg µs | p50 µs | p99 µs | load | responses |
|---|---|---|---|---|---|---|---|
| 16 | muro_plug | 26,014.07 | 612 | 578 | 1,143 | 2.45 | 390,250 |
| 16 | Bandit | 44,428.54 | 357 | 347 | 631 | 3.77 | 666,619 |
| 16 | Cowboy | 32,298.81 | 492 | 453 | 1,180 | 4.23 | 484,520 |
| 32 | muro_plug | 24,367.19 | 1,310 | 1,245 | 3,211 | 4.43 | 365,519 |
| 32 | Bandit | 42,434.69 | 751 | 729 | 1,704 | 4.41 | 636,581 |
| 32 | Cowboy | 33,422.39 | 954 | 896 | 2,244 | 4.82 | 501,367 |
| 64 | muro_plug | 24,412.52 | 2,618 | 2,437 | 5,949 | 5.16 | 366,172 |
| 64 | Bandit | 42,776.78 | 1,493 | 1,409 | 3,052 | 5.36 | 641,702 |
| 64 | Cowboy | 32,444.99 | 1,969 | 1,839 | 5,047 | 5.40 | 486,723 |
| 128 | muro_plug | 24,421.32 | 5,238 | 4,897 | 11,944 | 5.57 | 366,289 |
| 128 | Bandit | 43,106.48 | 2,966 | 2,803 | 6,286 | 5.46 | 646,641 |
| 128 | Cowboy | 32,327.86 | 3,956 | 3,609 | 10,228 | 5.35 | 484,943 |
Many headers, c=64:
| server | req/s | avg µs | p50 µs | p99 µs | load | responses |
|---|---|---|---|---|---|---|
| muro_plug | 9,421.27 | 6,788 | 6,206 | 15,062 | 5.03 | 141,276 |
| Bandit | 24,742.10 | 2,582 | 2,489 | 5,719 | 4.88 | 371,125 |
| Cowboy | 15,938.79 | 4,010 | 3,777 | 10,012 | 4.88 | 239,063 |
At c=64 Bandit is 1.75× muro_plug and Cowboy is 1.33×. Thirty extra headers are 2.63× and 1.69×.
The first Plug c=64 row was taken at load 11.00 / 9.57 / 8.28. This row is load 5.16 / 5.36 / 5.40. Bandit stayed flat (42,324 req/s to 42,777). muro_plug went from 19,788 to 24,413. Cowboy went from 22,903 to 32,445 on the quieter box; Bandit's flat row is why that Cowboy jump is the machine, while muro_plug's move is the inline.
Phoenix mode, after the inline
| c | server | req/s | avg µs | p50 µs | p99 µs | load | responses |
|---|---|---|---|---|---|---|---|
| 16 | muro_plug | 25,636.85 | 621 | 592 | 1,272 | 4.65 | 384,635 |
| 16 | Bandit | 39,390.24 | 403 | 363 | 1,124 | 4.81 | 591,041 |
| 16 | Cowboy | 30,015.16 | 530 | 472 | 1,536 | 4.99 | 450,302 |
| 32 | muro_plug | 24,171.02 | 1,320 | 1,220 | 3,097 | 5.70 | 362,592 |
| 32 | Bandit | 39,236.06 | 812 | 731 | 1,987 | 5.72 | 588,652 |
| 32 | Cowboy | 31,038.69 | 1,028 | 939 | 2,823 | 5.41 | 465,611 |
| 64 | muro_plug | 25,144.41 | 2,542 | 2,534 | 5,151 | 5.68 | 377,184 |
| 64 | Bandit | 39,098.53 | 1,633 | 1,465 | 3,808 | 5.24 | 586,631 |
| 64 | Cowboy | 30,820.46 | 2,072 | 1,906 | 5,478 | 5.71 | 462,395 |
| 128 | muro_plug | 24,617.79 | 5,196 | 4,946 | 10,497 | 6.22 | 369,219 |
| 128 | Bandit | 41,794.35 | 3,058 | 2,870 | 6,944 | 5.74 | 627,035 |
| 128 | Cowboy | 32,982.40 | 3,877 | 3,620 | 8,562 | 5.90 | 494,696 |
Many headers, c=64:
| server | req/s | avg µs | p50 µs | p99 µs | load | responses |
|---|---|---|---|---|---|---|
| muro_plug | 9,469.84 | 6,753 | 6,414 | 14,626 | 5.92 | 142,014 |
| Bandit | 24,003.26 | 2,661 | 2,498 | 6,450 | 5.52 | 360,051 |
| Cowboy | 15,570.02 | 4,105 | 3,840 | 10,240 | 5.78 | 233,527 |
At c=64 Bandit is 1.55× muro_plug and Cowboy is 1.23×. Thirty extra headers are 2.53× and 1.64×.
Phoenix c=64 is the oha comparison with a matched load. The first sitting was load 5.81 / 5.86 / 6.64. This one is 5.68 / 5.24 / 5.71. muro_plug went from 19,006 to 25,144 req/s (1.32×). Bandit went from 37,892 to 39,099 (1.03×). Cowboy went from 29,043 to 30,820 (1.06×).
Dripped request, after the inline
Same harness. Bandit's one-shot (9,601) and drip median (18,429) match the first sitting.
| server | one-shot reductions | drip median | drip min | drip max | wall µs median |
|---|---|---|---|---|---|
| muro_plug | 19,245 | 199,595 | 199,548 | 205,023 | 212,065 |
| Bandit | 9,601 | 18,429 | 18,119 | 24,447 | 211,959 |
| Cowboy | 15,083 | 32,783 | 32,483 | 34,400 | 212,096 |
muro_plug's one-shot fell from 30,102 to 19,245, which is 2.0× Bandit (it was 3.1×). The drip fell from 402,862 to 199,595, which is 10.8× Bandit (it was 21.9×). muro_plug's drip is 10.4× its own one-shot. Bandit's is 1.9×. Cowboy's is 2.2×. Wall time is still the client's pause schedule.
The hottest muro_plug process on the largest sample had 199,092 of
199,595 reductions (proc_lib.init_p/5, a gen_server).
What is still slower
Bandit's HTTP/1 reader calls :erlang.decode_packet(:http_bin, ...),
which runs in C. The book still scans a finished header block twice
(scan/1 and hdScan/1), and each of those calls
:binary.compile_pattern/1. A partial header uses scanTail/3, a
byte fold that builds two closures per byte and calls stepB. Inlining
the predicates removes the calls to u64eq and the other word helpers.
compile_pattern and the scanTail closures stay in the generated
module. Putting stepB on the inline list as well moved the
in-process drip from about 186,000 reductions to about 179,000, so
stepB stays a normal call.
At Phoenix c=64 the remaining keep-alive gap is 1.55× Bandit. The dripped header block is still about 11× Bandit's reductions. Both are the book.