port changes to 6.3
This commit is contained in:
parent
821b39acac
commit
4c3d9341fd
@ -425,6 +425,18 @@ int getMaxmemoryState(size_t *total, size_t *logical, size_t *tofree, float *lev
|
|||||||
if (g_pserver->FRdbSaveInProgress())
|
if (g_pserver->FRdbSaveInProgress())
|
||||||
maxmemory = static_cast<size_t>(maxmemory*1.2);
|
maxmemory = static_cast<size_t>(maxmemory*1.2);
|
||||||
|
|
||||||
|
/* If there is less than 10% free system memory, force eviction */
|
||||||
|
bool mem_rss_max_exceeded;
|
||||||
|
if (g_pserver->cron_malloc_stats.sys_total) {
|
||||||
|
size_t mem_rss_max = static_cast<size_t>(g_pserver->cron_malloc_stats.sys_total * 0.9);
|
||||||
|
mem_rss_max_exceeded = g_pserver->cron_malloc_stats.process_rss > mem_rss_max;
|
||||||
|
if (mem_rss_max_exceeded) {
|
||||||
|
/* This will always set maxmemory < mem_reported */
|
||||||
|
float frag_ratio = (float)g_pserver->cron_malloc_stats.process_rss / (float)mem_reported;
|
||||||
|
maxmemory = static_cast<size_t>((float)mem_rss_max / frag_ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* We may return ASAP if there is no need to compute the level. */
|
/* We may return ASAP if there is no need to compute the level. */
|
||||||
int return_ok_asap = !maxmemory || mem_reported <= maxmemory;
|
int return_ok_asap = !maxmemory || mem_reported <= maxmemory;
|
||||||
if (return_ok_asap && !level) return C_OK;
|
if (return_ok_asap && !level) return C_OK;
|
||||||
@ -435,6 +447,12 @@ int getMaxmemoryState(size_t *total, size_t *logical, size_t *tofree, float *lev
|
|||||||
size_t overhead = freeMemoryGetNotCountedMemory();
|
size_t overhead = freeMemoryGetNotCountedMemory();
|
||||||
mem_used = (mem_used > overhead) ? mem_used-overhead : 0;
|
mem_used = (mem_used > overhead) ? mem_used-overhead : 0;
|
||||||
|
|
||||||
|
/* If we've exceeded max RSS memory, we want to force evictions no matter
|
||||||
|
* what so we also offset the overhead from maxmemory. */
|
||||||
|
if (mem_rss_max_exceeded) {
|
||||||
|
maxmemory = (maxmemory > overhead) ? maxmemory-overhead : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Compute the ratio of memory usage. */
|
/* Compute the ratio of memory usage. */
|
||||||
if (level) {
|
if (level) {
|
||||||
if (!maxmemory) {
|
if (!maxmemory) {
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int g_fTestMode = false;
|
int g_fTestMode = false;
|
||||||
@ -2312,6 +2313,15 @@ void cronUpdateMemoryStats() {
|
|||||||
g_pserver->cron_malloc_stats.allocator_active = g_pserver->cron_malloc_stats.allocator_resident;
|
g_pserver->cron_malloc_stats.allocator_active = g_pserver->cron_malloc_stats.allocator_resident;
|
||||||
if (!g_pserver->cron_malloc_stats.allocator_allocated)
|
if (!g_pserver->cron_malloc_stats.allocator_allocated)
|
||||||
g_pserver->cron_malloc_stats.allocator_allocated = g_pserver->cron_malloc_stats.zmalloc_used;
|
g_pserver->cron_malloc_stats.allocator_allocated = g_pserver->cron_malloc_stats.zmalloc_used;
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
struct sysinfo sysinf;
|
||||||
|
memset(&sysinf, 0, sizeof sysinf);
|
||||||
|
if (!sysinfo(&sysinf)) {
|
||||||
|
g_pserver->cron_malloc_stats.sys_total = static_cast<size_t>(sysinf.totalram);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2014,6 +2014,7 @@ struct malloc_stats {
|
|||||||
size_t allocator_allocated;
|
size_t allocator_allocated;
|
||||||
size_t allocator_active;
|
size_t allocator_active;
|
||||||
size_t allocator_resident;
|
size_t allocator_resident;
|
||||||
|
size_t sys_total;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct socketFds {
|
typedef struct socketFds {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user