vmtouch - Lifesaver when selfhosting with slow storage
vmtouch - Lifesaver when selfhosting with slow storage
This is an automated archive made by the Lemmit Bot.
The original was posted on /r/selfhosted by /u/koveho on 2023-08-04 12:55:36.
originally posted at
I am running a ODroid HC4 as a media server with Jellyfin and Navidrome.
After expanding my music collection to about 70k tracks, Navidrome’s search performance was terrible. Searching for tracks took more than 10 seconds.
I know that Navidrome’s search just uses SQLite LIKE statements without an index, so the performance is not optimal, but it could definitely be better. However, the main reason for the bad performance was the slow microSD storage.
My ODroid may have slow storage, but it has plenty of RAM (4GB). So it should be possible to keep a 160MB database permanently cached. Turns out, there is an application that can permanently keep certain files in RAM: vmtouch
.
You can install it with apt and then run the command vmtouch -vtl database.sqlite
. This will keep the file locked in RAM as long as the program is running.
VMTouch also comes with a service to permanently keep certain files cached. To set it up, you have to edit the config file under /etc/default/vmtouch
and restart the service.
Change to yes to enable running vmtouch as a daemon
===================================================
ENABLE\_VMTOUCH=yes
User and group to run as
========================
VMTOUCH\_USER\_GROUP=root:root
Whitespace separated list of files and directories for vmtouch to operate on
============================================================================
VMTOUCH\_FILES="/apps/data/navidrome/navidrome.db"
Options to pass to vmtouch itself. See vmtouch(8).
==================================================
VMTOUCH\_OPTIONS="-tld"
Now the music database is always kept in RAM, which improved the search speed to 300-600ms.
Source: