-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
High CPU usage after speaker.Init()
called
#14
Comments
As mentioned in the original issue, I expect the Feel free to re-open the issue if this wasn't the problem. |
This got a new reply from the original author in the faiface/beep repo:
|
Some things to try:
Which OS are you running? Related issue: #137 |
Thanks @MarkKremer and I'm glad to see that this project lives on in another repo :) I tried updating to
I'm running Ubuntu 22.04. |
Could you profile this for me? See #137 (comment) but put the profiling code above your own example code that is giving you the high load and share both the profiler output and the code here. I don't have time right now but I'll try to look into it within a couple weeks. Although from a quick look at the profile in the other issue it wasn't clear to me yet how it can be improved. |
First of all, thanks for Beep and the excellent documentation.
I've written a doorbell in Go that listens to an MQTT channel and then plays a ding-dong noise when a button is pressed. I can deploy the code to multiple hosts on different platforms, which is the appeal of using Go for this.
My code runs as a systemd unit, starts up and initialises the sound streams using Beep's speaker package. However, I've noticed that the baseline CPU usages is pretty high - I have two wav files open and this is using ~15% CPU - even on a puny Celeron box this seems excessive. I've written some minimal code to reproduce this:
Save the snippet above as play.go and then run with
go run play.go <wavfile>
. During thetime.Sleep
(after init, but before the sound is actually played) you can see the usage intop
.I can reduce the CPU usage by reducing the sample rate in the
Init
call - withtime.Second
it was down to about 1% - but that still seems high since it should be completely idle. I also tried using buffering as per the wiki, but that didn't make any difference. Did I miss something here? I'm using go1.18.1.Original issue: faiface/beep#159
The text was updated successfully, but these errors were encountered: