Unverified Commit a33c0de2 by Patrick Steinhardt Committed by GitHub

Merge pull request #5172 from bk2204/cache-efficient-eviction

Evict cache items more efficiently
parents e86d75f3 770b91b1
...@@ -115,9 +115,12 @@ void git_cache_dispose(git_cache *cache) ...@@ -115,9 +115,12 @@ void git_cache_dispose(git_cache *cache)
/* Called with lock */ /* Called with lock */
static void cache_evict_entries(git_cache *cache) static void cache_evict_entries(git_cache *cache)
{ {
size_t evict_count = 8, i; size_t evict_count = git_cache_size(cache) / 2048, i;
ssize_t evicted_memory = 0; ssize_t evicted_memory = 0;
if (evict_count < 8)
evict_count = 8;
/* do not infinite loop if there's not enough entries to evict */ /* do not infinite loop if there's not enough entries to evict */
if (evict_count > git_cache_size(cache)) { if (evict_count > git_cache_size(cache)) {
clear_cache(cache); clear_cache(cache);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment