Skip to content
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

Audio module CPU utilization #657

Open
jmiskovic opened this issue Mar 23, 2023 · 3 comments
Open

Audio module CPU utilization #657

jmiskovic opened this issue Mar 23, 2023 · 3 comments

Comments

@jmiskovic
Copy link
Contributor

jmiskovic commented Mar 23, 2023

With blank main.lua the lovr process consumes 12% of my CPU.

Turning off the t.modules.audio = false brings it under the 1%.

Here's the callgrind output showing how the ALSA miniaudio backend spends it's time:

with_alsa

Switching miniaudio backend to PulseAudio has a similar effect on CPU utilization to disabling the audio module.

with_pa

I've tested the PulseAudio audio to work correctly in lovr, but this was with PipeWire which has interface for PulseAudio. I can re-test on actual PulseAudio in few days. @bjorn you mentioned some issues with PA you had before, let me know what so I can test that specifically.

Edit: above profiling is done with valgrind --tool=callgrind ./lovr . on the debug build, and visualized through kcachegrind.

@bjornbytes
Copy link
Owner

bjornbytes commented Mar 24, 2023

I'm getting roughly:

  • 6-7% CPU usage with pulseaudio
  • 8-9% CPU usage with ALSA
  • 5% CPU usage with t.modules.audio = false

This was on an optimized build. If I change BUFFER_SIZE to 1024 in audio.h I get a little bit less overhead (presumably at the cost of latency).

If I disable the window, ALSA sits at 12% CPU and the other configurations are at 10%.

These are imprecise metrics, but it does seem like ALSA has a bit more overhead than pulseaudio. Maybe not as much as you're seeing though...

@bjornbytes
Copy link
Owner

  • Wonder if t.audio.start should be false by default, or if that's too weird/annoying.
  • Or maybe audio could lazily start the audio device once the first source is played.

@jmiskovic
Copy link
Contributor Author

Strange that I'm the only one seeing this as it really heats up the laptop. I'm happy with using the PulseAudio backend, feel free to close the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants