[Codel] fp sqrt vis int sqrt?
Eric Dumazet
eric.dumazet at gmail.com
Fri May 4 11:56:33 EDT 2012
On Fri, 2012-05-04 at 11:26 -0400, Jim Gettys wrote:
>
> I suspect there are fully integer implementations kicking around...
> It's just that x86 finally got fast enough FP that doing one multiply in
> floating point beat the alternative.
Anyway we dont need to compute sqrt() at all.
This can be done easily when we do the q->count++, if we hold in
q->sqrt_count the estimated value of sqrt(count)
Ie replace :
q->count++;
by:
q->count++;
n = q->sqrt_count + 1;
if (n * n <= q->count)
q->sqrt_count = n;
A multiply is an acceptable cost.
Of course, you need to reset sqrt_count to 1 when count is reset to 1
More information about the Codel
mailing list