vmtouch - Lifesaver when selfhosting with slow storage

3 years ago by ThetaDev to c/selfhosted

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: https://www.baeldung.com/linux/file-cache-ram

load all comments
croxis 3 points 3 years ago

Does it use Linux's usual filter system cache?

path: 0 852140, hotness: undefined, score: 3, children: 1
ThetaDev 4 points 3 years ago

Yes, it does. You can also use the tool to check if a file is cached (just run it without any arguments for that).

path: 0 852140 852429, hotness: undefined, score: 4, children: 0
selfhosted
selfhosted

@lemmy.world

login for more options
62950
6792
5617

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

Detailed Rules Post

  1. Be civil.

  2. No spam.

  3. Posts are to be related to self-hosting.

  4. Don't duplicate the full text of your blog or readme if you're providing a link.

  5. Submission headline should match the article title.

  6. No trolling.

  7. Promotion posts require active participation, with an account that is at least 30 days old. F/LOSS without a paywall has exceptions, with requirements. See the rules link for details. Tags [CBH] or [AIP] are required, see the links in Rule 8 for details.

  8. AI-related discussions and AI-involved promotional posts have additional requirements for tagging, as noted in Rule 7 and the AI & Promotional Post Expanded Rules post, and find example disclosures here.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

go to feed...