You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A flag that would cause llhttp to automatically lowercase response headers, so that higher level libraries do not need to perform an additional iteration over headers.
Parse and include "keep-alive: timeout (\d+)s" in kOnMessageHeadersComplete, e.g. by changing the type of shouldKeepAlive to an integer, so that higher level libraries do not need to perform an additional iteration over headers.
I'll investigate, but the second sounds possible. As for the first one, llhttp does not modify the incoming data - it simply isn't possible for it to emit the data that isn't a part of the input. Sorry!
On server side it's supported by nginx and more recently Node. Probably more that I am not aware of. We want to add support for it in the Node core client as well.
It resolves a problem that otherwise cannot be worked around in terms of a connection close race between server and client.
What do you think about the following plan: I'll make this change in a branch and we'll see how much difference it makes for undici. If there is a performance improvement for it - we'll polish the feature and release it, otherwise - we'll call the experiment a failure. Does this sound reasonable?
I'd clone the repo, checkout the branch, run npm install and make release, and then copy over the contents of release/* into deps/llhttp in Node.js folder.
Hm, I did that, copied to deps/llhttp and overwrote the old files and confirmed they contain the changes. Did a ./configure --ninja and make -j4. However, Node seems to still be running with previous version (i.e. shouldKeepAlive is a boolean)... Any ideas? I'm not too good with the Node build system.
Looks about the same with sufficient number of runs:
new llhttp: n=100 mean=49943.697 stddev=1994.497
old llhttp: n=100 mean=49818.511 stddev=1175.314
new llhttp: n=100 mean=49716.333 stddev=984.585
old llhttp: n=100 mean=49305.306 stddev=1173.042
Could you run it for longer time @ronag ? The standard deviation is quite significant and given low n - there must be a lot of noise in the mean (noise goes of as 1/sqrt(n)). It should be safer to compare n=100 (or even n=200) results.
Could you also share the node.js patch that you are using? I'd like to do the benchmarks runs on a beefy server as well.
Activity
indutny commentedon Aug 17, 2020
I'll investigate, but the second sounds possible. As for the first one, llhttp does not modify the incoming data - it simply isn't possible for it to emit the data that isn't a part of the input. Sorry!
indutny commentedon Aug 17, 2020
Is
keep-aliveheader a part of this draft https://tools.ietf.org/id/draft-thomson-hybi-http-timeout-01.html ? How widespread is the implementation of it? At glance it looks like it is not part of standard HTTP protocol and that draft has expired...ronag commentedon Aug 17, 2020
https://tools.ietf.org/html/draft-thomson-hybi-http-timeout-03#section-2
https://tools.ietf.org/html/rfc7230#appendix-A.1.2
On server side it's supported by nginx and more recently Node. Probably more that I am not aware of. We want to add support for it in the Node core client as well.
It resolves a problem that otherwise cannot be worked around in terms of a connection close race between server and client.
ronag commentedon Aug 17, 2020
nodejs/node#34561
ronag commentedon Aug 17, 2020
http://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout
indutny commentedon Aug 17, 2020
Excellent! Thank you for sharing the references.
What do you think about the following plan: I'll make this change in a branch and we'll see how much difference it makes for undici. If there is a performance improvement for it - we'll polish the feature and release it, otherwise - we'll call the experiment a failure. Does this sound reasonable?
ronag commentedon Aug 17, 2020
Sounds great. Thank you for helping out on this.
http: parse timeout from `Keep-Alive` header
indutny commentedon Aug 17, 2020
@ronag could you give a try to this branch please?
ronag commentedon Aug 18, 2020
Sure. Just need to figure out how to make a node build with it.
indutny commentedon Aug 18, 2020
Oh, right. Sorry!
I'd clone the repo, checkout the branch, run
npm installandmake release, and then copy over the contents ofrelease/*intodeps/llhttpin Node.js folder.ronag commentedon Aug 18, 2020
Hm, I did that, copied to deps/llhttp and overwrote the old files and confirmed they contain the changes. Did a
./configure --ninjaandmake -j4. However, Node seems to still be running with previous version (i.e.shouldKeepAliveis a boolean)... Any ideas? I'm not too good with the Node build system.ronag commentedon Aug 18, 2020
Found it!
node_http_parserneeds some tuning as well.indutny commentedon Aug 18, 2020
You have to patch up node so that it makes it an integer. Let me see what change would do it.
indutny commentedon Aug 18, 2020
Oh, you found it! Great!
12 remaining items
ronag commentedon Aug 18, 2020
Sorry! I think I made a mistake in undici. Digging into it now.
ronag commentedon Aug 18, 2020
Ok, here we go:
First one is with the changes and second one without:
It's a bit of an unrealistic benchmark since the test server is responding with 1000 headers but it does show there is a diff.
indutny commentedon Aug 18, 2020
So... it is better?
ronag commentedon Aug 18, 2020
yes, ~6% better
indutny commentedon Aug 18, 2020
Looks about the same with sufficient number of runs:
Here's the modified benchmark script: https://gist.github.com/indutny/b972581054a30d0773497a94845fa9aa
At least we didn't make it slower :D
indutny commentedon Aug 18, 2020
That being said, I'm looking forward for seeing how this benchmark will run on modified undici that leverages the parsed header value.
ronag commentedon Aug 19, 2020
modified
unmodified
indutny commentedon Aug 19, 2020
Could you run it for longer time @ronag ? The standard deviation is quite significant and given low
n- there must be a lot of noise in themean(noise goes of as1/sqrt(n)). It should be safer to comparen=100(or evenn=200) results.Could you also share the node.js patch that you are using? I'd like to do the benchmarks runs on a beefy server as well.
ronag commentedon Aug 19, 2020
nxtedition/node@4e460f3
https://github.com/mcollina/undici/pull/342
ronag commentedon Aug 19, 2020
My computer is useless for benchmarks unfortunately. Have the same problem with undici benchmarks.
indutny commentedon Aug 19, 2020
Thanks! I'll give it an extended run and report back to you.
indutny commentedon Aug 19, 2020
Here are the results:
Looks like there is no significant improvement, and in fact it is worse than with unpatched node.
ronag commentedon Aug 19, 2020
That's interesting. I guess doing the keep-alive parsing is faster in Javascript. Weird.
Thanks a lot for trying this. Much appreciated. I might dig into this at some point in the future to try and understand why it's slower.
indutny commentedon Aug 19, 2020
Sure thing! I'm keeping the branch in llhttp for now. Thanks!