Internals: benchmark reports

Compression on xeon: mode off, static and all against nginx gzip (2026-11-15)

The measurement of the ScalPanel plan’s Task 6 (design “Cost when off, measured”): what response compression costs when it is off, and how ScalWS’s static and all modes compare with nginx’s gzip module.

Method

bench/compression.sh <scalwsd> <base-scalwsd> <out-dir> (the script’s header has every detail).

  • Host: 2x Xeon E5-2650 v2 (no AVX2), Ubuntu 26.04, kernel 7.0.0-38, no VM running.
  • Server on CPU 0 (1 CPU layout) or CPUs 0-5 (6 CPU layout), socket 0; PHP-FPM 8.5.4 (one external pool for both servers, static, 8 children) on 6, 7, 22, 23; oha 1.16.0 on 8-15 and 24-31 (socket 1), 64 connections, 5 s warm-up and 15 s measured per row, 3 rounds with the server order rotated; medians, ratios are the median of the per-round ratios.
  • ScalWS: tools/pgo-build.sh with PGO_FEATURES=scalwsd/http3, commit 99e4900 (this task). Base: the same build of f19987c, the v1.1 branch before compression (Task 4). Both with open_file_cache: {max_entries: 0} and the access log off, as nginx.
  • nginx 1.31.6 (built from source with gzip_static; no 1.30 build is installed on xeon, 1.31.6 is the release every 1.0 ratio was taken against) with bench/configs/nginx-gzip.conf: gzip on; gzip_comp_level 1; gzip_min_length 1024; gzip_types <ScalWS's static types>; gzip_vary on; gzip_static on;, no .gz files present. nginx has no brotli module: for Accept-Encoding: br, gzip it sends gzip.
  • Files: a 100 KiB CSS and a 20 KiB HTML page generated from a fixed seed, a 300 KiB JS (jQuery 3 unminified, repeated to 300 KiB), text files of 1 KiB and 100 KiB for part (a), a PHP hello page and a PHP page that sends a 50 KiB HTML file.

What the modes do in these rows: with static, ScalWS compresses a file once at the cached levels (gzip 6, brotli 5) and serves the variant from memory afterwards; nginx compresses every response at level 1 (gzip_static only helps with precompressed files on disk). With all, both compress the PHP page while it streams, at level 1.

Results (run 1, 21:58 to 22:39 local time)

(a) mode off against the build before compression (gate: >= 0.98)

CPUsscenarioscalws-off rpsbase-off rpsratio (median, min-max)scalws-off p99 msbase-off p99 msscalws-off bytes/respbase-off bytes/respencodinggate
1php-hello13417132131.013 (1.009-1.030)5.145.221313identityPASS
1static-100k511352320.977 (0.975-0.995)31.0530.68102400102400identityFAIL
1static-1k13259134020.989 (0.977-1.017)11.3010.9610241024identityPASS
6php-hello29918298741.001 (1.001-1.002)3.123.111313identityPASS
6static-100k33703338860.995 (0.993-1.005)3.754.00102400102400identityPASS
6static-1k81012818840.991 (0.979-1.000)1.741.5210241024identityPASS

(b) mode static against nginx gzip_comp_level 1 + gzip_static (gate at 1 CPU: >= 1.05)

CPUsscenarioscalws-static rpsnginx rpsratio (median, min-max)scalws-static p99 msnginx p99 msscalws-static bytes/respnginx bytes/respencodinggate
1css-100k-br96389849.858 (9.720-10.122)14.8065.751703121744br/gzipPASS
1css-100k-gzip1001098310.189 (10.169-10.461)14.8465.811669421744gzipPASS
1html-20k-br1022027553.725 (3.648-3.835)14.0523.6062367193br/gzipPASS
1html-20k-gzip1059227553.857 (3.792-3.958)13.4223.6264707193gzipPASS
1js-300k-br718618838.206 (37.566-38.601)20.493574.1579667111126br/gzipPASS
1js-300k-gzip709218937.746 (36.996-38.071)20.953572.4791849111126gzipPASS
6css-100k-br59904591610.144 (10.093-10.165)1.9615.571703121744br/gzipreport (>= 1.0)
6css-100k-gzip62707591510.602 (10.588-10.686)1.8514.441669421744gzipreport (>= 1.0)
6html-20k-br63260164293.851 (3.832-3.875)1.804.7862367193br/gzipreport (>= 1.0)
6html-20k-gzip66231164414.016 (3.984-4.061)1.985.5564707193gzipreport (>= 1.0)
6js-300k-br44255112139.481 (39.276-39.745)2.6959.8679667111126br/gzipreport (>= 1.0)
6js-300k-gzip43717112039.080 (38.788-39.233)2.7459.9991849111126gzipreport (>= 1.0)

(c) mode all, 50 KiB PHP page, against nginx gzip on over FastCGI (gate at 1 CPU: >= 1.05)

CPUsscenarioscalws-all rpsnginx rpsratio (median, min-max)scalws-all p99 msnginx p99 msscalws-all bytes/respnginx bytes/respencodinggate
1php-50k-gzip181811721.550 (1.548-1.571)36.2455.702310517259gzipPASS
6php-50k-gzip712947301.761 (1.507-1.821)12.0015.692310517259gzipreport (>= 1.0)

Non-2xx answers over all rows: 0.

Every row of run 1 is at or above its gate except (a) 1 CPU static-100k, 0.977 (per-round 0.975 to 0.995), below the 0.98 line by 0.3 %.

Re-measurement of the row below the gate

Part (a) at 1 CPU again (23:39 to 23:52 local time), 5 rounds of 20 s, the same binaries, under the xeon bench lock (/var/tmp/XEON_BENCH, no cargo or rustc running). A first attempt of this re-run (around 23:12) is discarded: another agent’s tests held 127.0.0.1:9901, the metrics port the bench configuration uses by default, so the server did not start.

(a) mode off against the build before compression (gate: >= 0.98)

CPUsscenarioscalws-off rpsbase-off rpsratio (median, min-max)scalws-off p99 msbase-off p99 msscalws-off bytes/respbase-off bytes/respencodinggate
1php-hello13448133801.001 (0.998-1.015)5.125.141313identityPASS
1static-100k552555960.996 (0.960-1.010)29.9529.56102400102400identityPASS
1static-1k13036133360.985 (0.921-0.988)5.4310.5410241024identityPASS

Non-2xx answers over all rows: 0.

All three rows pass. The 100 KiB row moved from 0.977 to 0.996 with nothing changed: its spread (0.960 to 1.010 per round here) is wider than the 2 % gate, so run 1’s value is noise. Nothing in the off path of this task touches the static handler: with compression absent the pipeline pays one Option test when the application is routed and one in finish, and pipeline_cost counts the same allocations per request as before (below). The static and php rows of pipeline_cost allocate about 1.3 KiB more bytes per request (same count) since Task 5 (a larger future of the static handler); that is Task 5’s and did not show here.

pipeline_cost (cargo test --release -p scalws-server pipeline_cost -- --ignored, allocations per request / bytes per request):

rowf19987c (before Task 4)ea0c445 (Task 5)99e4900 (this task)
proxy22.0 / 759322.0 / 759322.0 / 7593
respond15.0 / 523215.0 / 523215.0 / 5232
static (1 KiB file, new row)17.0 / 663217.0 / 792817.0 / 7960
php (PHP-FPM page, new row)29.0 / 861129.0 / 990729.0 / 9939
respond+cache15.0 / 523215.0 / 523215.0 / 5232
respond+cloudflare15.0 / 523215.0 / 523215.0 / 5232
respond+trusted18.0 / 529218.0 / 529218.0 / 5292

Findings

  • Mode off: within the 2 % gate at 1 and 6 CPUs (run 1 at 6 CPUs, the re-run at 1 CPU).
  • Mode static: 3.7x to 38x nginx at 1 CPU and 3.9x to 39x at 6 CPUs. The difference is the method, not the encoder: ScalWS compresses each file once (gzip 6, brotli 5) and serves the variant from memory, so it also sends fewer bytes (CSS 16.7 KB gzip / 17.0 KB br against nginx’s 21.7 KB; JS 91.8 / 79.7 KB against 111.1 KB); nginx compresses every response at level 1. nginx at 1 CPU with the 300 KiB JS reaches 189 requests per second and a p99 of 3.6 s; ScalWS 7 092 and 21 ms.
  • Inline fills (Task 5 review): rows (b) do not measure them. The curl that checks the encoding before each row and the warm-up fill the cache, so the measured window has cache hits only. Fills are measured separately in part (f) below (fix round 1).
  • Mode all: 1.55x nginx at 1 CPU and 1.76x at 6 CPUs for the 50 KiB PHP page. ScalWS’s responses are larger, 23.1 KB against nginx’s 17.3 KB, at the same nominal level 1. The likely cause is zlib-rs’s level 1, the fast “quick” strategy of zlib-ng, which compresses less than zlib’s level 1 (ScalWS also sync-flushes when PHP’s output pauses). Streaming gzip at level 2 would likely close most of the byte gap for some speed; not changed here, since every row is above its gate. Fix round 1 tried level 2: see below.
  • No non-2xx answer in any row.

Fix round 1 (2026-11-16): inline fills, streaming gzip level 2

Same host and method; PGO builds of the fix-round tree. Taken under the xeon bench lock (/var/tmp/XEON_BENCH, no cargo or rustc running), FORCE=1 (the load average of idle sessions stays near 2.7 on xeon).

(c) at streaming gzip level 2 (01:39 UTC)

CPUsscalws-all rpsnginx rpsratio (median, min-max)scalws p99 msnginx p99 msscalws bytes/respnginx bytes/resp
1134111751.138 (1.138-1.141)48.9355.191661417259
6604445971.308 (1.210-1.452)13.0717.171661417259

Level 2 sends 28 % fewer bytes than level 1 (16.6 KB against 23.1 KB, now below nginx’s 17.3 KB), but throughput at 1 CPU drops from 1.55x to 1.14x nginx. That is under the 1.2x the controller set as the condition for keeping it, so streaming gzip stays at level 1 (rows (c) of run 1 stand). The ETag suffix is now derived from the encoder’s level (Level::level), so a later level change cannot keep an old suffix.

(f) inline fills (new part)

4 connections fetch random ones of 1000 distinct 60 KiB CSS files with a variant cache of 1 byte, so every one of their requests compresses the file (gzip 6 or brotli 5) and nothing is kept; 60 connections fetch the 1 KiB file as identity at the same time. Against the same load with compression off. Server on CPU 0, 3 rounds of 15 s.

Inline limit 64 KiB for both codings (01:44 UTC):

scenariofill rpsoff rpsfill p50 msoff p50 msfill p99 msoff p99 msp99 ratio (median, min-max)
background, br fills6278120747.644.9724.8010.682.341 (2.247-2.553)
br fill load24280117.324.9734.4610.723.237 (3.102-3.286)
background, gzip fills7665120626.184.9719.8510.661.817 (1.816-1.895)
gzip fill load29680313.874.9628.7210.812.657 (2.583-2.780)

Brotli inline limit lowered one step, to 32 KiB, so these 60 KiB brotli fills run on the blocking pool (02:40 UTC):

scenariofill rpsoff rpsfill p50 msoff p50 msfill p99 msoff p99 msp99 ratio (median, min-max)
background, br fills6362120327.595.0024.5110.832.264 (2.253-2.282)
br fill load24279817.084.9933.9310.743.124 (3.121-3.176)
background, gzip fills7866118856.005.0119.4610.851.809 (1.779-1.809)
gzip fill load29979013.835.0028.2710.762.637 (2.615-2.660)

No non-2xx answer. (A first part (f) run at 23:09 UTC is discarded: its file URLs were not generated as intended (404) and oha’s default Accept-Encoding made the background compressed too.)

What this shows:

  • A steady stream of fills at 1 CPU raises the p99 of other requests on that CPU by 1.8x (gzip) to 2.3x (brotli), well over the 1.10x line set for this row. Each 60 KiB fill costs roughly 3 ms (gzip 6) to 4 ms (brotli 5) of CPU, and 240 to 300 of them a second take most of the core.
  • Where the fill runs makes no measurable difference at 1 CPU: with brotli fills moved from the event loop to the blocking pool, the background p99 went from 2.34x to 2.26x, inside the round spread. Both threads share the one CPU, so the cost is the CPU time, not the place. With more CPUs the blocking pool runs beside the event loop, which is what the lower limit is for; 6 CPUs were not measured here.
  • The row is the worst case by construction: in normal operation a file is compressed once per coding while it stays in the cache (rows (b): cache hits only). A site whose working set of compressible files does not fit cache_bytes (8 MiB in ScalPanel mode) pays these fills repeatedly.
  • The brotli inline limit stays at 32 KiB (gzip at 64 KiB): no measurable cost and no measurable gain at 1 CPU; it bounds the stall of one event loop worker per fill on hosts with more CPUs.