Re: Justifying Optimization

Christian Bau <christian.bau@cbau.freeserve.co.uk>
21 Jan 2003 00:10:27 -0500

          From comp.compilers

Related articles
Justifying Optimization mike.dillon@lmco.com (MICHAEL DILLON) (2003-01-17)
Re: Justifying Optimization joachim_d@gmx.de (Joachim Durchholz) (2003-01-20)
Re: Justifying Optimization srikanth@cup.hp.com (srikanth) (2003-01-21)
Re: Justifying Optimization christian.bau@cbau.freeserve.co.uk (Christian Bau) (2003-01-21)
Re: Justifying Optimization vbdis@aol.com (2003-01-21)
Re: Justifying Optimization jgd@cix.co.uk (2003-01-21)
Re: Justifying Optimization touati@prism.uvsq.fr (Sid TOUATI) (2003-01-25)
Re: Justifying Optimization ONeillCJ@logica.com (Conor O'Neill) (2003-01-25)
Re: Justifying Optimization jvorbrueggen@mediasec.de (Jan C. =?iso-8859-1?Q?Vorbr=FCggen?=) (2003-01-25)
Re: Justifying Optimization jvorbrueggen@mediasec.de (Jan C.=?iso-8859-1?Q?Vorbr=FCggen?=) (2003-01-25)
[16 later articles]
| List of all articles for this month |

From: Christian Bau <christian.bau@cbau.freeserve.co.uk>
Newsgroups: comp.compilers
Date: 21 Jan 2003 00:10:27 -0500
Organization: Compilers Central
References: 03-01-088
Keywords: optimize
Posted-Date: 21 Jan 2003 00:10:27 EST

  MICHAEL DILLON <mike.dillon@lmco.com> wrote:


> I've been developing for twenty years, and ever since I've been
> allowed to have an opinion I've insisted that code ready for final
> testing and deployment be optimized. I'm currently responsible for my
> program's development strategy, and was recently blindsided by
> resistance to this approach. Developers are stating that optimized
> code produces errors and makes debugging more difficult.


I have used development systems where debugging compiler optimised
code was significantly more difficult. Not just debugging, but single
stepping through code which is the most basic test one should
do. Write the code, compile it, then single step through it to make
sure your code doesn't do anything _really_ stupid. Optimising also
can cost considerable compile time.


And I have seen cases where code that worked fine without optimisation
stopped working with optimisation. Often the real error was undefined
behavior in C code; the same problems would happen if you just
switched to a different compiler. Fact is that the code stopped
working with optimisation.


Developing with optimisation switched off and then trying to ship code
with optimisation switched on is asking for trouble. By switching
optimisation on, you _will_ introduce faults into the product you pass
to testing. Ask yourself if you can afford this.


Developing with optimisation switched on will make development take
longer, because compile times are longer and debugging is harder. Ask
yourself if you can afford this.


Optimisation should make execution times shorter. Measure how much you
gain. Chances are your code spends time in library routines that are
not recompiled anyway, or it spends time by just being stupid (in my
recent experience, most performance gains I achieved were by changing
code that did just stupid things), or it spends time in accessing
memory and any optimisations your C compiler does don't have any
effect at all. Ask yourself how much you will gain. How much time will
your customers safe, and how much will they lose if one single bug
introduced by optimising goes unnoticed.


Now the psychological effect: If you overrule the wishes of your
developers, you will feel good and they will feel bad. Developers who
feel bad develop bad code. Many of them know better how to develop
than you do. Most of them believe they know better how to develop than
you do. You are not paid for feeling good, you are paid for making the
developers feel good so that they produce good code.


If your developers are worth what you pay them, then they are worth
listening to. You have been developing years ago, they do it
know. Times change.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.