Skip to content
Browse files

better swapout policy while loading RDB file

  • Loading branch information...
1 parent 2691b01 commit 1bc183731d2a464e9ec528506b1792aa98b1621d @antirez committed Jun 2, 2010
Showing with 6 additions and 1 deletion.
  1. +6 −1 redis.c
View
7 redis.c
@@ -4076,6 +4076,7 @@ static int rdbLoad(char *filename) {
}
while(1) {
robj *key, *val;
+ int force_swapout;
expiretime = -1;
/* Read type. */
@@ -4140,9 +4141,13 @@ static int rdbLoad(char *filename) {
continue;
}
+ force_swapout = 0;
+ if ((zmalloc_used_memory() - server.vm_max_memory) > 1024*1024*32)
+ force_swapout = 1;
+
/* If we have still some hope of having some value fitting memory
* then we try random sampling. */
- if (!swap_all_values && server.vm_enabled && (loadedkeys % 5000) == 0) {
+ if (!swap_all_values && server.vm_enabled && force_swapout) {
while (zmalloc_used_memory() > server.vm_max_memory) {
if (vmSwapOneObjectBlocking() == REDIS_ERR) break;
}

0 comments on commit 1bc1837

Please sign in to comment.
Something went wrong with that request. Please try again.