Replies: 5 comments 17 replies
-
I/O isn't really an issue if you get a decent SD card. I've had the same SD card in 4 different versions of Pi's going back for over 5 years and have re-imaged and abused them more than I care to admit. If disk I/O is such a big deal you should just set the Pi to boot read only in raspi-config. My gut tells me that you're entering unnecessary optimization territory. An alternative if you have a reasonable sized SD-card that will reduce disk and network I/O and theoretically boost performance a tiny bit is to configure librespot to cache audio files to disk. I have it set up with a cache size of 2 GB (16 GB SD card) on my Pi Zero v2 and 16 GB on my home server (the server is not a Pi) You can fit a lot of 320kbps Vorbis' in 2 GB that later do not need to be re-downloaded. That being said I'm open to a tmpfs as default so long as it doesn't break disk caching or otherwise negatively affect the operation of Raspotify in any way. Put in a PR and I will review it. |
Beta Was this translation helpful? Give feedback.
-
Well, so far I also never had issues with any SD-card, but now it appeared very suddenly and slowed down things extremely. However, I have to admit that I used the SC-card for quite some years reformatting it several times. Of course this also depends on how occupied the card is. Since a lot of people even advise to put /var/log on a tmpfs I wanted to check the I/O in advance. During normal usage I found, that librespot by far caused the highest I/O for me. I will put in a PR and we will see. |
Beta Was this translation helpful? Give feedback.
-
Done: |
Beta Was this translation helpful? Give feedback.
-
First post to any kind of Github project, so please excuse any mistakes in etiquette. Not really a bug, but for really long tracks the tmpfs can fill up and cause Raspotify to crash. I recently updated my installation to 0.42.6 and found that Raspotify would crash when playing a 9 hour track (I play white noise to help my infant daughter sleep). Adding TMPDIR=/tmp to the conf file fixes the problem (revert temp file to main SD card). Making a note here in case someone else has the same use case. |
Beta Was this translation helpful? Give feedback.
-
raspi-config when you get your system all set up the way you want it, then enable the overlay file system |
Beta Was this translation helpful? Give feedback.
-
First of all, thanks a lot for the excellent work!
I am using raspotify since years on a raspberryPi. Recently on my pi3 my SD-card died because of too many write operations over the last years. On my new setup (same pi3 with rasberrypios 11, bullseye) I wanted to improve things and reduce the number of dics writes.
Using iotop, i figured out, that a large portion of the dics writes is caused by librespot. Hence, I carefully checked that audio caching is really disabled. However, the dics writes were caused by the currently played song. The song is not directly streamed, but temporarily "downloaded" to the path given in librespots environment variable TMPDIR and deleted directly afterwards. This causes a high IO on the SD-card.
To circumvent this behaviour the idea was to write the currently played song directly to a RAM-disc (tmpfs) instead of the SD-card. So here is what I did.
As mentioned, per default librespot writes the downloaded file to its temporary directory given in the Environment variable TMPDIR. So in raspotifys systemd service one simply has to point that variable to a path located in a tmpfs. To make the changes persistent and not being overwritten with the next raspotify update do not edit raspotifys systemd service configuration file directly, but create an override file using:
sudo systemctl edit raspotify.service
This generates an override file and automatically opens that file in nano. Simply add
and save the file. The two lines define a runtime directory which is mounted as tmpfs (ramdisc) located at /run/raspotify and sets the Environment variable TMPDIR to exactly that location. Just save and issue the commands
From now on the file will only be written to RAM which protects your SD-card from write cycles when music is played back.
If you additionally want to control whether to write to SD-card or to RAM you can add the following line to your /etc/raspotify/conf
TMPDIR=/tmp
If uncommented raspotify writes to the SD-card directly (to its private temp directory at /tmp/systemd-private-[hash]-raspotify.service).
If commented it writes to a tmpfs located at /run/raspotify
This is what helped for me, maybe its worth thinking about to include it in the official release, which makes the systemd override file unnecessary.
Beta Was this translation helpful? Give feedback.
All reactions