Skip to content

Commit a33c0de

Browse files
authored
Merge pull request libgit2#5172 from bk2204/cache-efficient-eviction
Evict cache items more efficiently
2 parents e86d75f + 770b91b commit a33c0de

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cache.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,12 @@ void git_cache_dispose(git_cache *cache)
115115
/* Called with lock */
116116
static void cache_evict_entries(git_cache *cache)
117117
{
118-
size_t evict_count = 8, i;
118+
size_t evict_count = git_cache_size(cache) / 2048, i;
119119
ssize_t evicted_memory = 0;
120120

121+
if (evict_count < 8)
122+
evict_count = 8;
123+
121124
/* do not infinite loop if there's not enough entries to evict */
122125
if (evict_count > git_cache_size(cache)) {
123126
clear_cache(cache);

0 commit comments

Comments
 (0)