From 23ff0e722e3c4b0827940853c53c5ee2ede5ec9f Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Thu, 17 Aug 2023 07:52:37 -0600 Subject: feat(ext/web): resourceForReadableStream (#20180) Extracted from fast streams work. This is a resource wrapper for `ReadableStream`, allowing us to treat all `ReadableStream` instances as resources, and remove special paths in both `fetch` and `serve`. Performance with a ReadableStream response yields ~18% improvement: ``` return new Response(new ReadableStream({ start(controller) { controller.enqueue(new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100])); controller.close(); } }) ``` This patch: ``` 12:36 $ third_party/prebuilt/mac/wrk http://localhost:8080 Running 10s test @ http://localhost:8080 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 99.96us 100.03us 6.65ms 98.84% Req/Sec 47.73k 2.43k 51.02k 89.11% 959308 requests in 10.10s, 117.10MB read Requests/sec: 94978.71 Transfer/sec: 11.59MB ``` main: ``` Running 10s test @ http://localhost:8080 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 163.03us 685.51us 19.73ms 99.27% Req/Sec 39.50k 3.98k 66.11k 95.52% 789582 requests in 10.10s, 82.83MB read Requests/sec: 78182.65 Transfer/sec: 8.20MB ``` --- cli/tests/unit_node/http_test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'cli/tests/unit_node') diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts index a361ff257..706c672f1 100644 --- a/cli/tests/unit_node/http_test.ts +++ b/cli/tests/unit_node/http_test.ts @@ -141,8 +141,7 @@ Deno.test("[node/http] chunked response", async () => { } }); -// TODO(kt3k): This test case exercises the workaround for https://github.com/denoland/deno/issues/17194 -// This should be removed when #17194 is resolved. +// Test empty chunks: https://github.com/denoland/deno/issues/17194 Deno.test("[node/http] empty chunk in the middle of response", async () => { const promise = deferred(); -- cgit v1.2.3