This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: exceptions and threads---a survival tactic!
- To: Joe Buck <jbuck at synopsys dot com>
- Subject: Re: exceptions and threads---a survival tactic!
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Date: Thu, 12 Mar 98 21:25:06 +0100
- Cc: egcs at cygnus dot com
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <199803121553.HAA29418@atrus.synopsys.com>
> Yes, and this can be even more true in Java. The March
> '98 issue of Byte has a piece by David Orchard entitled
> "Better Performance With Exceptions in Java". He finds
> that, for very large arrays,
[ Run loop until end of array by catching index-out-of-bound
exception ]
> is 30-40% faster on JDK 1.1.3 (Sun's Windows version)
> than the traditional
[ Run a loop bounded by the upper array bound ]
OK, even though this has every chance to escalate into a language
war, I can't let this pass:
This must be specific to Java.
About a year and a half ago I installed the latest operational
version of our numerical weather forecasting system (see
http://www.knmi.nl/hirlam) on a DEC Alpha, using Digital Fortran. I
tried compiling both with and without (compiler generated) array
bound checking. The difference in run time was *undetectable* (i.e.
below 1 %, the variance between two successive runs), even though
_every_ array access would have 2 x 2 comparison operations (upper
and lower bound in two dimensions). Oh, and you can be assured that
numerical weather forecasting is nothing else but using data in
arrays.
The reason the overhead is so low is that conditional branches on
Alpha's (and probably on other architectures too) are predicted "not
taken". So as long as the checking code branches _out_ of the main
line of computing on error, it's almost free. Hence, there
wouldn't be any gain in handling this via exceptions (not that any
current Fortran standard _has_ any).
HTH,
Toon.