We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4941

Summary: ALSA: excessive IO causes high CPU usage
Product: SDL Reporter: Paul Cercueil <paul>
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz
Version: HG 1.2   
Hardware: All   
OS: Linux   
Attachments: Patch to fix the issue

Description Paul Cercueil 2020-01-13 18:08:12 UTC
Created attachment 4157 [details]
Patch to fix the issue

Quote from the patch:

"On GCW Zero jz4770 platform, I saw higher than usual CPU usage when
running a more recent kernel (4.xx series versus 3.xx). Upon
investigation, it was found that the ALSA pcm file was not blocking
as it should. This resulted in ~30-50,000 system calls a second that
were unnecesary.

After adjusting the order in which SDL requests its pcm blocking mode,
the number of syscalls a second has dropped to a much smaller figure,
< 1,000/sec if I recall correctly. CPU usage also dropped by ~5%."
Comment 1 Ryan C. Gordon 2020-03-23 02:04:35 UTC
Generally we don't mess with SDL 1.2, but this patch was straightforward enough that I've applied it to revision control here: https://hg.libsdl.org/SDL/rev/9c0fc6e28c5e

--ryan.
Comment 2 Ozkan Sezer 2020-06-24 22:30:11 UTC
Does the default/2.0 branch not need this change?