public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: C++ exception code size / recommended practice
@ 2003-04-10 18:29 Benjamin Kosnik
  2003-04-10 20:35 ` Tim Jansen
  0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Kosnik @ 2003-04-10 18:29 UTC (permalink / raw)
  To: ml; +Cc: gcc

Hmm. Your data is surprising to me. The last time I measured this was
when RTH was putting the call frame bits in, and I found that the
overhead in libstdc++ between -fno-exceptions and the default was less
than 30%. I have not done this recently.

Some questions:

Are you on x86? Have you tried the gcc-3.2.x series, and is it comparable?

-benjamin

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

* Re: C++ exception code size / recommended practice
  2003-04-10 18:29 C++ exception code size / recommended practice Benjamin Kosnik
@ 2003-04-10 20:35 ` Tim Jansen
  0 siblings, 0 replies; 6+ messages in thread
From: Tim Jansen @ 2003-04-10 20:35 UTC (permalink / raw)
  To: Benjamin Kosnik; +Cc: gcc

On Thursday 10 April 2003 18:43, you wrote:
> Are you on x86? Have you tried the gcc-3.2.x series, and is it comparable?

On x86. I have compiled it with gcc 3.2.2 and a newer 3.3 snapshot, it's a 
somewhat smaller:

gcc 3.2.2, without exceptions 343964 bytes
gcc 3.2.2, with exceptions 485164 bytes
gcc 3.3 prerelease 20030407, without exceptions 353400 bytes
gcc 3.3 prerelease 20030407, with exceptions 507208 bytes

bye...

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

* Re: C++ exception code size / recommended practice
  2003-04-10 18:24 ` Joe Buck
@ 2003-04-10 19:46   ` Tim Jansen
  0 siblings, 0 replies; 6+ messages in thread
From: Tim Jansen @ 2003-04-10 19:46 UTC (permalink / raw)
  To: Joe Buck; +Cc: gcc

On Thursday 10 April 2003 18:42, Joe Buck wrote:
> Actually, the extra size is, for the most part, not code at all; rather,
> it is tables (for specifying how the stack is to be unwound if an
> exception occurs). 

Yes, ca 50%. Here are some values (the same app as in my first mail, gcc 3.3 
prerelease on x86, but now with -O2):

Without exceptions:
Filesize: 350092 bytes
.text : 298400
.eh_frame: 4
.gcc_except_table: does not exist
.eh_frame_hdr: does not exist

With exceptions:
Filesize: 524732 bytes
.text: 387936
.eh_frame: 45340
.gcc_except_table: 31280
.eh_frame_hdr: 7948

With exceptions, -fno-enforce-eh-specs:
Filesize: 523836 bytes
.text: 385856
.eh_frame: 45364
.gcc_except_table: 30002
.eh_frame_hdr: 7948
(there are only a few throw() declarations)

bye...



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

* Re: C++ exception code size / recommended practice
  2003-04-09 23:59 Tim Jansen
  2003-04-10 15:03 ` Jason Merrill
@ 2003-04-10 18:24 ` Joe Buck
  2003-04-10 19:46   ` Tim Jansen
  1 sibling, 1 reply; 6+ messages in thread
From: Joe Buck @ 2003-04-10 18:24 UTC (permalink / raw)
  To: tim; +Cc: gcc

On Thu, Apr 10, 2003 at 01:20:32AM +0200, Tim Jansen wrote:
> Hi...
> 
> I wonder what are the recommended practices for decreasing code size of C++ 
> applications with exceptions. I switched a project from -fno-exceptions to 
> regular exception support. This increased the size of the two binaries, after 
> stripping, from 370572 and 39660 bytes to 581308 and 58408, respectively. 
> Thus the increase in code size is > 50% (compiler: GCC 3.3 20030226 from SuSE 
> 8.2). 

Actually, the extra size is, for the most part, not code at all; rather,
it is tables (for specifying how the stack is to be unwound if an
exception occurs).  Since the tables land in a separate section, in most
cases they will not occupy RAM until an exception occurs, at which point
they are paged in from disk.  What this means is that your executable
consumes extra disk space, but the increase in RAM is far less.

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

* Re: C++ exception code size / recommended practice
  2003-04-09 23:59 Tim Jansen
@ 2003-04-10 15:03 ` Jason Merrill
  2003-04-10 18:24 ` Joe Buck
  1 sibling, 0 replies; 6+ messages in thread
From: Jason Merrill @ 2003-04-10 15:03 UTC (permalink / raw)
  To: tim; +Cc: gcc

On Thu, 10 Apr 2003 01:20:32 +0200, Tim Jansen <ml@tjansen.de> wrote:

> Are there any hopes to make the overhead smaller on 3.x gccs? Is a throws() 
> clause in the declaration recommended or not? It would be desirable for API 
> documentation purposes and a paper claimed that empty throws() decreases the 
> code size in VisualC++, but with gcc I noticed another small increase.
> Or, possibly, could the reason for the increase be that the app uses a 
> -fno-exceptions library (Qt) extensively?

The -fno-enforce-exception-specs flag should improve the code size with
throw() specs.

Jason

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

* C++ exception code size / recommended practice
@ 2003-04-09 23:59 Tim Jansen
  2003-04-10 15:03 ` Jason Merrill
  2003-04-10 18:24 ` Joe Buck
  0 siblings, 2 replies; 6+ messages in thread
From: Tim Jansen @ 2003-04-09 23:59 UTC (permalink / raw)
  To: gcc

Hi...

I wonder what are the recommended practices for decreasing code size of C++ 
applications with exceptions. I switched a project from -fno-exceptions to 
regular exception support. This increased the size of the two binaries, after 
stripping, from 370572 and 39660 bytes to 581308 and 58408, respectively. 
Thus the increase in code size is > 50% (compiler: GCC 3.3 20030226 from SuSE 
8.2). 

Are there any hopes to make the overhead smaller on 3.x gccs? Is a throws() 
clause in the declaration recommended or not? It would be desirable for API 
documentation purposes and a paper claimed that empty throws() decreases the 
code size in VisualC++, but with gcc I noticed another small increase.
Or, possibly, could the reason for the increase be that the app uses a 
-fno-exceptions library (Qt) extensively?

I would appreciate any suggestions.

bye...


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

end of thread, other threads:[~2003-04-10 20:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-10 18:29 C++ exception code size / recommended practice Benjamin Kosnik
2003-04-10 20:35 ` Tim Jansen
  -- strict thread matches above, loose matches on Subject: below --
2003-04-09 23:59 Tim Jansen
2003-04-10 15:03 ` Jason Merrill
2003-04-10 18:24 ` Joe Buck
2003-04-10 19:46   ` Tim Jansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).