Skip to content

Commit

Permalink
check test
Browse files Browse the repository at this point in the history
  • Loading branch information
hwware committed Dec 3, 2024
1 parent 5a6714d commit f44c517
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/evict.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ int getMaxmemoryState(size_t *total, size_t *logical, size_t *tofree, float *lev
if (mem_used <= maxmemory) return C_OK;

/* Compute how much memory we need to free. */
mem_tofree = mem_used - server.key_eviction_memory_temp;
mem_tofree = mem_used - server.key_eviction_memory;

if (logical) *logical = mem_used;
if (tofree) *tofree = mem_tofree;
Expand Down Expand Up @@ -546,7 +546,7 @@ int performEvictions(void) {
int replicas = listLength(server.replicas);
int result = EVICT_FAIL;

if (getMaxmemoryState(&mem_reported, &mem_used, &mem_tofree, NULL, server.key_eviction_memory_temp) == C_OK) {
if (getMaxmemoryState(&mem_reported, &mem_used, &mem_tofree, NULL, server.key_eviction_memory) == C_OK) {
result = EVICT_OK;
goto update_metrics;
}
Expand Down Expand Up @@ -712,7 +712,7 @@ int performEvictions(void) {
* across the dbAsyncDelete() call, while the thread can
* release the memory all the time. */
if (server.lazyfree_lazy_eviction) {
if (getMaxmemoryState(NULL, NULL, NULL, NULL, server.key_eviction_memory_temp) == C_OK) {
if (getMaxmemoryState(NULL, NULL, NULL, NULL, server.key_eviction_memory) == C_OK) {
break;
}
}
Expand All @@ -731,7 +731,7 @@ int performEvictions(void) {
}
}

if (mem_freed >= (long long)(mem_used - server.key_eviction_memory_temp)) {
if (mem_freed >= (long long)(mem_used - server.key_eviction_memory)) {
/* at this point, the memory is OK, or we have reached the time limit */
result = (isEvictionProcRunning) ? EVICT_RUNNING : EVICT_OK;
} else {
Expand All @@ -746,7 +746,7 @@ int performEvictions(void) {
mstime_t lazyfree_latency;
latencyStartMonitor(lazyfree_latency);
while (bioPendingJobsOfType(BIO_LAZY_FREE) && elapsedUs(evictionTimer) < eviction_time_limit_us) {
if (getMaxmemoryState(NULL, NULL, NULL, NULL, server.key_eviction_memory_temp) == C_OK) {
if (getMaxmemoryState(NULL, NULL, NULL, NULL, server.key_eviction_memory) == C_OK) {
result = EVICT_OK;
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -5627,7 +5627,7 @@ sds genValkeyInfoString(dict *section_dict, int all_sections, int everything) {
char used_memory_scripts_hmem[64];
char used_memory_rss_hmem[64];
char maxmemory_hmem[64];
char key_eviction_memory_temp_hmem[64];
char key_eviction_memory_hmem[64];
size_t zmalloc_used = zmalloc_used_memory();
size_t total_system_mem = server.system_memory_size;
const char *evict_policy = evictPolicyToString();
Expand All @@ -5649,7 +5649,7 @@ sds genValkeyInfoString(dict *section_dict, int all_sections, int everything) {
bytesToHuman(used_memory_scripts_hmem, sizeof(used_memory_scripts_hmem), mh->lua_caches + mh->functions_caches);
bytesToHuman(used_memory_rss_hmem, sizeof(used_memory_rss_hmem), server.cron_malloc_stats.process_rss);
bytesToHuman(maxmemory_hmem, sizeof(maxmemory_hmem), server.maxmemory);
bytesToHuman(key_eviction_memory_temp_hmem, sizeof(key_eviction_memory_temp_hmem), server.key_eviction_memory_temp);
bytesToHuman(key_eviction_memory_hmem, sizeof(key_eviction_memory_hmem), server.key_eviction_memory);

if (sections++) info = sdscat(info, "\r\n");
info = sdscatprintf(
Expand Down Expand Up @@ -5689,8 +5689,8 @@ sds genValkeyInfoString(dict *section_dict, int all_sections, int everything) {
"maxmemory_human:%s\r\n", maxmemory_hmem,
"maxmemory_policy:%s\r\n", evict_policy,
"maxmemory_soft_scale:%d\r\n", server.maxmemory_soft_scale,
"key_eviction_memory_temp:%lld\r\n", server.key_eviction_memory_temp,
"key_eviction_memory_temp_human:%s\r\n", key_eviction_memory_temp_hmem,
"key_eviction_memory:%lld\r\n", server.key_eviction_memory,
"key_eviction_memory_human:%s\r\n", key_eviction_memory_hmem,
"allocator_frag_ratio:%.2f\r\n", mh->allocator_frag,
"allocator_frag_bytes:%zu\r\n", mh->allocator_frag_bytes,
"allocator_rss_ratio:%.2f\r\n", mh->allocator_rss,
Expand Down
3 changes: 1 addition & 2 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,6 @@ struct valkeyServer {
int maxmemory_policy; /* Policy for key eviction */
int maxmemory_samples; /* Precision of random sampling */
int maxmemory_soft_scale; /* Percent of the soft maxmemory value */
unsigned long long key_eviction_memory_temp; /* Memory bytes to begin the key eviction process */
unsigned long long key_eviction_memory; /* Memory bytes to begin the key eviction process */
int maxmemory_eviction_tenacity; /* Aggressiveness of eviction processing */
int lfu_log_factor; /* LFU logarithmic counter factor. */
Expand Down Expand Up @@ -3039,7 +3038,7 @@ static inline int canUseSharedObject(void) {
return server.maxmemory == 0 || !(server.maxmemory_policy & MAXMEMORY_FLAG_NO_SHARED_INTEGERS);
}
static inline void updateSoftMaxmemoryValue(void) {
server.key_eviction_memory_temp = (unsigned long long)server.maxmemory / 100.0 * (100 - server.maxmemory_soft_scale);
server.key_eviction_memory = (unsigned long long)server.maxmemory / 100.0 * (100 - server.maxmemory_soft_scale);
}
#define sdsEncodedObject(objptr) (objptr->encoding == OBJ_ENCODING_RAW || objptr->encoding == OBJ_ENCODING_EMBSTR)

Expand Down

0 comments on commit f44c517

Please sign in to comment.