MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / evictionTimeLimitUs

Function evictionTimeLimitUs

src/evict.cpp:595–610  ·  view source on GitHub ↗

Algorithm for converting tenacity (0-100) to a time limit. */

Source from the content-addressed store, hash-verified

593
594/* Algorithm for converting tenacity (0-100) to a time limit. */
595static unsigned long evictionTimeLimitUs() {
596 serverAssert(g_pserver->maxmemory_eviction_tenacity >= 0);
597 serverAssert(g_pserver->maxmemory_eviction_tenacity <= 100);
598
599 if (g_pserver->maxmemory_eviction_tenacity <= 10) {
600 /* A linear progression from 0..500us */
601 return 50uL * g_pserver->maxmemory_eviction_tenacity;
602 }
603
604 if (g_pserver->maxmemory_eviction_tenacity < 100) {
605 /* A 15% geometric progression, resulting in a limit of ~2 min at tenacity==99 */
606 return (unsigned long)(500.0 * pow(1.15, g_pserver->maxmemory_eviction_tenacity - 10.0));
607 }
608
609 return ULONG_MAX; /* No limit to eviction time */
610}
611
612void evict(redisDb *db, robj *keyobj) {
613 mstime_t eviction_latency;

Callers 1

performEvictionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected