mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
stream: read stream/iter push() readables without normalizing
The readable of push() yields batches that it has validated already, but from(), and so pipeTo(), normalized them again through another async iterator layer. Mark the readable with kValidatedSource, as for Readable sources, so that they are read directly. Piping a push() stream written with 64 KiB chunks is about 30% faster. Assisted-by: OpenCode Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/66504 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
1 parent
1af910b9b0
commit
db76c2fc60
1 file changed
+4
@@ -26,6 +26,7 @@ const {
|
||||
|
||||
const {
|
||||
drainableProtocol,
|
||||
kValidatedSource,
|
||||
} = require('internal/streams/iter/types');
|
||||
|
||||
const {
|
||||
@@ -734,6 +735,9 @@ class PushWriter {
|
||||
function createReadable(queue) {
|
||||
return {
|
||||
__proto__: null,
|
||||
// The batches read are validated already: from() and pipeTo() can read
|
||||
// them without normalizing them again.
|
||||
[kValidatedSource]: true,
|
||||
[SymbolAsyncIterator]() {
|
||||
return ObjectSetPrototypeOf({
|
||||
async next() {
|
||||
|
||||
Reference in new issue
Block a user