Bug 6588 - throw() takes 20,000 cycles : is it expected ?
Summary: throw() takes 20,000 cycles : is it expected ?
Status: SUSPENDED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 3.2
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2002-05-06 16:36 UTC by Sylvain Pion
Modified: 2009-04-09 10:06 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-03-11 06:55:56


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvain Pion 2002-05-06 16:36:00 UTC
The sequence throw/catch appears to take about 20,000 cycles
on a Pentium III.  Is this expected ?
Is there a way to speed this up ?
Even if this sequence is not supposed to happen often, the
fact that it's very slow can have a visible impact on global
performance.

Release:
3.1 and 3.2

Environment:
Reading specs from /u/zosma/0/prisme/spion/gcc/Linux_trunc/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs
Configured with: /u/zosma/0/prisme/spion/gcc/gcc_trunc/configure --disable-shared --disable-nls --enable-languages=c++ --prefix=/u/zosma/0/prisme/spion/gcc/Linux_trunc --with-gnu-as --with-gnu-ld --with-as=/u/zosma/0/prisme/spion/gcc/Binutils/Linux/bin/as --with-ld=/u/zosma/0/prisme/spion/gcc/Binutils/Linux/bin/ld
Thread model: single
gcc version 3.2 20020505 (experimental)

How-To-Repeat:
// Compile with optimization the following code,
// It takes more than 20 seconds to execute on my
// Pentium III at 933 MHz.
int main()
{
  for (int i=0; i<1000000; ++i)
  {
    try {
      throw(0);
    }
    catch (...) {
    }
  }
}
Comment 1 Richard Henderson 2002-05-08 14:56:51 UTC
From: Richard Henderson <rth@redhat.com>
To: Sylvain.Pion@sophia.inria.fr
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: optimization/6588: throw() takes 20,000 cycles : is it expected ?
Date: Wed, 8 May 2002 14:56:51 -0700

 On Mon, May 06, 2002 at 11:35:50PM -0000, Sylvain.Pion@sophia.inria.fr wrote:
 > The sequence throw/catch appears to take about 20,000 cycles
 > on a Pentium III.  Is this expected ?
 
 Not unexpected.
 
 > Is there a way to speed this up ?
 
 I doubt it.
 
 
 r~

Comment 2 Richard Henderson 2002-05-08 15:10:47 UTC
From: Richard Henderson <rth@redhat.com>
To: Sylvain Pion <Sylvain.Pion@sophia.inria.fr>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: optimization/6588: throw() takes 20,000 cycles : is it expected ?
Date: Wed, 8 May 2002 15:10:47 -0700

 On Wed, May 08, 2002 at 11:58:18PM +0200, Sylvain Pion wrote:
 > I made some benchmarks with the SunPro compiler, and it's 20 times faster.
 > (maybe it's not as correct as GCC, though)
 
 One of the changes for gcc 3.0 (that probably made it slower)
 is that we support throwing exceptions between languages.
 
 
 r~
Comment 3 Sylvain Pion 2002-05-08 23:58:18 UTC
From: Sylvain Pion <Sylvain.Pion@sophia.inria.fr>
To: Richard Henderson <rth@redhat.com>
Cc: Sylvain.Pion@sophia.inria.fr, gcc-gnats@gcc.gnu.org
Subject: Re: optimization/6588: throw() takes 20,000 cycles : is it expected ?
Date: Wed, 8 May 2002 23:58:18 +0200

 On Wed, May 08, 2002 at 02:56:51PM -0700, Richard Henderson wrote:
 > > The sequence throw/catch appears to take about 20,000 cycles
 > > on a Pentium III.  Is this expected ?
 > 
 > Not unexpected.
 
 :(
 
 > > Is there a way to speed this up ?
 > 
 > I doubt it.
 
 :((
 
 I made some benchmarks with the SunPro compiler, and it's 20 times faster.
 (maybe it's not as correct as GCC, though)
 
 -- 
 Sylvain

Comment 4 Dara Hazeghi 2003-05-25 04:17:23 UTC
Hello,

I can confirm that this problem is still present on gcc 3.2, 3.3 branch and mainline (20030524). 
Takes ~18 seconds on a P-III 733MHZ...

Dara

Comment 5 Andrew Pinski 2003-05-25 19:54:00 UTC
Changinh this to an enhancement request because there might be no way to speed up 
throwing of an exceptions.
Comment 6 Andrew Pinski 2003-08-05 15:22:52 UTC
Suspending this as the same reason for changing this to an enhancement.
Comment 7 Andrew Pinski 2005-01-13 21:23:12 UTC
Hmm, this is one of the cases where we should be able optimize away really but the general case we 
can try to.
Comment 8 Wolfgang Bangerth 2009-04-08 23:10:17 UTC
We're about 8 generations of gcc later now. Is this still true? Still
20,000 cycles?

W.
Comment 9 Sylvain Pion 2009-04-09 10:06:02 UTC
There seems to have been some progress : it now takes 6000-9000 cycles instead of 20000.

This is 6000 with g++ 4.3.1 on a Fedora 10 x86_64 box, and 9000 on a MacBook Pro with various g++ versions up to current mainline.