diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-07-07 22:17:08 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-07 22:17:08 +0530 |
commit | e4870d84be19f4ea768933522eff437f64963730 (patch) | |
tree | 789e83bc1d67754b917874b8f92d4a1227644930 /ext/node/polyfills/internal | |
parent | 7d022ad11a74710ce46e4ab9f4e57635cae3ed2e (diff) |
perf(ext/node): native vectored write for server streams (#19752)
```
# main
$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 106182.250000
Msg/sec: 110279.750000
^C
# this PR
$ ./load_test 10 0.0.0.0 8080 0 0
Using message size of 20 bytes
Running benchmark now...
Msg/sec: 131632.250000
Msg/sec: 134754.250000
^C
```
Diffstat (limited to 'ext/node/polyfills/internal')
-rw-r--r-- | ext/node/polyfills/internal/stream_base_commons.ts | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/node/polyfills/internal/stream_base_commons.ts b/ext/node/polyfills/internal/stream_base_commons.ts index d7acf729d..01da0c5e3 100644 --- a/ext/node/polyfills/internal/stream_base_commons.ts +++ b/ext/node/polyfills/internal/stream_base_commons.ts @@ -253,7 +253,9 @@ export function onStreamRead( } } else { const offset = streamBaseState[kArrayBufferOffset]; - const buf = Buffer.from(arrayBuffer, offset, nread); + // Performance note: Pass ArrayBuffer to Buffer#from to avoid + // copy. + const buf = Buffer.from(arrayBuffer.buffer, offset, nread); result = stream.push(buf); } |