Csound Csound-dev Csound-tekno Search About

[Csnd] Csound using 100% CPU when using Core Audio

Date2025-07-04 00:57
FromAdam Willetts
Subject[Csnd] Csound using 100% CPU when using Core Audio
Hi,

I’ve recently started trying out Csound 7 which has prompted me to use Core Audio instead of Port Audio and I’ve noticed that regardless of how simple my code is or what I set ksmps to or what CsOptions flags I use, elapsed time at end of performance always shows almost exactly the same number for real and CPU and Activity Monitor shows Csound using a fairly constant 100.3%. 
I’m not experiencing any problems with audio performance so I’m wondering if this is the expected behaviour with Core Audio or if there is a problem somewhere in my system?
The exact same thing happens with Csound 6.18 and the last file I tested was only using around 6% CPU when I tried it with Port Audio in 6.18.
I wondered if it might be related to my MOTU M4 USB audio interface but it happens even when that is disconnected and I use the built in speakers. I deleted the drivers for the MOTU M4 and that didn’t change anything either.
I’m using a MacBook Air M3 running macOS Sequoia 15.5. 

Thanks,
Adam
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2025-07-04 08:57
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Csound using 100% CPU when using Core Audio
That’s not your system, the coreaudio backend does that alright. What happens is that while
Csound is waiting for samples to be played, it runs a loop that keeps the CPU busy. The
reason you see no impact on performance is that if Csound needs to do more computation,
it then takes less time in that loop, and the result is a steady 100% cpu stat. However if
we look at the overall system resource use, we will see that this is not actually having an
impact on user cpu (well it’s more than portaudio), and I think it’s because it’s not doing
much computation except for looping.

There is code there commented out to give back the cpu to the system. I tested it and
it brings the stats back to normal. I will mainline that code and monitor its performance.

Thanks
========================
Prof. Victor Lazzarini
Maynooth University
Ireland






> On 4 Jul 2025, at 00:57, Adam Willetts  wrote:
>
> [You don't often get email from adam@ethermap.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> *Warning*
>
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>
> Hi,
>
> I’ve recently started trying out Csound 7 which has prompted me to use Core Audio instead of Port Audio and I’ve noticed that regardless of how simple my code is or what I set ksmps to or what CsOptions flags I use, elapsed time at end of performance always shows almost exactly the same number for real and CPU and Activity Monitor shows Csound using a fairly constant 100.3%.
> I’m not experiencing any problems with audio performance so I’m wondering if this is the expected behaviour with Core Audio or if there is a problem somewhere in my system?
> The exact same thing happens with Csound 6.18 and the last file I tested was only using around 6% CPU when I tried it with Port Audio in 6.18.
> I wondered if it might be related to my MOTU M4 USB audio interface but it happens even when that is disconnected and I use the built in speakers. I deleted the drivers for the MOTU M4 and that didn’t change anything either.
> I’m using a MacBook Air M3 running macOS Sequoia 15.5.
>
> Thanks,
> Adam
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2025-07-05 02:12
FromAdam Willetts
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Csound using 100% CPU when using Core Audio
Hi Victor

Thanks for the detailed explanation. It’s a relief to know that everything is working as intended and I really appreciate the insight into how Csound works with the core audio backend.
I’m excited to get on with exploring the new features of Csound 7 now that I know that 100% CPU stat is nothing to worry about.

Thanks
Adam

> On 4 Jul 2025, at 19:57, Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE> wrote:
> 
> That’s not your system, the coreaudio backend does that alright. What happens is that while
> Csound is waiting for samples to be played, it runs a loop that keeps the CPU busy. The
> reason you see no impact on performance is that if Csound needs to do more computation,
> it then takes less time in that loop, and the result is a steady 100% cpu stat. However if
> we look at the overall system resource use, we will see that this is not actually having an
> impact on user cpu (well it’s more than portaudio), and I think it’s because it’s not doing
> much computation except for looping.
> 
> There is code there commented out to give back the cpu to the system. I tested it and
> it brings the stats back to normal. I will mainline that code and monitor its performance.
> 
> Thanks
> ========================
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 
> 
> 
> 
> 
> 
>> On 4 Jul 2025, at 00:57, Adam Willetts  wrote:
>> 
>> [You don't often get email from adam@ethermap.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>> 
>> *Warning*
>> 
>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>> 
>> Hi,
>> 
>> I’ve recently started trying out Csound 7 which has prompted me to use Core Audio instead of Port Audio and I’ve noticed that regardless of how simple my code is or what I set ksmps to or what CsOptions flags I use, elapsed time at end of performance always shows almost exactly the same number for real and CPU and Activity Monitor shows Csound using a fairly constant 100.3%.
>> I’m not experiencing any problems with audio performance so I’m wondering if this is the expected behaviour with Core Audio or if there is a problem somewhere in my system?
>> The exact same thing happens with Csound 6.18 and the last file I tested was only using around 6% CPU when I tried it with Port Audio in 6.18.
>> I wondered if it might be related to my MOTU M4 USB audio interface but it happens even when that is disconnected and I use the built in speakers. I deleted the drivers for the MOTU M4 and that didn’t change anything either.
>> I’m using a MacBook Air M3 running macOS Sequoia 15.5.
>> 
>> Thanks,
>> Adam
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>       https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
> 
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2025-07-05 08:39
Fromvlz
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Csound using 100% CPU when using Core Audio
Thx. I have some changes now that give cpu back, combined with other changes that also improve its performance. Hopefully they will be merged soon.

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 5 Jul 2025, at 02:12, Adam Willetts  wrote:
> 
> Hi Victor
> 
> Thanks for the detailed explanation. It’s a relief to know that everything is working as intended and I really appreciate the insight into how Csound works with the core audio backend.
> I’m excited to get on with exploring the new features of Csound 7 now that I know that 100% CPU stat is nothing to worry about.
> 
> Thanks
> Adam
> 
>> On 4 Jul 2025, at 19:57, Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE> wrote:
>> 
>> That’s not your system, the coreaudio backend does that alright. What happens is that while
>> Csound is waiting for samples to be played, it runs a loop that keeps the CPU busy. The
>> reason you see no impact on performance is that if Csound needs to do more computation,
>> it then takes less time in that loop, and the result is a steady 100% cpu stat. However if
>> we look at the overall system resource use, we will see that this is not actually having an
>> impact on user cpu (well it’s more than portaudio), and I think it’s because it’s not doing
>> much computation except for looping.
>> 
>> There is code there commented out to give back the cpu to the system. I tested it and
>> it brings the stats back to normal. I will mainline that code and monitor its performance.
>> 
>> Thanks
>> ========================
>> Prof. Victor Lazzarini
>> Maynooth University
>> Ireland
>> 
>> 
>> 
>> 
>> 
>> 
>>>> On 4 Jul 2025, at 00:57, Adam Willetts  wrote:
>>> 
>>> [You don't often get email from adam@ethermap.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>>> 
>>> *Warning*
>>> 
>>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>>> 
>>> Hi,
>>> 
>>> I’ve recently started trying out Csound 7 which has prompted me to use Core Audio instead of Port Audio and I’ve noticed that regardless of how simple my code is or what I set ksmps to or what CsOptions flags I use, elapsed time at end of performance always shows almost exactly the same number for real and CPU and Activity Monitor shows Csound using a fairly constant 100.3%.
>>> I’m not experiencing any problems with audio performance so I’m wondering if this is the expected behaviour with Core Audio or if there is a problem somewhere in my system?
>>> The exact same thing happens with Csound 6.18 and the last file I tested was only using around 6% CPU when I tried it with Port Audio in 6.18.
>>> I wondered if it might be related to my MOTU M4 USB audio interface but it happens even when that is disconnected and I use the built in speakers. I deleted the drivers for the MOTU M4 and that didn’t change anything either.
>>> I’m using a MacBook Air M3 running macOS Sequoia 15.5.
>>> 
>>> Thanks,
>>> Adam
>>> Csound mailing list
>>> Csound@listserv.heanet.ie
>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>> Send bugs reports to
>>>      https://github.com/csound/csound/issues
>>> Discussions of bugs and features can be posted here
>> 
>> 
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>       https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here