From 4c6b40e42f695a5cf78548796a77a45ad77a48b0 Mon Sep 17 00:00:00 2001 From: Krateng Date: Sat, 13 Jun 2020 17:42:59 +0200 Subject: [PATCH] Added some sanity checks to cache reduction --- maloja/database.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/maloja/database.py b/maloja/database.py index d275db6..7fb9aa7 100644 --- a/maloja/database.py +++ b/maloja/database.py @@ -1179,9 +1179,10 @@ def reduce_caches(to=0.75): global cache_query, cache_aggregate, cache_query_perm, cache_aggregate_perm for c in cache_query, cache_aggregate, cache_query_perm, cache_aggregate_perm: currentsize = len(c) - targetsize = int(currentsize * to) - c.set_size(targetsize) - c.set_size(csz) + if currentsize > 100: + targetsize = max(int(currentsize * to),10) + c.set_size(targetsize) + c.set_size(csz) def reduce_caches_if_low_ram(): ramprct = psutil.virtual_memory().percent