this post was submitted on 05 Jul 2023
64 points (97.1% liked)

Selfhosted

40246 readers
1101 users here now

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:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

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

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

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

top 3 comments
sorted by: hot top controversial new old
[–] croxis@kbin.social 3 points 1 year ago (1 children)

Does it use Linux's usual filter system cache?

[–] ThetaDev@lemmy.fmhy.ml 4 points 1 year 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).

[–] johntash@eviltoast.org 2 points 1 year ago

I've never heard of vmtouch before but it sounds pretty useful, and simpler than setting up a ram disk.

Thanks for the tip.