comp.lang.ada
 help / color / mirror / Atom feed
* Re: Performance issue
  1996-04-03  0:00 Performance issue Laurent Guerby
@ 1996-04-03  0:00 ` Robert Dewar
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Dewar @ 1996-04-03  0:00 UTC (permalink / raw)


Laurent said

"--  Simple test to measure the speed improvement between GNAT 3.03 and GNAT
--  3.04 for "zero cost exception handling" (no more setjmps).
"

That's not quite right, we do not yet have true zero cost exception 
handling. What we *did* do is to eliminate the use of the standard
setjmp/longjmp, and replace it with an inernal implementation of
these primitives.

The gain will vary from machine to machine. On some machines there will
be very little gain, but on the Sparc the gain is huge. The Sun folks
seem to think that they have to do a system call (gasp!!!) to do a
setjmp, and in fact this is quite unnecessry, as this fix shows.

We still intend to do true zero cost exception handling in the future
(this is hard to do in a target independent manner), but meanwhile,
at least GNAT 3.04 eliminates the quite ludicrous overhead of defining
exception handlers on SunOS and Solaris.





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Performance issue
@ 1996-04-03  0:00 Laurent Guerby
  1996-04-03  0:00 ` Robert Dewar
  0 siblings, 1 reply; 2+ messages in thread
From: Laurent Guerby @ 1996-04-03  0:00 UTC (permalink / raw)


--  Laurent Guerby, 1996-04-03 

--  Simple test to measure the speed improvement between GNAT 3.03 and GNAT
--  3.04 for "zero cost exception handling" (no more setjmps).

--  Here are the result on Solaris 2.4 on a SS4,
--
--  with GNAT 3.03 :
--  $ gnatmake perf_exception.adb -cargs -O2
--  gcc -c -O2 perf_exception.adb
--  gnatbind perf_exception.ali
--  gnatbl perf_exception.ali -linkonly
--  $ /bin/time perf_exception
--  real     6:36.8  (396.8s)
--  user     1:58.5  (118.5s)
--  sys      4:28.9  (268.9s)
--  (Note that you  can  easily get +/-30s  on  these numbers since  you're
--  relying a lot on the system).
--
--  with GNAT 3.04 :
--  $ gnatmake perf_exception.adb -cargs -O2
--  gcc -c -O2 perf_exception.adb
--  gnatbind -x perf_exception.ali
--  gnatlink perf_exception.ali
--  $ /bin/time perf_exception
--  real       12.6  ( 12.6s)
--  user       12.2  ( 12.2s)
--  sys         0.0  (  0.0s)
--
--  Speedup = (118.5+268.9) / (12.2+0.0) = 31.7 (>= 20)
--  Hum, one order of magnitude faster ;-).

procedure Perf_Exception is

   pragma Suppress (All_Checks);
   --  We don't want to measure range or overflow checks performance.

   E : exception;

   Number_Of_E   : constant := 10;
   Number_Of_Inc : constant := 10_000_000;

   --  With  this  configuration, we  just  measure the  cost of entering a
   --  block  with an exception handler, not   the performance of exception
   --  handling  by itself. Swap the numbers  if you want a "naive" measure
   --  of exceptiom handling performance.

   E_Count   : Natural := 0;
   Inc_Count : Natural := 0;

begin
   --  The   following loop  raises  Number_Of_E  times   E, and the  block
   --  statement  is executed Number_Of_E   + Number_Of_Inc times, counting
   --  the number of "Inc" and "E", to defeat compiler optimization.

   for I in 1 .. Number_Of_E + Number_Of_Inc loop
      begin
         if I > Number_Of_Inc then
            raise E;
         else
            Inc_Count := Inc_Count + 1;
         end if;
      exception
         when E => E_Count := E_Count + 1;
      end;
   end loop;

   --  Simple coherence check (the result of our useful computation ;-).

   if E_Count /= Number_Of_E or 
     Inc_Count /= Number_Of_Inc 
   then
      raise Program_Error;
   end if;
end Perf_Exception;

-- 
--  Laurent Guerby, student at Telecom Bretagne (France), Team Ada
--  "Use the Source, Luke. The Source will be with you, always (GPL)"
--  http://www-eleves.enst-bretagne.fr/~guerby/ (GATO Project)
--  Try GNAT, the GNU Ada 95 compiler (ftp://cs.nyu.edu/pub/gnat)




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-04-03  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-03  0:00 Performance issue Laurent Guerby
1996-04-03  0:00 ` Robert Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox