perf(http): recover the fetch adapter's per-request cost on Deno and Bun #175

Merged
chrnx merged 2 commits from perf/web-headers-fast-path into develop 2026-10-28 19:31:15 +00:00
2 Commits
Author SHA1 Message Date
chrnx 133af8dfe5 perf(http): read a declared-length fetch body with arrayBuffer()
CI / dco (pull_request) Successful in 5s
CI / runtimes (bun) (pull_request) Successful in 20s
CI / build (pull_request) Successful in 29s
CI / runtimes (edge) (pull_request) Successful in 23s
CI / runtimes (deno) (pull_request) Successful in 32s
The chunked reader added for the incremental 413 (4d1639f) cut a Bun JSON
POST by more than half: 37.6k -> 11.7k req/s on jarvis. A well-formed
Content-Length inside the limit already bounds the body, because the
runtime frames it by that header, so arrayBuffer() is safe there and native
in Bun, Deno and workerd. byteLength is still checked for a Request built in
user code whose header and body disagree. Chunked uploads keep the bounded
read.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-10-27 22:35:06 -05:00
chrnx 5b2143fcb7 perf(http): hand plain-string response headers to the fetch Response as a record
toWebHeaders copied every response's headers into a Headers object one by
one, so set-cookie arrays survive. Deno and Bun build native headers from a
record directly, and the JS copy cost 5-8% on every Deno request (bisected to
50010da). A record holding only strings is now returned as it is; anything
else still goes through Headers.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-10-27 22:35:03 -05:00