diff options
author | Salvatore Sanfilippo <antirez@gmail.com> | 2020-05-20 15:17:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-20 15:17:02 +0200 |
commit | af34245692214d778268d2c3afd795255530a7ec (patch) | |
tree | dbd563607e11c608248c581ec2fa37735ddc1faf /src/defrag.c | |
parent | 23a85ba191ed4d42cc88b76972dc3cb409e765dc (diff) | |
parent | 88d71f479338c1a70fac15ea37f87315f9401f99 (diff) | |
download | redis-af34245692214d778268d2c3afd795255530a7ec.tar.gz |
Merge pull request #7289 from oranagra/defrag_edge_case
fix a rare active defrag edge case bug leading to stagnation
Diffstat (limited to 'src/defrag.c')
-rw-r--r-- | src/defrag.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/defrag.c b/src/defrag.c index e729297a5..6e5296632 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -43,7 +43,7 @@ /* this method was added to jemalloc in order to help us understand which * pointers are worthwhile moving and which aren't */ -int je_get_defrag_hint(void* ptr, int *bin_util, int *run_util); +int je_get_defrag_hint(void* ptr); /* forward declarations*/ void defragDictBucketCallback(void *privdata, dictEntry **bucketref); @@ -55,18 +55,11 @@ dictEntry* replaceSateliteDictKeyPtrAndOrDefragDictEntry(dict *d, sds oldkey, sd * when it returns a non-null value, the old pointer was already released * and should NOT be accessed. */ void* activeDefragAlloc(void *ptr) { - int bin_util, run_util; size_t size; void *newptr; - if(!je_get_defrag_hint(ptr, &bin_util, &run_util)) { - server.stat_active_defrag_misses++; - return NULL; - } - /* if this run is more utilized than the average utilization in this bin - * (or it is full), skip it. This will eventually move all the allocations - * from relatively empty runs into relatively full runs. */ - if (run_util > bin_util || run_util == 1<<16) { + if(!je_get_defrag_hint(ptr)) { server.stat_active_defrag_misses++; + size = zmalloc_size(ptr); return NULL; } /* move this allocation to a new allocation. |