### Version 16.14.0 ### Platform Darwin Alans-MacBook-Pro.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:01 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T6000 arm64 ### Subsystem _No response_ ### What steps will reproduce the bug? ```js import crypto from 'crypto' import { Blob } from 'buffer' async function main () { const bytes = crypto.randomBytes(1024e6) const blob = new Blob([bytes]) const reader = blob.stream().getReader() console.time('read') const result = await reader.read() console.timeEnd('read') console.log(result.value.length, 'bytes') reader.cancel() } main() ``` Output: ```console $ node test.js read: 203.812ms 65536 bytes ``` ### How often does it reproduce? Is there a required condition? _No response_ ### What is the expected behavior? _No response_ ### What do you see instead? Why does it take 203ms to read 65kb from an in memory buffer? `blob.slice(0, 65536)` takes `0.148ms` so maybe some copying is happening? ```js const buf = await blob.arrayBuffer() const slice = buf.slice(0, 65536) ``` Takes `105ms`, which is still half the time `stream.read()` takes. ### Additional information _No response_
Activity
alanshaw commentedon Feb 24, 2022
I looked up what's happening behind the scenes:
node/lib/internal/blob.js
Lines 323 to 339 in 9be1dcf
fix: tests in CI (#1034)
chore: disable node native blob (#49)
buffer: improve blob read performance
buffer: improve blob read performance
buffer: improve blob read performance
buffer: improve blob read performance
buffer: improve blob read performance