Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove minmemory-os configuration parameter.

  • Loading branch information...
commit c8416279d32b7721533596800571b8551e7ad75f 1 parent a0d1eaa
@yossigo yossigo authored
Showing with 0 additions and 92 deletions.
  1. +0 −6 redis.conf
  2. +0 −2  src/config.c
  3. +0 −83 src/redis.c
  4. +0 −1  src/redis.h
View
6 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
View
2  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;
View
83 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;
View
1  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 */
Please sign in to comment.
Something went wrong with that request. Please try again.