Fix Small Typo: privlaged → privileged#1
Merged
Merged
Conversation
fewf
pushed a commit
to fewf/deno
that referenced
this pull request
Feb 7, 2019
add tests and add permissions checks to op_open
Closed
castarco
pushed a commit
to castarco/deno
that referenced
this pull request
Aug 3, 2024
hardfist
referenced
this pull request
in hardfist/deno
Aug 7, 2024
losfair
added a commit
that referenced
this pull request
Aug 14, 2024
4 tasks
This was referenced May 1, 2026
1 task
This was referenced May 30, 2026
This was referenced Jun 1, 2026
This was referenced Jun 13, 2026
nathanwhit
added a commit
that referenced
this pull request
Jun 26, 2026
## Summary A trivial [Hono](https://hono.dev) app served through `Deno.serve` left a lot of throughput on the table and emitted `transfer-encoding: chunked` where a fixed `Content-Length` was possible: ```ts const app = new Hono(); app.use("*", async (c, next) => { await next(); c.header("x-powered-by", "hono"); }); app.get("/", (c) => c.json({ hello: "world", framework: "hono" })); Deno.serve({ port, hostname: "127.0.0.1" }, app.fetch); ``` Profiling (`samply` + `--v8-flags=--perf-basic-prof`) pinned the overhead to the middleware's `c.header()` call, which after `await next()` runs `new Response(oldResponse.body, oldResponse)` to tweak a header — a very common framework pattern. That exposed three avoidable costs, fixed here: 1. **Static body downgraded to a stream.** Reading `.body` turns the fast string body into a `ReadableStream`, so the response is served via the streaming/chunked path — 3 `__sendto` syscalls/req and no `Content-Length` (~30% of main-thread time). `extractBody` now recovers the original static body when a `Response`/`Request` is reconstructed from an **undisturbed, static-backed** stream, restoring the single-write fast static path. Genuine streams (and any read/locked stream) are untouched. 2. **Headers re-validated through webidl.** `fillHeaderList` sent the already-validated `Headers` init object through the full webidl `sequence<sequence<ByteString>>` converter, re-validating every entry (~22% of main-thread time after fix #1). It now copies a `Headers` instance's entries directly. 3. **Eager body-stream materialization.** The `.body` getter eagerly built and UTF-8-encoded a `ReadableStream` that recovery immediately discards. It's now materialized lazily (high-water-mark 0, via the internal `createReadableStream` that also skips the webidl `UnderlyingSource` conversion), so the encode only happens on an actual read. ## Result `oha -n 1000000 -c 100 --disable-compression`, `--profile=release-lite`: | | req/s | encoding | |---|---|---| | before | 54,899 | chunked | | + static-body recovery | 79,207 | content-length | | + Headers fast path | 91,807 | content-length | | + lazy body stream | **98,637** | content-length | **+80%** on the same app, with `Content-Length` restored. The remaining cost is dominated by raw socket I/O (`__sendto` + `__recvfrom` ≈ 42% of main-thread time) and the inherent cost of constructing `Response`/`Headers` objects in JS. ## Behavior change Reconstructing a `Response`/`Request` from another body's stream (`new Response(other.body, other)`) and serving/consuming it now yields a `Content-Length` instead of chunked encoding when the source stream was static-backed and unread. As a side effect, consuming the reconstructed body no longer disturbs the original stream (the bytes are identical either way). Genuine `ReadableStream` bodies are unaffected. ## Tests - `ext/fetch/22_body.js` / `ext/fetch/20_headers.js` changes. - `tests/unit/serve_test.ts`: the `stream()` helper now builds a genuinely-opaque stream so the existing length/chunked tests still exercise the chunked path; added `recoveredStaticStreamBody` covering the new fast path. - `unit::{streams,body,headers,response,request,fetch,serve}_test` all pass; `tools/format.js` + `tools/lint.js --js` clean.
This was referenced Jul 20, 2026
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.
No description provided.