Repository navigation
Conversation
Buffer body spans in on_body() and deliver them to JS once per execute() call instead of once per chunk. A body sent as many small chunks no longer costs one C++ to JS call and Buffer per chunk. Signed-off-by: Guilherme Araújo <[email protected]>
Collaborator
|
Review requested:
|
Signed-off-by: Guilherme Araújo <[email protected]>
Member
|
Any benchmark/perf numbers? |
Member
Author
|
https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1903/ Benchmark |
ronag
reviewed
Nov 1, 2026
| Local<Value> buffer = Buffer::Copy(env, data, length).ToLocalChecked(); | ||
| // ponytail: clear() keeps capacity (up to one read, 64 KiB) per parser; | ||
| // shrink_to_fit() here if pooled parsers' memory becomes a concern. | ||
| body_buf_.clear(); |
Member
There was a problem hiding this comment.
This can grow capacity-wise unbounded, e.g. one big message can keep the buffer needlessly big, forever
ronag
reviewed
Nov 1, 2026
| body_buf_.assign(pending_body_, pending_body_ + pending_body_len_); | ||
| body_buf_.insert(body_buf_.end(), at, at + length); | ||
| } | ||
| pending_body_len_ += length; |
Member
There was a problem hiding this comment.
should we maybe have a body max size, and flush if exceeding it? e.g. 64k?
Member
There was a problem hiding this comment.
then the body_buf_ can be reserved to 64k on construction
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67187 +/- ##
==========================================
+ Coverage 90.67% 90.71% +0.03%
==========================================
Files 797 797
Lines 278773 278808 +35
Branches 53607 53615 +8
==========================================
+ Hits 252778 252916 +138
+ Misses 16356 16249 -107
- Partials 9639 9643 +4
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Buffer body spans in
on_body()and deliver them to JS once perexecute()call instead of once per chunk. A body sent as many small chunks no longer costs one C++ to JS call andBufferper chunk.Chunks that arrive in the same read now produce a single
'data'event onIncomingMessage. Chunk boundaries were never documented, but code that treats each'data'event as a full message could break, so this is marked semver-major and needs a CITGM run.