pack: enhance memory allocation strategy for large JSON payloads
pack: enhance memory allocation strategy for large JSON payloads

When converting msgpack buffers with large JSON text content, the buffering
strategy is not quite optimal since the outgoing buffer always set an
output buffer of size 1.5x, then if more space is needed the code reallocate
by adding 256 bytes more.

If the large payload needs more than 1.5x, the 256 bytes allocation generates
a slow path and may lead to hundreds of memory reallocations, adding latency
to the pipeline.

This patch improves the strategy by allocating an initial buffer size of 2x
and then if more space is needed, increase in rounds of 10% of the original
payload size.

Signed-off-by: Eduardo Silva <81f705dc2ce1a61a2621e0e4b442a9474e1d0c70@calyptia.com>

fluent/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit