mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[GH-ISSUE #567] Uses unexpected level of CPU while idle #362
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#362
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mdekstrand on GitHub (Jan 18, 2021).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/567
I am noticing an unexpectedly high level of CPU usage in librespot while it is idle. This is with Librespot 0.1.3 built in release mode with the Rodio backend (from the Alpine package).
On my Raspberry Pi Zero W, with a single-core 1GHz ARM processor (Broadcom 2835, ARMv6 ISA) and a HiFiBerry DAC Zero hat, the librespot process is constantly using 12-14% CPU. An
straceindicates that it's receiving messages from various machines on the local LAN, but not a large number of them (one ever 5 seconds or so). During playback CPU usage is about 30%.I don't know what is going on with this, but it doesn't seem like an idle music player should use so much CPU.
@ashthespy commented on GitHub (Jan 18, 2021):
Could you confirm if you see a reduction when using the ALSA back end directly? IIRC, Rodio has some overhead, that becomes noticeable on less powerful devices.
@mdekstrand commented on GitHub (Jan 18, 2021):
I'll try that. If it does reduce overhead, would you recommend building the Alpine package with the ALSA backend across the board? That's the package build script did before I took it over, but it was building a git snapshot from 2018.
@ashthespy commented on GitHub (Jan 20, 2021):
Some more context https://github.com/librespot-org/librespot/pull/277#issuecomment-473614497
The ALSA back-end is quite a bare bones, but if it serves your purpose, then go for it ;-)
@mdekstrand commented on GitHub (Jan 21, 2021):
I have rebuilt with the Alsa backend and confirmed that it idles without CPU. It looks like RustAudio/rodio#299 may be the relevant Rodio issue tracking this.
On the package build: I've taken over maintaining the package in the Alpine testing repos, and would like to provide a generally-useful build for Alpine users generally. It seems that at least on the
armhfarchitecture, LibreSpot will usually be running on low-power machines, and so the alsa build might be useful default. I'm going to also ping on an Alpine support channel for suggestions, but as upstream if you've got recommendations for downstream packaging I'm open to the input.I see a few options:
librespot-alsa,librespot-pulseaudio, etc.).@ashthespy commented on GitHub (Jan 21, 2021):
You could always build in both back-ends, and let users choose?
@mdekstrand commented on GitHub (Jan 21, 2021):
Thanks! Didn't realize that was possible. Will give it a try.
@mdekstrand commented on GitHub (Jan 26, 2021):
Since the root cause of this seems to be a Rodio issue, I am fine with this issue being closed if that's what project maintainers want to do. Not closing it myself in case you want to leave it open to check librespot's cpu usage after rodio addresses the problem (if they do).
@sashahilton00 commented on GitHub (Jan 26, 2021):
Looking over that issue, rodeo appears to return a
Sinkin most instances, so it might be possible for librespot to drop the sink after playback concludes. I may be wrong, but I thought someone implemented this feature a while back where the sink was deliberately kept open to prevent clicking when the sink was opened/closed. If so, it might be possible to add a runtime flag to close the sink after playback or keep it open depending on what the user wants.@ashthespy commented on GitHub (Jan 26, 2021):
If my foggy memory serves me right, @willstott101 was also exploring ditching Rodio, and using
cpaldirectly..EDIT: bingo! https://github.com/librespot-org/librespot/issues/317#issuecomment-529198164
@roderickvd commented on GitHub (May 24, 2021):
We're seriously considering switching from Rodio to cpal, with some initial code already proposed. For now I'll be closing this issue. The buffering on Rodio-on-Alsa is indeed not so great, so better to use the direct
alsabackend.