jorgebay/node-cassandra-cql — pull request #103 by gwicke (2014-08-04 17:10:42+00:00)
Title: Performance: Avoid excessive buffer copying on large values

Rows with large (>64k) values would be accumulated by repeatedly concatenating
a new chunk with the entire buffered value received so far. In benchmarks with
a 3mb value and a REST front-end this led to buffer copying being responsible
for about 56% of all CPU time.

This patch avoids this issue by recording how many bytes are expected for the
next cell, and then accumulating all buffers in an array until enough bytes
are received. The buffers in the array are only concatenated once, which
avoids the quadratic copying seen before this patch.

This file seems use a mix of DOS and UNIX line endings, which caused my vim to
switch to DOS mode. I'm happy to fix this up in a follow-up commit, ideally by
converting the file to unix-only line endings.