Switch Luxi sendMsg from strict to lazy ByteStrings
Switch Luxi sendMsg from strict to lazy ByteStrings

Commit e821050d (“Switch the Luxi interface from Strings to
ByteStrings”) was designed to optimise the receive interface, but has
an unfortunate side-effect: when sending non-trivial messages, it
means that both the entire String and the ByteString versions must be
in memory at the same time, leading to much increased memory usage.

By changing the "hPut" from strict to lazy ByteStrings, it means that
both the String and the ByteString values can be evaluated lazily,
with significant effects: for a test query answer, instead of having
a peak from ~600MB to 1.4G during the entire Luxi send operation,
memory consumption actually decreased during the send operation, as
the ByteString chunks are released individually and even the backing
storage of the items that create the JSON string serialisation is
released lazily as well. So instead of slow growth 10→550MB then quick
peak to 1.4GB during Luxi send, we now have an even slower growth to
~580MB and then decrease of memory as the Luxi send progresses.

The only downside is of a small increase in CPU time of a few percents
for the above case; for our use cases, I think this is much desirable.

Signed-off-by: Iustin Pop <acf83a5274f31a43af6b914614365999469c1a31@google.com>
Reviewed-by: Helga Velroyen <2d0126b1ec6f9ec5cbec4a7012aa14faeaef10f5@google.com>

leshchevds/ganeti,apyrgio/snf-ganeti,yiannist/ganeti,ganeti-github-testing/ganeti-test-1,andir/ganeti,ganeti/ganeti,leshchevds/ganeti,andir/ganeti,grnet/snf-ganeti,ganeti/ganeti,apyrgio/ganeti,apyrgio/ganeti,bitemyapp/ganeti,mbakke/ganeti,ganeti/ganeti,ganeti-github-testing/ganeti-test-1,andir/ganeti,leshchevds/ganeti,mbakke/ganeti,onponomarev/ganeti,dimara/ganeti,yiannist/ganeti,dimara/ganeti,onponomarev/ganeti,bitemyapp/ganeti,grnet/snf-ganeti,apyrgio/snf-ganeti,mbakke/ganeti,yiannist/ganeti