You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`Reader.prototype.addChunk` was calling `Buffer.concat` constantly, which
increased garbage collection and just all-around killed performance. The
exact implications of this is documented in
brianc/node-postgres#1286, which has a test case
for showing how performance is affected.
Rather than concatenating buffers to the new buffer size constantly, this
change uses a growth strategy that doubles the size of the buffer each
time and tracks the functional length in a separate `chunkLength` variable.
This significantly reduces the amount of allocation and provides a 25x
performance in my test cases, the larger the amount of data the query
is returning, the greater improvement of performance.
Since this uses a doubling buffer, it was important to avoid growing
forever, so I also added a reclaimation strategy which reduces the size
of the buffer wever time more than half of the data has been read.
0 commit comments