lkml.org 
[lkml]   [2007]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: OT: Does Linux have any "Perfect Code"
From
Date
Eric Dumazet <dada1@cosmosbay.com> writes:
>
> http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/timers.c#1106
>
> I would say this code was OK 10 years ago.

I would have expected 1997 compilers to already do these standard muliplication
optimizations.

> Now that a processor (say an Opteron in 64 bits mode, used on SUN
> hardware), can perform a multiply in few cycles, ts2hrt() could use a
> normal multiply and an addition.

To be fair Linux runs on a lot of CPUs which are not quite as fast
at multiplying as an Opteron, especially not for 64bit multiplies.
So some optimizations might be still a good idea. For divisions
at least Linux also actively does this.

On the other hand compilers also get worse. Modern gccs now turn

while (nsec >= NANOSEC) {
nsec -= NANOSEC;
sec++;
}

into a division which is actually much slower. Or insert unnecessary
cache misses randomly. See the recent gcc thread safety discussion
where it turned out that the thread breaking optimization is actually
more a general pessimization.

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-11-15 08:47    [W:1.201 / U:0.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site