Repository navigation
feat: Added @perseveranza-pets/milo as alternative experimental HTTP parser - #5492
Conversation
|
Perf comparison? |
Codecov Reportâ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5492 +/- ##
==========================================
- Coverage 93.50% 84.63% -8.88%
==========================================
Files 110 115 +5
Lines 38436 43701 +5265
==========================================
+ Hits 35940 36985 +1045
- Misses 2496 6716 +4220 â View full report in Codecov by Harness. ð New features to boost your workflow:
|
I haven't posted them here but even thought Milo is twice as fast as llhttp in terms of pure WASM perf, undici benchmark varies from +3% to -1% on different runs. I've tried countless times. |
metcoder95
left a comment
There was a problem hiding this comment.
I like this, a env var seems a good option as well to switch between experiences; but maybe adding it within a Client constructor can be helpful.
@metcoder95 Do you mind to expand. I'm not sure I get what you're asking for. |
|
Sure thing, was just referring that it could be nice to, when instantiating a Just guarding it as experimental should be enough to warn its usage. |
|
@metcoder95 How about now? |
metcoder95
left a comment
There was a problem hiding this comment.
lgtm, thanks @ShogunPanda ð
Just conflicts arised
âĶparser. Signed-off-by: Paolo Insogna <paolo@cowtech.it>
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
Benchmark results (llhttp vs Milo)Ran TL;DR: Milo is meaningfully faster on the GET benchmark (+14% to +44% on the core dispatcher APIs) and roughly neutral on the POST benchmark, where the 128 KiB upload dominates and parsing is a small share of the work. Environment
MethodologyThe stock So I pinned the two sides apart:
The non-undici clients in the table act as a built-in control: they don't touch the H1 parser, so their spread between configs is the noise floor. With pinning that floor is Âą6%. GET benchmark (
|
| Test | llhttp (req/sec) | Milo (req/sec) | Î |
|---|---|---|---|
| undici - stream | 12,953 | 18,605 | +43.6% |
| undici - dispatch | 14,471 | 19,960 | +37.9% |
| undici - request | 12,352 | 16,868 | +36.6% |
| undici - pipeline | 11,707 | 13,392 | +14.4% |
| undici - fetch | 5,424 | 5,718 | +5.4% |
Control clients (should be unaffected â this is the noise floor):
| Test | llhttp | Milo | Î |
|---|---|---|---|
| http - keepalive | 9,214 | 8,700 | -5.6% |
| superagent | 7,289 | 7,097 | -2.6% |
| got | 6,045 | 5,714 | -5.5% |
| http - no keepalive | 5,869 | 5,851 | -0.3% |
| node-fetch | 4,703 | 4,561 | -3.0% |
The undici deltas are 6â8Ã the control spread, so the GET win looks real.
undici - fetch barely moves, which is expected â it's bottlenecked in the Fetch/streams layer rather than in the parser.
POST benchmark (post-benchmark.js, 128 KiB request body)
| Test | llhttp (req/sec) | Milo (req/sec) | Î |
|---|---|---|---|
| undici - pipeline | 3,593 | 4,125 | +14.8% |
| undici - fetch | 1,700 | 1,854 | +9.0% |
| undici - dispatch | 5,577 | 5,690 | +2.0% |
| undici - stream | 5,414 | 5,509 | +1.8% |
| undici - request | 5,527 | 5,255 | -4.9% |
Apart from pipeline, everything here is inside the noise band â unsurprising, since the upload dominates and the response body is small.
Correctness spot-check
Before trusting the GET numbers I checked that Milo isn't simply delivering less: 500 concurrent requests against the bench server under both parsers returned identical results â 32,768,000 bytes total, correct content-length, correct status, and byte-for-byte identical payloads, 0 mismatches under both.
Caveats
- Single machine, 4 physical cores; the pinning that makes the comparison stable also means server and client each get half the box, so absolute numbers are lower than an unpinned
npm run bench. - Results on an unpinned, fully-contended setup were not reproducible in either direction on this hardware â worth a second opinion from a bigger/quieter machine before treating the exact percentages as final.
- Only
benchandbench-postwere run;bench:h2is unaffected (H2 doesn't use this parser) andbench:httpswasn't run.
Benchmarks run with Claude Code.
|
@metcoder95 @mcollina Are we good to land this? |
|
Nothing to add in my side, lgtm ð |
Summary
UNDICI_USE_MILO=1orUNDICI_USE_MILO=true.build:miloscript to refresh them.Assisted-By: OpenAI:GPT-5.5 <openai/gpt-5.5>
Status