diff options
Diffstat (limited to 'src/lazyfree.c')
-rw-r--r-- | src/lazyfree.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lazyfree.c b/src/lazyfree.c index 6127abe77..1cc521cbd 100644 --- a/src/lazyfree.c +++ b/src/lazyfree.c @@ -1,6 +1,7 @@ #include "server.h" #include "bio.h" #include "atomicvar.h" +#include "functions.h" static redisAtomic size_t lazyfree_objects = 0; static redisAtomic size_t lazyfreed_objects = 0; @@ -46,6 +47,15 @@ void lazyFreeLuaScripts(void *args[]) { atomicIncr(lazyfreed_objects,len); } +/* Release the functions ctx. */ +void lazyFreeFunctionsCtx(void *args[]) { + functionsCtx *f_ctx = args[0]; + size_t len = functionsLen(f_ctx); + functionsCtxFree(f_ctx); + atomicDecr(lazyfree_objects,len); + atomicIncr(lazyfreed_objects,len); +} + /* Release replication backlog referencing memory. */ void lazyFreeReplicationBacklogRefMem(void *args[]) { list *blocks = args[0]; @@ -193,6 +203,16 @@ void freeLuaScriptsAsync(dict *lua_scripts) { } } +/* Free functions ctx, if the functions ctx contains enough functions, free it in async way. */ +void freeFunctionsAsync(functionsCtx *f_ctx) { + if (functionsLen(f_ctx) > LAZYFREE_THRESHOLD) { + atomicIncr(lazyfree_objects,functionsLen(f_ctx)); + bioCreateLazyFreeJob(lazyFreeFunctionsCtx,1,f_ctx); + } else { + functionsCtxFree(f_ctx); + } +} + /* Free replication backlog referencing buffer blocks and rax index. */ void freeReplicationBacklogRefMemAsync(list *blocks, rax *index) { if (listLength(blocks) > LAZYFREE_THRESHOLD || |