Some side notes:
- The readFileSync in this benchmark has UTF-8 decoding (produces a string instead of a Buffer). That’s why it’s slower; not sure why it’s included.
- The first guess/suggestion,
> I suspect the cause is right here: [https://github.com/nodejs/node/blob/3b2863db12818778671713b5...]
> Instead of creating a new Buffer for each chunk, it could allocate a single Buffer and write to that buffer. I don't think Buffer.concat or temporary arrays are necessary.
is already what the code does. Multiple chunks and Buffer.concat are only involved if more data gets read than stat initially reports.