Shairport-sync: setting niceness of systemd service

Created on 20 Jan 2016  Â·  8Comments  Â·  Source: mikebrady/shairport-sync

Hi everbody,

I tried my best figuring this out on my own, but did not succeed. I have the impression that manually lowering the processes niceness level using sudo htop significantly reduces the amount of drop outs I was previously reporting on.

Unfortunately I am unable to find out how to adapt /usr/lib/systemd/system/shairport-sync.service to that the service is started with a niceness level of for example -15. Any hints are highly appreciated.

Thanks!
Peter

question

Most helpful comment

All 8 comments

It would be interesting to know the result of this. Is your system busy doing other things as well as running Shairport Sync?

Thank you @roblan, I actually had tried exactly this. Now I noticed that the correct file to edit is /lib/systemd/system/shairport-sync.service. The statement Nice=-15 needs to be added in the section [Service].

@mikebrady, I did not yet test the result thoroughly, since it is quite late already. By now my Pi 2 B is running several services (apache2, owncloud, kodi, shairport-sync, netatalk to serve as a timecapsule). Almost everything runs nice and smooth. The only thing that keeps me uneasy are the sound stutters during playback over airplay. I observed those also while the system was exclusively running shairport-sync. As noted earlier, I prefer stable playback over very short buffers or synced multiple devices, as I am only playing to one receiving raspberry.

Thanks for the update, Peter. I must say that I'd be troubled by the stuttering when Shairport Sync is playing exclusively – that really shouldn't be happening, and it would be worth investigating the cause. Just to clarify, when you say "the system was exclusively running shairport-sync", do you mean that the system was a fresh image of the OS with just Shairport Sysc installed? What I'm wondering about is, if other software was installed but apparently disabled, it might still be grabbing the processor from time to time for some hidden background process. Just a thought...

The current situation troubles me as well. let me find another SD card and
do a test with a fresh installation, to see if my statement really holds
true. If yes, I would additionally have to temporarily remove the hifiberry
dac to simplify the setup even further. I am following the Linux repository
of the raspberry pi foundation and there is currently development going on
for the 4.4 kernel, regarding i2s clocks and this relates to audio playback
via DACs.

I'll close this issue, since the original issue of setting the niceness was solved. Shortly I'll create an issue with my updated findings on playback robustness.

Note that you shouldn't edit the original file at /lib/systemd/system/shairport-sync.service. If you need to make substantial changes to the supplied file, copy it to /etc/systemd/system and edit the copy. For single settings, create a "drop-in" file such as /etc/systemd/system/shairport-sync.service.d/nice.conf containing only the section name and setting you want to change. Details:

https://www.freedesktop.org/software/systemd/man/systemd.unit.html

@SpareSimian and an easier way to do a similar thing is via systemctl edit shairport-sync, which will open an editor of override file, then magically run systemctl daemon-reload after saving :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LinusU picture LinusU  Â·  4Comments

choppedfish picture choppedfish  Â·  8Comments

janlei0524 picture janlei0524  Â·  8Comments

ContraVarus picture ContraVarus  Â·  7Comments

rockrabbit picture rockrabbit  Â·  6Comments