Re: Justifying Optimization

Joachim Durchholz <joachim_d@gmx.de>
26 Jan 2003 16:30:26 -0500

          From comp.compilers

Related articles
[5 earlier articles]
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)
Re: Justifying Optimization jvorbrueggen@mediasec.de (Jan C.=?iso-8859-1?Q?Vorbr=FCggen?=) (2003-01-25)
Re: Justifying Optimization joachim_d@gmx.de (Joachim Durchholz) (2003-01-26)
Re: Justifying Optimization lars@bearnip.com (2003-01-26)
Re: Justifying Optimization cgweav@aol.com (2003-01-29)
Re: Justifying Optimization tmk@netvision.net.il (2003-01-30)
Re: Justifying Optimization lex@cc.gatech.edu (Lex Spoon) (2003-02-05)
Re: Justifying Optimization bobduff@shell01.TheWorld.com (Robert A Duff) (2003-02-05)
Re: Justifying Optimization vbdis@aol.com (2003-02-06)
[8 later articles]
| List of all articles for this month |
From: Joachim Durchholz <joachim_d@gmx.de>
Newsgroups: comp.compilers
Date: 26 Jan 2003 16:30:26 -0500
Organization: Compilers Central
References: 03-01-088 03-01-098 03-01-141
Keywords: optimize, practice
Posted-Date: 26 Jan 2003 16:30:26 EST

Jan C. Vorbrüggen wrote:
>
>>I agree with Michael's colleagues that performance is rarely a
>>reason to turn optimization on.
>
> Tell that to the people buying the largest computers and using
> petacycles for their work.


These are the rare exceptions (at least in terms of manpower spent on
programming).


  > At the other end of the scale, in an
> embedded system some optimization can make the difference between what
> chip to use, saving a few cents per item, and making the difference
> between bliss and misery (cf. Dickens).


Agreed. Industrial programming is a different case entirely. But,
again, it's a niche market in terms on man-years spent. Most
programmer time is invested into commercial applications targetted for
Windows and nothing else (sad as this state of affairs is). In that
area, it makes sense to run the debug-mode code, simply to cut down on
the effort for testing.


Additional testing with the optimizer turned on will just find a lot
of bugs that were never relevant in debug code - why fix them?
Customers don't care about them, fixing them just runs the risk of
introducing other errors, and customers want that the software vendor
invests his time into new features (or in fixing the more obvious bugs
and misfeatures), not in making the software beautiful.


Things are quite different in the original poster's scenario. He's
compiling with different compilers on different platforms; making the
software conform to a specific compiler with a specific set of options
is not an option for him, he'll have to make his software conform to the
language specification.


> I even disagree that one can debug without optimization. There are
> enough cases were you have to leave your program running for
> substantial time until you get to the point where debugging can
> start (watchpoints, conditional breakpoints, and all that). If that
> time increases from a few minutes to an hour, you've just lost a lot
> of productivity. You _should_ insist on a development system that
> allows you to mix optimized and non-optimized code.


My situation is a bit different. In my environment, switching
assertions on or off can change performance by a factor of 10, 100, or
even 1000, depending on the amount of assertion checking that some
piece of code is laced with. Under these circumstances, I couldn't
care less about the factor of 2 that compiler optimization usually
gives.


What's much more important is that I have very fine systematic control
over which assertions are checked in what modules. I can specify
assertion checking per module, per class, or per function; each
specification says "no assertions", "just precondition checking",
"postcondition checking", "class invariant checking", "assert
instructions in the middle of function bodies". This is important:
precondition checking is usually cheap, postcondition checking takes
up somewhat more time, class invariants are really expensive (because
they are checked on *every* call - an innocent-looking "file.open
implies file.name /= Void" can take up reasonable amounts of time if
it's checked on every file read and write, particularly if file.open
calls system functions - but then class invariant checking is roughly
equivalent to a watchpoint, you're warned at the earliest opportunity
when an object starts to break down).


Regards,
Joachim


Post a followup to this message

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