This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: exceptions and threads---a survival tactic!

>  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 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  

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).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]