Repository navigation
actix: port what the ntex entry gained in #1726 and #1756 - #1768
Merged
Merged
Conversation
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.
Owner
Author
|
/benchmark-multiple --save |
Contributor
|
👋 Benchmark request received. A collaborator will review and approve the run. |
Contributor
Benchmark ResultsFrameworks: 3 | Test: ✅
|
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
actix,actix-h2c,actix-websocketactix,actix-h2c: no per-request clone of every name, category and tag. It reaches the handler throughweb::ThinData, so there is also noArcshared by all workers to bump on each requestCompresson the JSON route onlyactix, see belowDATABASE_MAX_CONN / workersactix, see below500on a database erroractixfortunesactix, with the same Askama template and escaperecho-ws-limitedactix-websocketsubscribes; the profile needs nothing beyond/wsCompresswas wrapped around the whole appThat included the static files.
try_compressed()serves the.brsibling where there is one, but the two.woff2fonts have none, and the middleware only skipsimage/*andvideo/*, 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):
reset.css(br sibling)vendor.js(br sibling)hero.webpregular.woff2Two 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, nocontent-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 aserde_json::Valuetree 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
Server: actixheader is gone andtext/plainno longer carries; charset=utf-8. The baseline response goes from 133 to 103 bytes, which is what ntex sends.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 plusnum_cpus. Same count.actix-websocketbuilt with cargo's default release profile and withouttarget-cpu=native. It now builds like the other two actix entries and like ntex-ws.dashmapwith them.RUSTFLAGSis set for both build steps, so the dependency layer is reused instead of rebuilt, and the placeholder is dropped withcargo clean -pas in Gateway profiles: validate the stack instead of the standalone, fix authsvc on Rust 1.100, unbreak the aspnet gateway entries #1767.Not carried over
LoadBalancing::Reuseport, each worker accepting on its ownSO_REUSEPORTlistener, 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.Compressas shipped. actix-http 3.20 still sends every body of 1 KiB or more throughspawn_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.read_mode_threshold()is raised. Left at the default: it is a tuning knob, not a documented production setting.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:actix97 passed, 0 failed;actix-h2c7 passed, 0 failed;actix-websocket7 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.DATABASE_URLset and no Postgres,/async-dband/fortunesanswer500and the other routes are unaffected. Once Postgres is up they recover without a restart./async-dbrequests against 16 workers: all200, 18 connections opened in total.Nothing was benchmarked after the change. The published
actixrows are still the old entry's until a saved bench-host run of the three dirs.🤖 Generated with Claude Code