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 (...) { } } }
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~
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~
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
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
Changinh this to an enhancement request because there might be no way to speed up throwing of an exceptions.
Suspending this as the same reason for changing this to an enhancement.
Hmm, this is one of the cases where we should be able optimize away really but the general case we can try to.
We're about 8 generations of gcc later now. Is this still true? Still 20,000 cycles? W.
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.