<<
 
>>
 
 
justin = {main feed , music , code , askjf , pubkey };
 
realtime audio on macOS in the age of asymmetrical multicore CPUs
December 27, 2021
It's now time when I bitch about, and document my experiences dealing with Apple's documentation/APIs/etc. For some reason I never feel the need to do this on other platforms, maybe it's that they tend to have better documentation or less fuss to deal with, I'm not sure why, but anyway if you search for "macOS" on this blog you'll find previous installments. Anyway, let's begin.

A bit over a year ago Apple started making computers with their own CPUs, the M1. These have 8 or more cores, but have a mix of slower and faster cores, the slower cores having lower power consumption (whether or not they are more efficient per unit of work done is unclear, it wouldn't surprise me if their efficiency was similar under full load, but anyway now I'm just guessing).

The implications for realtime audio of these asymmetric cores is pretty complex and can produce all sorts of weird behavior. The biggest issue seems to be when your code ends up running on the efficiency cores even though you need the results ASAP, causing underruns. Counterintuitively, it seems that under very light load, things work well, and under very heavy load, things work well, but for medium loads, there is failure. Also counterintuitively, the newer M1 Pro and M1 Max CPUs, with more performance cores (6-8) and fewer efficiency cores (2), seem to have a larger "medium load" range where things don't work well.

The short summary: Perhaps this was all obvious and documented and I failed to read the right things, but anyway I'm just putting this here in case somebody like me would find it useful.
4 Comments:

Posted by Tale on Tue 28 Dec 2021 at 03:03 from 77.170.68.x

Thanks for sharing, this will certainly come in useful one at some point. BTW, Apple's (lack of) documentation if also one of my biggest frustrations.

Posted by Chris on Fri 23 Dec 2022 at 16:21 from 99.155.33.x

Hi,

Thank you SO MUCH for writing this up, saved me a lot of effort...

I put together a gist that describes how to do it, seeing as their documentation really sucks
gist.github.com/cjappl/20fed4c5631...

I was running into the EINVAL thing, and nothing was helping besides this article.

I had a couple questions:

1. How did you discover the period/constraint/computation of the coreaudio thread? Do you have a source anywhere?
2. In your calculation, what do `blocksize` and `srate` refer to, and in what units?

Again, thank you so much. Really useful

Posted by Justin on Mon 26 Dec 2022 at 09:52 from 174.247.17.x

1. I forget if that calculation was buried as code somewhere on the apple documentation site, or if it was just described. Block size is samples, srate is the samplerate in samples/second.

Posted by Chris on Mon 02 Jan 2023 at 19:10 from 76.77.180.x

Perfect, thank you very much.

Add comment:

Name:
Human?: (no or yes, patented anti crap stuff here)
Comment:
search : rss : recent comments : Copyright © 2024 Justin Frankel