diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2022-09-24 14:10:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-24 14:10:46 +0300 |
commit | 12cd3988949b604af74c28c6424b7753cf3a5069 (patch) | |
tree | 3f43e20ad78dc5aca4baf2fb4f3604493689c2f7 /libnetdata | |
parent | 5e0d532e19ad338dd499bad49773d51d797b45d6 (diff) |
Faster streaming by 25% on the child (#13708)
* faster printing of BEGIN, SET, END
* fewer conditions
* faster buffer_fast_strcat()
* faster buffer_fast_strcat() fix
* eliminate atomic operations and conditions in the BEGIN, SET, END flow
* removed unecessary condition
Diffstat (limited to 'libnetdata')
-rw-r--r-- | libnetdata/buffer/buffer.c | 12 | ||||
-rw-r--r-- | libnetdata/buffer/buffer.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/libnetdata/buffer/buffer.c b/libnetdata/buffer/buffer.c index 8a32184f60..3d29c30255 100644 --- a/libnetdata/buffer/buffer.c +++ b/libnetdata/buffer/buffer.c @@ -136,6 +136,18 @@ void buffer_print_llu(BUFFER *wb, unsigned long long uvalue) wb->len += wstr - str; } +void buffer_print_ll(BUFFER *wb, long long value) +{ + buffer_need_bytes(wb, 50); + + if(value < 0) { + buffer_fast_strcat(wb, "-", 1); + value = -value; + } + + buffer_print_llu(wb, value); +} + void buffer_fast_strcat(BUFFER *wb, const char *txt, size_t len) { if(unlikely(!txt || !*txt)) return; diff --git a/libnetdata/buffer/buffer.h b/libnetdata/buffer/buffer.h index 42425b4cb7..c134cc9aca 100644 --- a/libnetdata/buffer/buffer.h +++ b/libnetdata/buffer/buffer.h @@ -78,6 +78,7 @@ extern char *print_number_llu_r(char *str, unsigned long long uvalue); extern char *print_number_llu_r_smart(char *str, unsigned long long uvalue); extern void buffer_print_llu(BUFFER *wb, unsigned long long uvalue); +extern void buffer_print_ll(BUFFER *wb, long long value); static inline void buffer_need_bytes(BUFFER *buffer, size_t needed_free_size) { if(unlikely(buffer->size - buffer->len < needed_free_size)) |