diff --git a/README.md b/README.md index 38528d4..dcba5bb 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,10 @@ You can check [my own Maloja page](https://maloja.krateng.ch) to see what it loo ## Table of Contents * [Why not Last.fm / Libre.fm / GNU FM?](#why-not-lastfm--librefm--gnu-fm) * [How to install](#how-to-install) + * [Environment](#environment) * [New Installation](#new-installation) * [Update](#update) + * [Docker](#docker) * [How to use](#how-to-use) * [Basic control](#basic-control) * [Data](#data) @@ -40,6 +42,10 @@ Also neat: You can use your **custom artist or track images**. ## How to install +### Environment + +I can support you with issues best if you use **Alpine Linux**. In my experience, **2-4 GB RAM** should do nicely. + ### New Installation 1) Make sure you have Python 3.5 or higher installed. You also need some basic packages that should be present on most systems, but I've provided simple shell scripts for Alpine and Ubuntu to get everything you need. diff --git a/maloja/data_files/settings/default.ini b/maloja/data_files/settings/default.ini index 589933c..38f0bed 100644 --- a/maloja/data_files/settings/default.ini +++ b/maloja/data_files/settings/default.ini @@ -59,7 +59,7 @@ SCROBBLES_GOLD = 250 SCROBBLES_PLATINUM = 500 SCROBBLES_DIAMOND = 1000 # name for comparisons -NAME = None +NAME = "A Maloja User" [Misc] diff --git a/maloja/database.py b/maloja/database.py index d56fa0d..aefe140 100644 --- a/maloja/database.py +++ b/maloja/database.py @@ -1126,10 +1126,7 @@ def db_query_cached(**kwargs): elif eligible_temporary_caching: cache_query[key] = result if use_psutil: - ramprct = psutil.virtual_memory().percent - if ramprct > cmp: - log("{prct} RAM usage, dumping temporary caches!".format(prct=ramprct),module="debug") - invalidate_caches() + reduce_caches_if_low_ram() return result @@ -1165,10 +1162,7 @@ def db_aggregate_cached(**kwargs): elif eligible_temporary_caching: cache_aggregate[key] = result if use_psutil: - ramprct = psutil.virtual_memory().percent - if ramprct > cmp: - log("{prct} RAM usage, dumping temporary caches!".format(prct=ramprct),module="debug") - invalidate_caches() + reduce_caches_if_low_ram() return result @@ -1178,6 +1172,21 @@ def invalidate_caches(): cache_aggregate.clear() log("Database caches invalidated.") +def reduce_caches(to=0.75): + global cache_query, cache_aggregate + for c in cache_query, cache_aggregate: + currentsize = len(c) + targetsize = int(currentsize * to) + c.set_size(targetsize) + c.set_size(csz) + +def reduce_caches_if_low_ram(): + ramprct = psutil.virtual_memory().percent + if ramprct > cmp: + log("{prct}% RAM usage, reducing temporary caches!".format(prct=ramprct),module="debug") + ratio = (cmp / ramprct) ** 3 + reduce_caches(to=ratio) + #### ## Database queries ####