summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-07-18 19:17:40 +0200
committerGitHub <noreply@github.com>2019-07-18 19:17:40 +0200
commita33c0de2edace210ccb99f2dc886971b8fa68382 (patch)
treead33671a8820e9c03a0b990e056da2a919ba5588
parente86d75f3b2ce6d359520d035b8b21c70545c8cf0 (diff)
parent770b91b114467c5e6b7d3edc884e0fef6475c0bc (diff)
downloadlibgit2-a33c0de2edace210ccb99f2dc886971b8fa68382.tar.gz
Merge pull request #5172 from bk2204/cache-efficient-eviction
Evict cache items more efficiently
-rw-r--r--src/cache.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/cache.c b/src/cache.c
index 3128e40c5..32ba993b0 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);