http,net,stream: reconcile read, write, and parser paths - #64980
http,net,stream: reconcile read, write, and parser paths#64980GetThatCookie wants to merge 3 commits into
Conversation
|
Review requested:
|
|
Please sign your comments, and add disclosers for any and all AI usage |
|
Looks AI generated... interesting non-the-less... not sure what to think |
Signed-off-by: GetThatCookie <NimmenKeks@gmx.de>
Signed-off-by: GetThatCookie <NimmenKeks@gmx.de>
Signed-off-by: GetThatCookie <NimmenKeks@gmx.de>
|
Just for some context... I use node in our own project and stumbled across the My intention was simply to see if those ideas could be brought together If the PR is too large or just not the direction you want to take, I am |
|
As I said, I think this is interesting |
ronag
left a comment
There was a problem hiding this comment.
can we move the http2 stuff to separate PR? I'm not comfortable reviewing that
ronag
left a comment
There was a problem hiding this comment.
I don't understand the stream changes. Can those be commented/explained?
ronag
left a comment
There was a problem hiding this comment.
I think it would help to have the 3 commits as separate PRs? I also think they are not entirely dependent?
|
@ronag I split this into four PRs now. A 1:1 split of the three commits wouldn't work because the second one completes the first. The parser and HTTP/2 parts are independent - your guess was right here. I also added a few comments around the stream changes. In short, the vector still goes through Writable so ordering, backpressure, and callbacks stay intact. StreamBase avoids creating a WriteWrap for synchronous writes and safely handles completion before JavaScript has attached the callback. |
This PR reconciles the overlapping goals of #64887, #64346, #64393, and
#64455 into one canonical HTTP, net, and stream architecture.
Those PRs identified real bottlenecks and directly informed this work. The
goal here is to combine their valid objectives without landing competing
response builders, caches, fast paths, or duplicate lifecycle state.
No public API or documented wire behavior is intentionally changed.
Changes
790260a488e— canonical write architecturethrough one shared vector path;
destruction, TLS, trailers, and pipelining;
WriteWrapobjects only for asynchronous writes;maxHeaderPairsonce per independent parser header section.bb58fcd9904— final path reconciliationUint8Arrayvalues;write/_writevsemantics;Http2Stream.end(chunk);39318a1d642— bounded managed-read reuseEnvironment;coupling.
Related work
This PR is intended to supersede the overlapping work while acknowledging the
analysis and implementation effort behind it:
WriteWrapwork is integrated, while its read-allocation objective is addressed through bounded internal reuse instead of a JavaScript-visible shared slab.The tested #64393 tip returned stale output when a reused Buffer changed from
AtoB: main and this branch producedA,B, while that branch producedA,A. Its cached headline path is therefore not a semantics-preservingcomparison target.
The tested shared slab from #64455 exposed a 64 KiB backing store for small
chunks and coupled their transfer/detach behavior. This branch keeps every
emitted chunk exactly sized and independently transferable.
Performance
Local macOS arm64 Release builds were compared through paired, interleaved
runs against the same
f43086d1e4dbase.The exceptional explicit-cork result comes from correcting a path that
previously emitted HTTP framing writes outside the socket-level batch. It is
the removal of a pathological unbatched path, not a claim that every HTTP
workload becomes 30x faster.
The read cache retains exactly 65,536 additional
arrayBuffersbytes perEnvironment. That value remained constant from 5,000 through 200,000roundtrips, with no growth in RSS or external memory.
Validation
The output/write reconciliation passed:
The final read-buffer binary additionally passed:
git diff --checkDocumentation is unchanged because this is an internal, behavior-preserving
reconciliation.
AI assistance
I developed this PR iteratively with OpenAI Codex as a pair-programming and
analysis tool. It helped trace the affected code paths and related PRs,
explore implementation alternatives, expand test coverage, run and analyze
benchmarks, and edit parts of this description.
I evaluated the alternatives, removed candidates that did not preserve
semantics or demonstrate measurable value, and reviewed and understand the
final diff and reported results.