Skip to content

Commit 9b848d4

Browse files
franciscovalentecastroedsiper
authored andcommitted
pack: use build time parameters for msgpack to json buffer
Setting build time parameters to determine the function 'flb_msgpack_raw_to_json_sds' buffer strategy. The parameter 'FLB_MSGPACK_TO_JSON_INIT_BUFFER_SIZE' is a multiplier to determine the initial buffer size to store the conversion to json from a msgpack object. It multiplies the size of the buffer where the msgpack object is stored to obtain an estimate of the allocation required. e.g. A value of 2 sets to allocate a buffer of size 2x of the received payload. The parameter 'FLB_MSGPACK_TO_JSON_REALLOC_BUFFER_SIZE' is a multiplier to determine the size in bytes to add in every memory reallocation when more space is needed for the buffer. It multiplies the size of the buffer where the msgpack object is stored to obtain a percentage of memory to be increased each round. e.g. A value of .1 sets to increase in rounds of 10% of the original payload size. Signed-off-by: Francisco Valente <[email protected]>
1 parent 673e7c2 commit 9b848d4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/flb_pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@ flb_sds_t flb_msgpack_raw_to_json_sds(const void *in_buf, size_t in_size)
723723
flb_sds_t tmp_buf;
724724

725725
/* buffer size strategy */
726-
out_size = in_size * 2;
727-
realloc_size = in_size * 0.10;
726+
out_size = in_size * FLB_MSGPACK_TO_JSON_INIT_BUFFER_SIZE;
727+
realloc_size = in_size * FLB_MSGPACK_TO_JSON_REALLOC_BUFFER_SIZE;
728728
if (realloc_size < 256) {
729729
realloc_size = 256;
730730
}

0 commit comments

Comments
 (0)