Skip to content

actix: port what the ntex entry gained in #1726 and #1756 - #1768

Merged
MDA2AV merged 4 commits into
mainfrom
actix-ntex-parity
Nov 13, 2026
Merged

MDA2AV merged 4 commits into
mainfrom
actix-ntex-parity

Conversation

@MDA2AV

@MDA2AV MDA2AV commented Nov 13, 2026

Copy link
Copy Markdown
Owner

ntex's entry was reworked by its author in #1726 and #1756 and went from 18th to 6th of 107 on the HTTP/1.1 board. The actix entry never had the same pass, so part of the distance between the two is the entries rather than the frameworks. This applies every one of those changes that actix has an equivalent for, across the three dirs that publish as actix, and lists the ones it has no equivalent for.

Carried over

ntex (#1726, #1756) actix
mimalloc as the global allocator actix, actix-h2c, actix-websocket
Dataset leaked once, responses borrow it actix, actix-h2c: no per-request clone of every name, category and tag. It reaches the handler through web::ThinData, so there is also no Arc shared by all workers to bump on each request
Compress on the JSON route only actix, see below
A Postgres pool per worker, sized DATABASE_MAX_CONN / workers actix, see below
500 on a database error actix
fortunes actix, with the same Askama template and escaper
echo-ws-limited actix-websocket subscribes; the profile needs nothing beyond /ws

Compress was wrapped around the whole app

That included the static files. try_compressed() serves the .br sibling where there is one, but the two .woff2 fonts have none, and the middleware only skips image/* and video/*, so both fonts went through brotli on every request.

Per file, both entries as they are on main, on the dev box (16 cores, wrk, 256 connections over TLS, 3 s each, taken before this change):

file actix req/s actix CPU per request ntex req/s ntex CPU per request
reset.css (br sibling) 395K 39 µs 249K 41 µs
vendor.js (br sibling) 141K 104 µs 93K 138 µs
hero.webp 204K 78 µs 153K 88 µs
regular.woff2 4.2K 3,759 µs 199K 59 µs

Two of the twenty files in the rotation cost 3.8 ms of CPU each; on the rest actix is level with ntex or ahead of it. That is what the published static rows are measuring: static-tls at 55,457 req/s on 6,037% CPU against ntex's 150,813 on 2,692%. It is also the likely source of the 35.9 GiB actix holds on static-h2 at 1,024 connections (an encoder per response in flight), though I did not verify that part.

The fonts are now sent as they are on disk (content-length: 18432, no content-encoding).

Postgres

Every actix-web worker is a single-threaded runtime. The entry had one pool shared by all of them, and deadpool-postgres spawns a connection's I/O task on the runtime that opened it, so a worker was mostly handed connections driven from another worker's thread: each query crossed threads on the way out and again on the way back. Each worker now has its own pool holding its share of DATABASE_MAX_CONN, the same split ntex uses (64 workers × 4 on the bench host). Rows are serialized from a typed struct instead of a serde_json::Value tree built per row.

A database error answers 500, as ntex does since #1726. The async-db page still describes an empty {"items":[],"count":0} for an unreachable database; I followed ntex so that a failing pool shows up in the 5xx column instead of as a fast result. Say if you want the documented fallback kept.

Smaller ones

  • The hand-added Server: actix header is gone and text/plain no longer carries ; charset=utf-8. The baseline response goes from 133 to 103 bytes, which is what ntex sends.
  • Worker count comes from std::thread::available_parallelism(), which is actix-web's own default and honours both the cpuset and a CPU quota, instead of a hand-rolled cgroup parser plus num_cpus. Same count.
  • actix-websocket built with cargo's default release profile and without target-cpu=native. It now builds like the other two actix entries and like ntex-ws.
  • The crud endpoints are removed (the profile went in profiles: remove static and crud #1374), and dashmap with them.
  • Dockerfile: RUSTFLAGS is set for both build steps, so the dependency layer is reused instead of rebuilt, and the placeholder is dropped with cargo clean -p as in Gateway profiles: validate the stack instead of the standalone, fix authsvc on Rust 1.100, unbreak the aspnet gateway entries #1767.
  • README rewritten; it still described SQLite and preloaded static files.

Not carried over

  • LoadBalancing::Reuseport, each worker accepting on its own SO_REUSEPORT listener, which took ntex's limited-conn up 76%. actix-server 2.9 has one accept thread that hands connections to the workers round-robin and no option to change that. Getting the same thing means assembling one single-worker server per core by hand, which is Tuned. actix's limited-conn row (1.13M at 4,588% of 6,400% CPU against ntex's 2.23M) is consistent with that thread being the limit, and it stays.
  • timer_resolution = 2. actix runs on tokio, whose timer already has 1 ms granularity. Nothing to set.
  • json-comp through the middleware alone. ntex 4.8 compresses bodies under 16 KiB in place, so its entry now uses Compress as shipped. actix-http 3.20 still sends every body of 1 KiB or more through spawn_blocking, so this keeps the handler-driven gzip from actix: fix json-comp - every response was going through a blocking thread pool [skip-maintainer-ping] #1388. That leaves actix as the one of the two that departs from the json-comp Standard rule as written, the same open point as in actix: fix json-comp - every response was going through a blocking thread pool [skip-maintainer-ping] #1388.
  • Static file reads. actix-files reads through the blocking pool unless read_mode_threshold() is raised. Left at the default: it is a tuning knob, not a documented production setting.
  • No gRPC entry (actix-web has no gRPC server), and h2 stays in the main entry instead of moving to a sibling.

Already level before this: TCP_NODELAY (ntex sets it on every accepted socket, the actix entries since #1690) and the 1,024 backlog (actix-web's default, and the value ntex sets).

Checked

  • validate.sh: actix 97 passed, 0 failed; actix-h2c 7 passed, 0 failed; actix-websocket 7 passed, 0 failed. Host port 8080 was in use on the dev box, so the script's containers and probes ran in a private network namespace; the checks themselves are unchanged.
  • With DATABASE_URL set and no Postgres, /async-db and /fortunes answer 500 and the other routes are unaffected. Once Postgres is up they recover without a restart.
  • 600 concurrent /async-db requests against 16 workers: all 200, 18 connections opened in total.

Nothing was benchmarked after the change. The published actix rows are still the old entry's until a saved bench-host run of the three dirs.

🤖 Generated with Claude Code

ntex's entry was reworked in #1726 and #1756. This applies the same
changes to the actix one, so the distance between the two on the board is
the frameworks and not the entries.

- mimalloc as the global allocator.
- The dataset is loaded once and leaked, and responses borrow its strings
  instead of cloning every name, category and tag per request. It reaches
  the handler through web::ThinData, so there is no Arc shared by all
  workers to bump on each request either.
- The Compress middleware wraps the JSON route only. Around the whole app
  it also compressed the static files without a pre-compressed sibling:
  the two .woff2 fonts went through brotli on every request.
- One deadpool-postgres pool per worker, each holding its share of
  DATABASE_MAX_CONN. Every worker is a single-threaded runtime; with one
  shared pool a connection's socket is driven from whichever worker opened
  it, so each query crossed threads both ways. Rows are serialized from a
  typed struct instead of a serde_json::Value tree, and a database error
  answers 500 instead of an empty 200.
- fortunes, with the same Askama template and escaper as ntex.
- The hand-added Server header is gone and text/plain carries no charset,
  which leaves the header set actix-web sends by default and ntex sends.
- Worker count from std::thread::available_parallelism(), which is
  actix-web's own default, instead of a hand-rolled cgroup parser.
- The crud endpoints are removed; the profile went in #1374.
- Dockerfile: RUSTFLAGS set for both build steps so the dependency layer
  is reused, and `cargo clean -p` instead of deleting from target/deps.
…ount

Same changes as the main actix entry: mimalloc as the global allocator,
the dataset leaked once and borrowed by every response, no hand-added
Server header, and the worker count left to actix-web's default instead of
a hand-rolled cgroup parser.
…s-limited

The entry built with cargo's default release profile and without
target-cpu=native, unlike the other two actix entries and ntex-ws. It now
uses the same opt-level=3 / codegen-units=1 / thin LTO / panic=abort
profile, and mimalloc as the global allocator.

Subscribes to echo-ws-limited, which needs nothing beyond the /ws endpoint
the entry already serves.
@MDA2AV

MDA2AV commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

/benchmark-multiple --save

@github-actions

Copy link
Copy Markdown
Contributor

👋 Benchmark request received. A collaborator will review and approve the run.

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results

Frameworks: 3 | Test: all tests

✅ actix

Test Conn RPS Rate CPU/req p99 p99.9 CPU Mem Δ RPS Δ Mem
baseline 4096 2,955,902 — — — — 6311.4% 371MiB +16.2% +127.6%
pipelined 4096 18,907,788 — — — — 6756.4% 428MiB +19.6% +104.8%
limited-conn 4096 1,139,262 — — — — 4400.5% 278MiB +1.0% +256.4%
json-comp 4096 613,630 — — — — 6341.9% 609MiB +15.9% +179.4%
json-comp 16384 594,198 — — — — 6562.2% 910MiB +11.0% +104.0%
json-tls 4096 1,401,777 — — — — 6274.9% 429MiB +23.2% +79.5%
8gbit 512 49,392 0.9878 48.67us 125.0us 4095.0us 218.8% 336MiB ~0% +277.5%
static-tls 1024 414,570 — — — — 6303.9% 2.6GiB +647.6% -44.7%
async-db 1024 320,231 — — — — 3602.7% 418MiB +112.8% +200.7%
fortunes 1024 267,328 — — — — 5072.5% 430MiB NEW NEW
baseline-h2 256 6,427,519 — — — — 6262.7% 513MiB +24.7% +174.3%
baseline-h2 1024 4,836,173 — — — — 6233.4% 829MiB +28.6% +35.9%
static-h2 256 419,801 — — — — 6239.4% 2.3GiB +722.7% -78.9%
static-h2 1024 404,445 — — — — 6246.2% 2.8GiB +534.0% -92.2%
latency-1m 1024 998,533 0.9985 24.98us 185.0us 2261.0us 2731.9% 294MiB ~0% +272.2%
latency-10k 1024 9,983 0.9983 26.63us 105.0us 149.0us 25.4% 360MiB ~0% +407.0%
latency-500k-8cpu 1024 445,089 0.8902 ⚠️ 17.92us 2126848.0us 2163712.0us 793.9% 83MiB +11.4% +107.5%
async 32000 1,998,958 — — — — 4807.0% 1.3GiB +14.4% +44.4%

Composite score, main against this run, in the board's default view:

Family main this run Δ
HTTP/1.1 5942.1 (13 of 107) 6493.5 (9 of 107) +551.4
HTTP/2 1502.1 (12 of 40) 2187.9 (8 of 40) +685.8
WebSocket 1629.8 (15 of 39) 2224.6 (11 of 39) +594.8

The results on main were measured in another session, so a few points up or down can be the machine and not the change.

✅ actix-h2c

Test Conn RPS CPU Mem Δ RPS Δ Mem
baseline-h2c 256 6,671,590 6418.6% 578MiB +9.4% +295.9%
baseline-h2c 1024 4,961,422 6340.3% 829MiB +12.3% +59.7%
baseline-h2c 4096 4,500,687 6176.9% 2.6GiB +24.3% +36.8%
json-h2c 1024 1,764,965 6566.7% 584MiB +22.6% +60.0%
json-h2c 4096 1,616,163 6244.4% 1.3GiB +22.9% +8.3%

✅ actix-websocket

Test Conn RPS CPU Mem Δ RPS Δ Mem
echo-ws 512 3,646,407 6495.2% 179MiB +3.0% +251.0%
echo-ws 4096 3,660,925 6188.0% 275MiB +5.4% +87.1%
echo-ws 16384 3,473,363 5920.3% 449MiB +4.9% +36.1%
echo-ws-pipeline 512 47,190,006 6715.6% 184MiB +7.9% +283.3%
echo-ws-pipeline 4096 46,405,884 6235.8% 283MiB +8.9% +86.2%
echo-ws-pipeline 16384 44,938,672 6151.7% 341MiB +7.9% +9.3%
echo-ws-limited 512 1,170,845 4419.1% 173MiB NEW NEW
echo-ws-limited 4096 1,145,177 4314.1% 178MiB NEW NEW

@MDA2AV
MDA2AV merged commit c4b9eed into main Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant