[LAD] cpu spikes

2016-01-24 Thread Fokke de Jong
Hi all,

This is my first post here. I’m note new to audio programming or linux, but I 
haven’t done much in terms of combining the two. Most of my audio programming 
has been on os x.

Currently working on some realtime convolution with lots of channels and low 
latency requirements, but I am running into some unexpected cpu-spikes and hope 
some of you might have an idea of possible causes.

I’m processing 32 sample-blocks at 48KHz but roughly every 0,6 seconds I get a 
large spike in cpu usage. This cannot possibly be explained by my algorithm, 
because the load should be pretty stable. 

I am measuring cpu load by getting the time with 
clock_gettime(CLOCK_MONOTONIC_RAW, timespec*) at the beginning and end of each 
callback. When converted to a percentage my cpu load hovers somewhere between 
40 an 50% most of the time, but more or less every 900 callbacks (0.8 seconds 
there is a spike of more than 100%.

I am not doing any IO, mallocing or anything else that could block. My threads 
are SCHED_FIFO with max priority (I have 4 threads on 4 cores).
The only explanation I can come up with is that my threads are somehow 
pre-empted even though there are realtime threads. Is that even possible?  And 
is there a way to check this? Besides pre-emption maybe my caches are severely 
thrashed but i find that unlikely as it seems to happen on all 4 cores 
simultaneously. 

I’m running (more or less default install, no additional services run-in) Linux 
Mint 17.3 with a 3.19.0-42-lowlatency kernel on a core i7-6700 with 
hyperthreading/turbo disabled.

I remember reading somewhere that realtime threads cannot run more than .95s 
every second. That would be very bad if it actually meant my threads are 
blocked  run for a period of 50ms straight…

Anyone have any thoughts on possible causes?

best,
Fokke


___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] cpu spikes

2016-01-24 Thread Fons Adriaensen
On Sun, Jan 24, 2016 at 03:03:08PM +0100, Fokke de Jong wrote:

> I remember reading somewhere that realtime threads cannot run
> more than .95s every second. That would be very bad if it
> actually meant my threads are blocked  run for a period of 50ms
> straight…

If your normal load is around 50% you shouldn't ever hit that limit.

Do you lock all memory used by your RT threads ? 

If you don't and the system is configured for high swappiness
[1] this sort of thing could happen. 

I'm routinely running big real-time convolution matrices without
problems, so it's certainly possible. 


[1] 

-- 
FA

A world of exhaustive, reliable metadata would be an utopia.
It's also a pipe-dream, founded on self-delusion, nerd hubris
and hysterically inflated market opportunities. (Cory Doctorow)

___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] cpu spikes

2016-01-24 Thread Len Ovens

On Sun, 24 Jan 2016, Fokke de Jong wrote:


I’m processing 32 sample-blocks at 48KHz but roughly every 0,6 seconds I get a
large spike in cpu usage. This cannot possibly be explained by my algorithm,
because the load should be pretty stable. 


...


I’m running (more or less default install, no additional services run-in) Linux
Mint 17.3 with a 3.19.0-42-lowlatency kernel on a core i7-6700 with
hyperthreading/turbo disabled.


...


Anyone have any thoughts on possible causes?


Bad kernel driver? WIFI drivers are known bad for things like this. An 
interupt driver can block if it is designed badly. I found on one machine 
I had to unload the the kernel module for my wifi as it actually created 
more problems when I turned the power off to the tx than when it was on. 
(it seems to me on my wifi, when it was turned on I got xruns every 5 
seconds, but with it turned off it was every half second or so... sounds 
very close to 0.6, unloading the kernel module fixed it)


Cron should also be turned off, but that is probably not the problem here. 
Cron runs super "nice" but there seem to be some things it does like 
packge update that can cause problems too. I turn off cron while 
recording.


--
Len Ovens
www.ovenwerks.net
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] cpu spikes

2016-01-24 Thread Harry van Haaren
On Sun, Jan 24, 2016 at 2:03 PM, Fokke de Jong 
wrote:

> Currently working on some realtime convolution with lots of channels and
> low latency requirements, but I am running into some unexpected cpu-spikes
> and hope some of you might have an idea of possible causes.
>

Keep an eye on the interrupts while its all running, particularly
Non-maskable interrupts. Try to correlate them with the 0.6 sec
of the glitches if possible;

watch -n 0.1 cat /proc/interrupts

I've written up some of the checks I generally do, perhaps browse
that to see if there's anything there that you could check?
http://openavproductions.com/real-time-latency-tuning/

Thats all I can think of at the moment, -Harry

-- 

http://www.openavproductions.com
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] cpu spikes

2016-01-24 Thread Jonathan E. Brickman



On 01/24/2016 08:03 AM, Fokke de Jong wrote:

Hi all,

This is my first post here. I’m note new to audio programming or 
linux, but I haven’t done much in terms of combining the two. Most of 
my audio programming has been on os x.


Currently working on some realtime convolution with lots of channels 
and low latency requirements, but I am running into some unexpected 
cpu-spikes and hope some of you might have an idea of possible causes.


I’m processing 32 sample-blocks at 48KHz but roughly every 0,6 seconds 
I get a large spike in cpu usage. This cannot possibly be explained by 
my algorithm, because the load should be pretty stable.


[...snip...]

I’m running (more or less default install, no additional services 
run-in) Linux Mint 17.3 with a 3.19.0-42-lowlatency kernel on a core 
i7-6700 with hyperthreading/turbo disabled.


I remember reading somewhere that realtime threads cannot run more 
than .95s every second. That would be very bad if it actually meant my 
threads are blocked  run for a period of 50ms straight…


Anyone have any thoughts on possible causes?

best,
Fokke
You're running Mint :-)  Lots of background bells and whistles there, 
lots of things which will crop up and interfere, things you cannot 
disable or turn off with absolute certainty.  If you want smooth power, 
you'll have to choose more carefully.  My current SOP in more detail here:


http://lsn.ponderworthy.com/doku.php/choosing_a_linux_platform_for_live_synth



--
Jonathan E. Brickman   j...@ponderworthy.com   (785)233-9977
Hear us at http://ponderworthy.com -- CDs and MP3 now available! 


Music of compassion; fire, and life!!!
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev