Commit a33c0de2edace210ccb99f2dc886971b8fa68382

Patrick Steinhardt 2019-07-18T19:17:40

Merge pull request #5172 from bk2204/cache-efficient-eviction Evict cache items more efficiently

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/cache.c b/src/cache.c
index 3128e40..32ba993 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -115,9 +115,12 @@ void git_cache_dispose(git_cache *cache)
 /* Called with lock */
 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;
 
+	if (evict_count < 8)
+		evict_count = 8;
+
 	/* do not infinite loop if there's not enough entries to evict  */
 	if (evict_count > git_cache_size(cache)) {
 		clear_cache(cache);