Csound Csound-dev Csound-tekno Search About

[Csnd] qutecsound, outvalue - eating a lot of CPU

Date2011-09-14 23:35
FromTarmo Johannes
Subject[Csnd] qutecsound, outvalue - eating a lot of CPU
Hello,

have you ever had similar experience:

In one application I got Csound (run within qutecsound) eating a lot of CPU (50-70%)

I found out that the most of it is caused by a quite simple instrument:

instr 3 ; generate random pseudo on-offs and write the info to widget-channels and table
	
	kbt1 init 0
	kbt2 init 0
	kbt3 init 0
	kbt4 init 0
	igroup=p4	
	
	k1 metro 0.01+rnd(0.4),0.0001
	if (k1==1) then
		kbt1=kbt1#1 ; bitwise XOR,  reverse the value of the bit
	endif

	k2 metro 0.9+rnd(2),0.0001
	if (k2==1) then
		kbt2=kbt2#1 
	endif
	
	k3 metro 0.25+rnd(0.25),0.0001
	if (k3==1) then
		kbt3=kbt3#1 
	endif

	k4 metro 0.05+rnd(0.3),0.5
	if (k4==1) then
		kbt4=kbt4#1 		
	endif
	
	
	;kgoto edasi
	Sbitt1 sprintf "bitt1-%d",igroup
	outvalue Sbitt1, kbt1 ; echo it in widgets
	
	Sbitt2 sprintf "bitt2-%d",igroup
	outvalue Sbitt2, kbt2
	
	Sbitt3 sprintf "bitt3-%d",igroup
	outvalue Sbitt3, kbt3
	
	Sbitt4 sprintf "bitt4-%d",igroup
	outvalue Sbitt4, kbt4
		
edasi:	kbyte=kbt1*1+kbt2*2+kbt3*4+kbt4*8 
	tablew kbyte, igroup-1, gigroup ;

endin 


The instument was run in 4 instances. I switched out all other sound producing instruments and this instr 3 made qutecsound using about 40% of CPU. Insane!
If I skipped the sprintf and outvalue section with kgoto , the CPU usage fell to around 5%.
If I commented out all "outvalue" lines, so sprintf was doing the work, the CPU usage was also around 5-8%.
So it has to be outvalue that is eating the CPU (or QCS reacting to it).

I don't know if it is a problem of Csound Outvalue opcode or Qutecsound behaviour, but I am afraid there is something wrong there.

Otherwise: I love QCS widgets!

tarmo

Csound 5.13 (git) double samples, QCS Version 0.7-alpha (similar results also in QCS 0.6.0)




Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2011-09-14 23:55
FromVictor Lazzarini
SubjectRe: [Csnd] qutecsound, outvalue - eating a lot of CPU
Nothing to do with Csound. I suspect updating the graphics at every k- 
cycle would be expensive alright.

Victor


On 14 Sep 2011, at 23:35, Tarmo Johannes wrote:

> Hello,
>
> have you ever had similar experience:
>
> In one application I got Csound (run within qutecsound) eating a lot  
> of CPU (50-70%)
>
> I found out that the most of it is caused by a quite simple  
> instrument:
>
> instr 3 ; generate random pseudo on-offs and write the info to  
> widget-channels and table
> 	
> 	kbt1 init 0
> 	kbt2 init 0
> 	kbt3 init 0
> 	kbt4 init 0
> 	igroup=p4	
> 	
> 	k1 metro 0.01+rnd(0.4),0.0001
> 	if (k1==1) then
> 		kbt1=kbt1#1 ; bitwise XOR,  reverse the value of the bit
> 	endif
>
> 	k2 metro 0.9+rnd(2),0.0001
> 	if (k2==1) then
> 		kbt2=kbt2#1
> 	endif
> 	
> 	k3 metro 0.25+rnd(0.25),0.0001
> 	if (k3==1) then
> 		kbt3=kbt3#1
> 	endif
>
> 	k4 metro 0.05+rnd(0.3),0.5
> 	if (k4==1) then
> 		kbt4=kbt4#1 		
> 	endif
> 	
> 	
> 	;kgoto edasi
> 	Sbitt1 sprintf "bitt1-%d",igroup
> 	outvalue Sbitt1, kbt1 ; echo it in widgets
> 	
> 	Sbitt2 sprintf "bitt2-%d",igroup
> 	outvalue Sbitt2, kbt2
> 	
> 	Sbitt3 sprintf "bitt3-%d",igroup
> 	outvalue Sbitt3, kbt3
> 	
> 	Sbitt4 sprintf "bitt4-%d",igroup
> 	outvalue Sbitt4, kbt4
> 		
> edasi:	kbyte=kbt1*1+kbt2*2+kbt3*4+kbt4*8
> 	tablew kbyte, igroup-1, gigroup ;
>
> endin
>
>
> The instument was run in 4 instances. I switched out all other sound  
> producing instruments and this instr 3 made qutecsound using about  
> 40% of CPU. Insane!
> If I skipped the sprintf and outvalue section with kgoto , the CPU  
> usage fell to around 5%.
> If I commented out all "outvalue" lines, so sprintf was doing the  
> work, the CPU usage was also around 5-8%.
> So it has to be outvalue that is eating the CPU (or QCS reacting to  
> it).
>
> I don't know if it is a problem of Csound Outvalue opcode or  
> Qutecsound behaviour, but I am afraid there is something wrong there.
>
> Otherwise: I love QCS widgets!
>
> tarmo
>
> Csound 5.13 (git) double samples, QCS Version 0.7-alpha (similar  
> results also in QCS 0.6.0)
>
>
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2011-09-15 06:58
FromRene Jopi
SubjectRe: [Csnd] qutecsound, outvalue - eating a lot of CPU
Hi,

Increase ksmps or use metro

ktrig metro $Update_Outvalues_Freq

if ktrig = 1 then


outvalue ....



endif


René



2011/9/15 Tarmo Johannes <tarmo@otsakool.edu.ee>
Hello,

have you ever had similar experience:

In one application I got Csound (run within qutecsound) eating a lot of CPU (50-70%)

I found out that the most of it is caused by a quite simple instrument:

instr 3 ; generate random pseudo on-offs and write the info to widget-channels and table

       kbt1 init 0
       kbt2 init 0
       kbt3 init 0
       kbt4 init 0
       igroup=p4

       k1 metro 0.01+rnd(0.4),0.0001
       if (k1==1) then
               kbt1=kbt1#1 ; bitwise XOR,  reverse the value of the bit
       endif

       k2 metro 0.9+rnd(2),0.0001
       if (k2==1) then
               kbt2=kbt2#1
       endif

       k3 metro 0.25+rnd(0.25),0.0001
       if (k3==1) then
               kbt3=kbt3#1
       endif

       k4 metro 0.05+rnd(0.3),0.5
       if (k4==1) then
               kbt4=kbt4#1
       endif


       ;kgoto edasi
       Sbitt1 sprintf "bitt1-%d",igroup
       outvalue Sbitt1, kbt1 ; echo it in widgets

       Sbitt2 sprintf "bitt2-%d",igroup
       outvalue Sbitt2, kbt2

       Sbitt3 sprintf "bitt3-%d",igroup
       outvalue Sbitt3, kbt3

       Sbitt4 sprintf "bitt4-%d",igroup
       outvalue Sbitt4, kbt4

edasi:  kbyte=kbt1*1+kbt2*2+kbt3*4+kbt4*8
       tablew kbyte, igroup-1, gigroup ;

endin


The instument was run in 4 instances. I switched out all other sound producing instruments and this instr 3 made qutecsound using about 40% of CPU. Insane!
If I skipped the sprintf and outvalue section with kgoto , the CPU usage fell to around 5%.
If I commented out all "outvalue" lines, so sprintf was doing the work, the CPU usage was also around 5-8%.
So it has to be outvalue that is eating the CPU (or QCS reacting to it).

I don't know if it is a problem of Csound Outvalue opcode or Qutecsound behaviour, but I am afraid there is something wrong there.

Otherwise: I love QCS widgets!

tarmo

Csound 5.13 (git) double samples, QCS Version 0.7-alpha (similar results also in QCS 0.6.0)




Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"



Date2011-09-15 10:48
FromTarmo Johannes
SubjectRe: [Csnd] qutecsound, outvalue - eating a lot of CPU
Thank you,

I forward it now to QuteCsound list but copy also to Csound-list.

Yes, the problem was in the QCS widget. I used before scrollnumbers as widgets (not very good chice, in fact) - I needed both to be able to change values (between 1 and 0) manually and also display  the value, if it generated or read by algorithm or external device.

I had 16 widgets of scrollnumbers and refreshing them at krate ksmps=64 with outvalue made QCS use about 40-50% of CPU.

I made experiment with a group of 4:
1) scrollnumbers -> CPU usage around 25%
2) displays -> CPU usage around 25-27% 
3) buttons (latched) -> CPU usage 6% Voila!

So I will use buttons instead.

I think it is not a bug, it's just good to be aware, that refreshing many (perhaps?) number-associated widgets in high rate is expensive.

The solution could be to use metro as suggested Rene Jopi (thanks!):

ktrig metro $Update_Outvalues_Freq
 if ktrig = 1 then

outvalue ....
 endif

greetings,
tarmo

On Thursday 15 September 2011 01:55:11 Victor Lazzarini wrote:
> Nothing to do with Csound. I suspect updating the graphics at every k- 
> cycle would be expensive alright.
> 
> Victor
> 
> 
> On 14 Sep 2011, at 23:35, Tarmo Johannes wrote:
> 
> > Hello,ps=64
> >
> > have you ever had similar experience:
> >
> > In one application I got Csound (run within qutecsound) eating a lot  
> > of CPU (50-70%)
> >
> > I found out that the most of it is caused by a quite simple  
> > instrument:
> >
> > instr 3 ; generate random pseudo on-offs and write the info to  
> > widget-channels and table
> > 	
> > 	kbt1 init 0
> > 	kbt2 init 0
> > 	kbt3 init 0
> > 	kbt4 init 0
> > 	igroup=p4	
> > 	
> > 	k1 metro 0.01+rnd(0.4),0.0001
> > 	if (k1==1) then
> > 		kbt1=kbt1#1 ; bitwise XOR,  reverse the value of the bit
> > 	endif
> >
> > 	k2 metro 0.9+rnd(2),0.0001
> > 	if (k2==1) then
> > 		kbt2=kbt2#1
> > 	endif
> > 	
> > 	k3 metro 0.25+rnd(0.25),0.0001
> > 	if (k3==1) then
> > 		kbt3=kbt3#1
> > 	endif
> >
> > 	k4 metro 0.05+rnd(0.3),0.5
> > 	if (k4==1) then
> > 		kbt4=kbt4#1 		
> > 	endif
> > 	
> > 	
> > 	;kgoto edasi
> > 	Sbitt1 sprintf "bitt1-%d",igroup
> > 	outvalue Sbitt1, kbt1 ; echo it in widgets
> > 	
> > 	Sbitt2 sprintf "bitt2-%d",igroup
> > 	outvalue Sbitt2, kbt2
> > 	
> > 	Sbitt3 sprintf "bitt3-%d",igroup
> > 	outvalue Sbitt3, kbt3
> > 	
> > 	Sbitt4 sprintf "bitt4-%d",igroup
> > 	outvalue Sbitt4, kbt4
> > 		
> > edasi:	kbyte=kbt1*1+kbt2*2+kbt3*4+kbt4*8
> > 	tablew kbyte, igroup-1, gigroup ;
> >
> > endin
> >
> >
> > The instument was run in 4 instances. I switched out all other sound  
> > producing instruments and this instr 3 made qutecsound using about  
> > 40% of CPU. Insane!
> > If I skipped the sprintf and outvalue section with kgoto , the CPU  
> > usage fell to around 5%.
> > If I commented out all "outvalue" lines, so sprintf was doing the  
> > work, the CPU usage was also around 5-8%.
> > So it has to be outvalue that is eating the CPU (or QCS reacting to  
> > it).
> >
> > I don't know if it is a problem of Csound Outvalue opcode or  
> > Qutecsound behaviour, but I am afraid there is something wrong there.
> >
> > Otherwise: I love QCS widgets!
> >
> > tarmo
> >
> > Csound 5.13 (git) double samples, QCS Version 0.7-alpha (similar  
> > results also in QCS 0.6.0)
> >
> >
> >
> >
> > Send bugs reports to the Sourceforge bug tracker
> >            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> > Discussions of bugs and features can be posted here
> > To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> > "unsubscribe csound"
> >
> 
> Dr Victor Lazzarini
> Senior Lecturer
> Dept. of Music
> NUI Maynooth Ireland
> tel.: +353 1 708 3545
> Victor dot Lazzarini AT nuim dot ie
> 
> 
> 
> 
> 
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 
> 


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"