bjornbytes / lovr

Lua Virtual Reality Framework
https://lovr.org
MIT License
2k stars 138 forks source link

Audio module CPU utilization #657

Open jmiskovic opened 1 year ago

jmiskovic commented 1 year ago

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 commented 1 year ago

I'm getting roughly:

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 commented 1 year ago
jmiskovic commented 1 year ago

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.