summaryrefslogtreecommitdiff
path: root/src/defrag.c
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2018-07-18 10:16:33 +0300
committerOran Agra <oran@redislabs.com>2018-07-18 10:16:33 +0300
commitf89c93c8adf2dea395224c5c65d82e90aa323bfd (patch)
treec1a0a8fe69caa4e99854c13970120943bd1ca2a8 /src/defrag.c
parentcefe21d28a75f4fdbf24823ce42e777c2b9d5c6f (diff)
downloadredis-f89c93c8adf2dea395224c5c65d82e90aa323bfd.tar.gz
make active defrag test more stable
on slower machines, the active defrag test tended to fail. although the fragmentation ratio was below the treshold, the defragger was still in the middle of a scan cycle. this commit changes: - the defragger uses the current fragmentation state, rather than the cache one that is updated by server cron every 100ms. this actually fixes a bug of starting one excess scan cycle - the test lets the defragger use more CPU cycles, in hope that the defrag will be faster, but also give it more time before we give up.
Diffstat (limited to 'src/defrag.c')
-rw-r--r--src/defrag.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/defrag.c b/src/defrag.c
index b25fceb1e..d67b6e253 100644
--- a/src/defrag.c
+++ b/src/defrag.c
@@ -867,9 +867,8 @@ void defragDictBucketCallback(void *privdata, dictEntry **bucketref) {
* or not, a false detection can cause the defragmenter to waste a lot of CPU
* without the possibility of getting any results. */
float getAllocatorFragmentation(size_t *out_frag_bytes) {
- size_t resident = server.cron_malloc_stats.allocator_resident;
- size_t active = server.cron_malloc_stats.allocator_active;
- size_t allocated = server.cron_malloc_stats.allocator_allocated;
+ size_t resident, active, allocated;
+ zmalloc_get_allocator_info(&allocated, &active, &resident);
float frag_pct = ((float)active / allocated)*100 - 100;
size_t frag_bytes = active - allocated;
float rss_pct = ((float)resident / allocated)*100 - 100;