diff options
author | Yossi Gottlieb <yossigo@gmail.com> | 2013-07-09 12:22:12 +0300 |
---|---|---|
committer | Yossi Gottlieb <yossigo@gmail.com> | 2013-07-09 12:22:12 +0300 |
commit | c8416279d32b7721533596800571b8551e7ad75f (patch) | |
tree | 2957687f4e731662ae9033f44d6ecc2d451b876d | |
parent | a0d1eaa5b63cd2ef94a54660de3d66ce06ce05e6 (diff) | |
download | redis-2.6.14-2.tar.gz |
Remove minmemory-os configuration parameter.2.6.14-2
-rwxr-xr-x | redis.conf | 6 | ||||
-rwxr-xr-x | src/config.c | 2 | ||||
-rwxr-xr-x | src/redis.c | 83 | ||||
-rwxr-xr-x | src/redis.h | 1 |
4 files changed, 0 insertions, 92 deletions
diff --git a/redis.conf b/redis.conf index a4a3c7b17..3007bfaa1 100755 --- a/redis.conf +++ b/redis.conf @@ -356,12 +356,6 @@ slave-priority 100 # # maxmemory-samples 3 -# Define the minimum OS memory threshold allowed before eviction begins. This -# is checked perioedically and eviction will be attempted for 1/2 of the delta -# between the free memory and required spare. If 0 is specified, this is -# disabled. -# minmemory-os 0 - ############################## APPEND ONLY MODE ############################### # By default Redis asynchronously dumps the dataset on disk. This mode is diff --git a/src/config.c b/src/config.c index bd1f14f6b..24f859707 100755 --- a/src/config.c +++ b/src/config.c @@ -212,8 +212,6 @@ void loadServerConfigFromString(char *config) { } } else if (!strcasecmp(argv[0],"maxmemory") && argc == 2) { server.maxmemory = memtoll(argv[1],NULL); - } else if (!strcasecmp(argv[0],"minmemory-os") && argc == 2) { - server.minmemory_os = memtoll(argv[1],NULL); } else if (!strcasecmp(argv[0],"maxmemory-policy") && argc == 2) { if (!strcasecmp(argv[1],"volatile-lru")) { server.maxmemory_policy = REDIS_MAXMEMORY_VOLATILE_LRU; diff --git a/src/redis.c b/src/redis.c index 8f73cf8bf..18a35bf6b 100755 --- a/src/redis.c +++ b/src/redis.c @@ -823,84 +823,6 @@ void clientsCron(void) { } } -#ifdef __linux__ -long long int getFreeOSMemory(void) { - FILE *meminfo_file; - char buf[128]; - long long int memfree_value = -1; - long long int buffers_value = -1; - long long int cached_value = -1; - long long int memfree = -1; - - meminfo_file = fopen("/proc/meminfo", "r"); - if (!meminfo_file) - return -1; - while (fgets(buf, sizeof(buf)-1, meminfo_file) != NULL) { - char *p = NULL; - char *k; - char *arg; - if (!(k = strtok_r(buf, " ", &p))) - break; /* parse error */ - if (!(arg = strtok_r(NULL, " ", &p))) - break; /* parse error */ - if (strcmp(k, "MemFree:") == 0) { - memfree_value = strtoull(arg, &p, 10); - if (!p || *p != '\0') - memfree_value = -1; /* parse error */ - } else if (strcmp(k, "Buffers:") == 0) { - buffers_value = strtoull(arg, &p, 10); - if (!p || *p != '\0') - buffers_value = -1; /* parse error */ - } else if (strcmp(k, "Cached:") == 0) { - cached_value = strtoull(arg, &p, 10); - if (!p || *p != '\0') - cached_value = -1; /* parse error */ - } - if (memfree_value != -1 && - buffers_value != -1 && - cached_value != -1) { - memfree = memfree_value + buffers_value + cached_value; - break; - } - } - fclose(meminfo_file); - if (memfree > 0) - memfree *= 1024; - - return memfree; -} -#else -#error "Implement getFreeOSMemory for this platform first." -#endif - -void checkOSMemory(void) { - /* Called periodically if minmemory_os is defined, and verifies that - * enough free OS memory is reported. If not, it attempts to free 1/2 - * of the minmemory_os value. - */ - - long long int os_memfree; - - if (!server.minmemory_os) - return; - - os_memfree = getFreeOSMemory(); - if (os_memfree < 0) - return; - if ((unsigned long long) os_memfree < server.minmemory_os) { - long long int delta = server.minmemory_os - os_memfree; - - if ((long long int) zmalloc_used_memory() > (delta / 2)) { - redisLog(REDIS_WARNING, "OS Memory is low, trying to free %llu bytes.", delta / 2); - - freeMemoryIfNeeded(zmalloc_used_memory() - (delta / 2)); - } else { - redisLog(REDIS_WARNING, "OS Memory is low, but this redis is too small to attempt eviction."); - } - } -} - - /* This function handles 'background' operations we are required to do * incrementally in Redis databases, such as active key expiring, resizing, * rehashing. */ @@ -1009,11 +931,6 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { server.shutdown_asap = 0; } - /* Try to evict if OS memory is low */ - run_with_period(10000) { - checkOSMemory(); - } - /* Cancel draining mode if not polled for a long time */ if (server.draining && server.unixtime - server.last_drain_time >= 10) server.draining = 0; diff --git a/src/redis.h b/src/redis.h index 34e95693e..5f2518b36 100755 --- a/src/redis.h +++ b/src/redis.h @@ -674,7 +674,6 @@ struct redisServer { /* Limits */ unsigned int maxclients; /* Max number of simultaneous clients */ unsigned long long maxmemory; /* Max number of memory bytes to use */ - unsigned long long minmemory_os; /* OS Free memory threshold that */ int maxmemory_policy; /* Policy for key eviction */ int maxmemory_samples; /* Pricision of random sampling */ /* Blocked clients */ |