Wednesday, 10 May 2017

Slow Buffer.concat

When I read a 16MB file in pieces of 64Kb, and do Buffer.concat on each piece, the latter proves to be incredibly slow, takes a whole 4s to go through the lot.

Is there a better way to concatenate a buffer in Node.js?

Node.js version used: 7.10.0, under Windows 10 (both are 64-bit).


This question is asked while researching the following issue: https://github.com/brianc/node-postgres/issues/1286, which affects a large audience.

The PostgreSQL driver reads large bytea columns in chunks of 64Kb, and then concatenates them. We found out that calling Buffer.concat is the culprit behind a huge loss of performance in such examples.



via vitaly-t

No comments:

Post a Comment