FreeBSD Most wanted
rsidd at online.fr
Fri Mar 5 17:25:58 PST 2004
> > > I know, by experience, that my code is always much faster than the
> > > compiler-generated code.
> > *rotfl*
> > seriously, grow up.
> This wasn't meant as a generalization, I only wanted to say that every time I
> tried it so far, my code was faster.
> Sorry if this is misleading.
You're probably trying some specific category of programs. Apart from
the fact that most compilers are pretty good these days, most programs
run into bottlenecks other than the CPU rather quickly and there's not
much point in optimising them. Look at the output of "top": there may
be a hundred or more processes running on the system, but usually no
process takes up more than a fraction of a percent of the CPU time.
Bittorrent is written in python, and it won't be any faster written in
asm because it spends most of its time waiting.
Things were very different in the 1980s because (a) cpu speeds were
100-500 times lower than today and hadn't so greatly outpaced the
rest of the hardware, (b) RAM was much more limited, so the savings in
memory usage from handcoded assembly was significant, (c) the most
common operating system was MS-DOS, which was hardly an operating
system at all, so programs didn't worry about playing nice with one
If you're doing some serious numbercrunching code, eg scientific
programming, then you need to worry not only about speed but about
correctness. (I don't mean to imply that correctness is unimportant
otherwise, but a very minor bug in a scientific program can ruin your
reputation.) Most people would not want to debug asm code and will
take the performance hit (if any) of a compiler. And even if you're
dissatisfied with the speed of the compiled program, if you profile
the program you generally find that one routine, comprising less than
10% of the code, is responsible for over 90% of the execution time, so
you really don't gain from optimising the rest.
More information about the freebsd-chat