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

Hostomarzo
CPUIntel Core i7-7820HQ @ 2.90 GHz, 1 socket, 4 cores, 8 threads
SMT siblings0/4, 1/5, 2/6, 3/7
RAM16,214,764 kB (~15.5 GiB)
Governorpowersave (/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor). Not changed.
Elixir / OTP1.20.4 / OTP 29 (erts 17.1)
Load generatoroha 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).

PackageVersion
muro_plug0.1.0
muro0.22.63
bandit1.15.0
plug_cowboy2.9.0
cowboy2.21.0
cowlib2.22.0
ranch2.4.0
phoenix1.8.17
thousand_island1.6.0
plug1.20.4
hpax1.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.

cserverreq/savg µsp50 µsp99 µsloadresponses
16muro_plug7,405.512,1561,9506,9019.52111,093
16Bandit13,617.351,1716405,17610.91204,305
16Cowboy11,268.361,4151,1145,18312.83169,080
32muro_plug16,646.781,9181,8184,85012.58249,719
32Bandit36,107.958828232,27312.24541,930
32Cowboy24,635.901,2951,1374,11011.56369,638
64muro_plug19,788.113,2303,0827,54411.00296,840
64Bandit42,324.441,5081,4163,0329.57635,000
64Cowboy22,902.992,7912,3779,9118.28343,545
128muro_plug21,103.076,0625,68512,7638.80316,502
128Bandit41,897.263,0512,8886,3917.83628,494
128Cowboy32,299.493,9593,5949,9749.28484,474

Many headers, c=64:

serverreq/savg µsp50 µsp99 µsloadresponses
muro_plug7,542.648,4817,76519,9088.07113,101
Bandit25,141.442,5412,3545,3977.41377,125
Cowboy15,476.274,1303,79011,1246.81232,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.

cserverreq/savg µsp50 µsp99 µsloadresponses
16muro_plug23,358.846826551,1851.64350,424
16Bandit44,111.593603565892.43661,799
16Cowboy32,510.184894491,1973.24487,741
32muro_plug21,505.971,4851,4193,1544.26322,588
32Bandit41,788.937627501,7075.59626,890
32Cowboy30,487.601,0469502,9645.83457,317
64muro_plug19,006.143,3643,1827,7465.81285,084
64Bandit37,891.591,6851,5194,3235.86568,492
64Cowboy29,043.182,1992,0215,5486.64435,796
128muro_plug20,846.296,1365,82713,0317.09312,629
128Bandit41,383.113,0892,8697,2757.76620,769
128Cowboy30,518.744,1903,69611,1297.36457,762

Many headers, c=64:

serverreq/savg µsp50 µsp99 µsloadresponses
muro_plug7,711.668,2957,64218,3577.25115,633
Bandit23,020.342,7742,5747,0156.48345,374
Cowboy15,123.854,2263,93810,1866.47226,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.

serverone-shot reductionsdrip mediandrip mindrip maxwall µs median
muro_plug30,102402,862402,847408,912212,116
Bandit9,60118,42918,11924,185212,010
Cowboy15,16032,80832,76534,426211,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:

pathbeforeafter
one GET, Book.step4,2212,176
30 extra headers22,64613,790
carried-cursor drip, same 6,692 bytes388,324185,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.

cserverreq/savg µsp50 µsp99 µsloadresponses
16muro_plug26,014.076125781,1432.45390,250
16Bandit44,428.543573476313.77666,619
16Cowboy32,298.814924531,1804.23484,520
32muro_plug24,367.191,3101,2453,2114.43365,519
32Bandit42,434.697517291,7044.41636,581
32Cowboy33,422.399548962,2444.82501,367
64muro_plug24,412.522,6182,4375,9495.16366,172
64Bandit42,776.781,4931,4093,0525.36641,702
64Cowboy32,444.991,9691,8395,0475.40486,723
128muro_plug24,421.325,2384,89711,9445.57366,289
128Bandit43,106.482,9662,8036,2865.46646,641
128Cowboy32,327.863,9563,60910,2285.35484,943

Many headers, c=64:

serverreq/savg µsp50 µsp99 µsloadresponses
muro_plug9,421.276,7886,20615,0625.03141,276
Bandit24,742.102,5822,4895,7194.88371,125
Cowboy15,938.794,0103,77710,0124.88239,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

cserverreq/savg µsp50 µsp99 µsloadresponses
16muro_plug25,636.856215921,2724.65384,635
16Bandit39,390.244033631,1244.81591,041
16Cowboy30,015.165304721,5364.99450,302
32muro_plug24,171.021,3201,2203,0975.70362,592
32Bandit39,236.068127311,9875.72588,652
32Cowboy31,038.691,0289392,8235.41465,611
64muro_plug25,144.412,5422,5345,1515.68377,184
64Bandit39,098.531,6331,4653,8085.24586,631
64Cowboy30,820.462,0721,9065,4785.71462,395
128muro_plug24,617.795,1964,94610,4976.22369,219
128Bandit41,794.353,0582,8706,9445.74627,035
128Cowboy32,982.403,8773,6208,5625.90494,696

Many headers, c=64:

serverreq/savg µsp50 µsp99 µsloadresponses
muro_plug9,469.846,7536,41414,6265.92142,014
Bandit24,003.262,6612,4986,4505.52360,051
Cowboy15,570.024,1053,84010,2405.78233,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.

serverone-shot reductionsdrip mediandrip mindrip maxwall µs median
muro_plug19,245199,595199,548205,023212,065
Bandit9,60118,42918,11924,447211,959
Cowboy15,08332,78332,48334,400212,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.