[Mono-dev] Weird performance problems possibly due to floats and precision issues?

Ivo Smits Ivo at UFO-Net.nl
Wed Sep 21 06:04:21 EDT 2011


Op 21-9-2011 8:31, noisecrime schreef:
> ...
>
> Essentially the function has three nested loops, all of which iterate the
> same number of times every call. The inner loop is a single line of simple
> arithmetic instructions akin to  x[i] = y[i] + (a * ( y[s] + y[t] + y[u] +
> y[v]) )/c. It normally completes in a few milliseconds, but when passing in
> the troublesome viscosity value it slows down quickly to taking half a
> second!
I have seen similar behaviour on MS .Net in an audio processing 
application. The slowdown there was caused by arithmetic operations on a 
non-value (NaN/Infinity/negative infinity). Such an operation will again 
result in a non-value, which might explain why the slowdown propagates. 
You could easily check for these values in your code.

I don't know exactly why these things cause such a slowdown. Maybe there 
is some (hardware) exception processing getting in the way, but that's 
just guessing. In my case it helped a lot to check the result for these 
3 non-values, and set it to some valid value instead. It's not a proper 
solution, but in my case helped to keep the application useable even for 
incorrect input values.

--
Ivo


More information about the Mono-devel-list mailing list