diff options
author | yihuang <huang@crypto.com> | 2021-02-16 22:17:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-16 16:17:38 +0200 |
commit | aab479f8cfaa4493f5618ba05cfec0e2b406e77c (patch) | |
tree | 1ee813e107dc086911e7b3066a3e1a51f09a0b35 /src/listpack_malloc.h | |
parent | fd052d2a86b1a9ace29abf2868785f0b4621b715 (diff) | |
download | redis-aab479f8cfaa4493f5618ba05cfec0e2b406e77c.tar.gz |
Optimize listpack for stream usage to avoid repeated reallocs (#6281)
Avoid repeated reallocs growing the listpack while entries are being added.
This is done by pre-allocating the listpack to near maximum size, and using
malloc_size to check if it needs realloc or not.
When the listpack reaches the maximum number of entries, we shrink it to fit it's used size.
Co-authored-by: Viktor Söderqvist <viktor@zuiderkwast.se>
Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/listpack_malloc.h')
-rw-r--r-- | src/listpack_malloc.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/listpack_malloc.h b/src/listpack_malloc.h index 401ab6f74..3a9050052 100644 --- a/src/listpack_malloc.h +++ b/src/listpack_malloc.h @@ -42,4 +42,5 @@ #define lp_malloc zmalloc #define lp_realloc zrealloc #define lp_free zfree +#define lp_malloc_size zmalloc_usable_size #endif |