There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

vmtouch - Lifesaver when selfhosting with slow storage

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.

<pre style="background-color:#ffffff;">
<span style="color:#323232;"># Change to yes to enable running vmtouch as a daemon
</span><span style="color:#323232;">ENABLE_VMTOUCH=yes
</span><span style="color:#323232;">
</span><span style="color:#323232;"># User and group to run as
</span><span style="color:#323232;">VMTOUCH_USER_GROUP=root:root
</span><span style="color:#323232;">
</span><span style="color:#323232;"># Whitespace separated list of files and directories for vmtouch to operate on
</span><span style="color:#323232;">VMTOUCH_FILES="/apps/data/navidrome/navidrome.db"
</span><span style="color:#323232;">
</span><span style="color:#323232;"># Options to pass to vmtouch itself. See vmtouch(8).
</span><span style="color:#323232;">VMTOUCH_OPTIONS="-tld"
</span>

Now the music database is always kept in RAM, which improved the search speed to 300-600ms.

Source: www.baeldung.com/linux/file-cache-ram

johntash ,

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

Thanks for the tip.

croxis ,
@croxis@kbin.social avatar

Does it use Linux's usual filter system cache?

ThetaDev OP ,
@ThetaDev@lemmy.fmhy.ml avatar

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

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines