with config
This commit is contained in:
parent
a464a7173d
commit
e3a1ea3928
@ -430,15 +430,16 @@ int getMaxmemoryState(size_t *total, size_t *logical, size_t *tofree, float *lev
|
|||||||
if (g_pserver->FRdbSaveInProgress() && !cserver.fForkBgSave)
|
if (g_pserver->FRdbSaveInProgress() && !cserver.fForkBgSave)
|
||||||
maxmemory = static_cast<size_t>(maxmemory*1.2);
|
maxmemory = static_cast<size_t>(maxmemory*1.2);
|
||||||
|
|
||||||
/* If available system memory is below a certain threshold, force eviction */
|
/* If there is less than a configurable percent of free system memory, force eviction */
|
||||||
long long sys_available_mem_buffer = 0;
|
bool mem_rss_max_exceeded;
|
||||||
if (g_pserver->force_eviction_percent && g_pserver->cron_malloc_stats.sys_total) {
|
if (g_pserver->force_eviction_percent && g_pserver->cron_malloc_stats.sys_total) {
|
||||||
float available_mem_ratio = (float)(100 - g_pserver->force_eviction_percent)/100;
|
float sys_total_ratio = (float)(100 - g_pserver->force_eviction_percent)/100;
|
||||||
size_t min_available_mem = static_cast<size_t>(g_pserver->cron_malloc_stats.sys_total * available_mem_ratio);
|
size_t mem_rss_max = static_cast<size_t>(g_pserver->cron_malloc_stats.sys_total * sys_total_ratio);
|
||||||
sys_available_mem_buffer = static_cast<long>(g_pserver->cron_malloc_stats.sys_available - min_available_mem);
|
mem_rss_max_exceeded = g_pserver->cron_malloc_stats.process_rss > mem_rss_max;
|
||||||
if (sys_available_mem_buffer < 0) {
|
if (mem_rss_max_exceeded) {
|
||||||
long long mem_threshold = mem_reported + sys_available_mem_buffer;
|
/* This will always set maxmemory < mem_reported */
|
||||||
maxmemory = ((long long)maxmemory < mem_threshold) ? maxmemory : static_cast<size_t>(mem_threshold);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user