Algorithm for converting tenacity (0-100) to a time limit. */
| 593 | |
| 594 | /* Algorithm for converting tenacity (0-100) to a time limit. */ |
| 595 | static 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 | |
| 612 | void evict(redisDb *db, robj *keyobj) { |
| 613 | mstime_t eviction_latency; |