-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS side code expensive for HTTP server #3546
Comments
Ref #2758 |
Just FYI, flamegraphs look very alike when you run
I'd advise to take a look at shared queue which uses a lot of |
@kevinkassimo we did a major decoding improvement in #3204, but we didn't touch encoding. Feels like we should certainly do that as well. #3204 increased performance to a point where JS clearly isn't the bottleneck. |
Since this issue was opened we introduced a lot of performance improvements, including:
That makes presented flamegraph outdated, so I'm closing this issue. |
Using flamegraph,
deno -A std/http/http_bench.ts
yields the following graph:deno_http.svg
Some discovery (
AsyncFunctionAwaitResolveClosure
corresponds to our main for await loop):A lot of time is still spent on
TextEncoder.encode
(center, 0x28236c3d6c48)ArrayPrototypeReverse
. This happens toStream
intext_encoding.ts
which I don't think is (along with slicing) necessary (in many cases we never push new data to it)Date
header that is sampled every time a request comes in. This is not necessary: instead we can just sample every few interval. However this requires a timer that could be unref (Node uses unref timer for this).Uint8Array.subarray(...) / Builtins_TypedArrayPrototypeSubArray
is quite expensive, and a lot of nontrivial chunks could be found spreading across the graph (see Use %TypedArray%.prototype.subarray for Buffer.prototype.slice nodejs/node#17431)Object.assign()
on very common objects (especially increateResolvable(...)
) is expensive.Async generators themselves are also having quite some overhead
On the rightmost of the whole graph there is a large chunk corresponding to freeing ArrayBuffers. We might have been abusing allocating new
TypedArray
s and for some internal places we might be able to just cache and reuseThe text was updated successfully, but these errors were encountered: