[Speex-dev] High CPU usage
mark_schilling at gmx.de
Wed Sep 23 13:42:51 PDT 2009
I first modified the FPU control word to raise an exception whenever a denormal is used. Then I used the debugger to locate the exceptions and added VERY_SMALLs where they seem to fit well.
Although I got CPU usage as low as 10%, I seriously lack knowledge of how things work inside speex. So just changing some code is not the best idea for me.
My second attempt was to follow Jeff's suggestion to modify the MXCSR register and recompile with _USE_SSE. This works very well (CPU < 3%).
However I would still prefer the first method (VERY_SMALL) because not all CPUs, my app is going to run on, have the SSE instruction set available. Hopefully someone with more insight is able to fix this some day :-)
Von: speex-dev-bounces at xiph.org [mailto:speex-dev-bounces at xiph.org] Im Auftrag von Jeff Wallace
Betreff: Re: [Speex-dev] High CPU usage
If you are compiling with SSE and/or SSE2 instructions enabled, you could consider enabling the floating point "Flush-to-zero" mode and maybe (if supported on the processor) enable "denormals are zero". The flush-to-zero is probably the more important of the two.
On Wed, Sep 23, 2009 at 4:06 AM, Jean-Marc Valin <jean-marc.valin at usherbrooke.ca> wrote:
Mark Schilling a écrit :
> I recompiled with FIXED_POINT and CPU utilization stays below 4%. This is a great improvement.
> So how can I fix this to work with floating point ?
OK, so it looks a lot like a denorm problem. The issue is basically that
there are filters that decay exponentially, so when the input suddenly
goes to zero, then the filter's output value becomes smaller and smaller
until it reaches ~1e-37. At that point, your CPU takes >10x the normal
time to make calculations (why is beyond me).
Now, the work-around is to prevent some signals from going to exacly
zero. Have a look at how the VERY_SMALL macro is currently being used.
It's defined as 0 for fixed-point, but 1e-15f for float. By adding that
value to the right signal(s), you can prevent denormalized numbers from
being generated. The key is to find that place or those places. A
profiler may be able to tell you where the problem happens so you can
add VERY_SMALL just before that place. I suspect that just doing that at
the output of the preprocessor may be enough but I'm not sure.
> -----Ursprüngliche Nachricht-----
> Von: Jean-Marc Valin [mailto:jean-marc.valin at usherbrooke.ca]
> Betreff: Re: [Speex-dev] High CPU usage
> Sound like it could be the good old denormalised float problem on the Intel chips. Just to make sure, can you try compiling in fixed-point
> (FIXED_POINT) and see if the problem goes away (it's not a fix, just a test)? If that's the case, there's probably a few VERY_SMALL's to add to some signals.
> Mark Schilling a écrit :
>> I have a curious problem with speex. As long as I'm talking, it takes about 2-5% of my CPU. This seems ok.
>> But as soon as I stop talking, CPU utilization rises to about 30-45% and stays there until I start talking again.
>> I compiled speex from source and use it with these settings:
>> - Preprocessor: Denoiser = ON, AGC = ON
>> - Encoder: ABR = 15000, DTX = 1, Mode = narrowband, Rate = 8000 Hz.
>> My platform: Windows XP SP3, MSVS 2008 SP1, 1.8 GHz Core Duo CPU, 2 GB RAM.
>> Thanks for your help :-)
Speex-dev mailing list
Speex-dev at xiph.org
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser
More information about the Speex-dev