public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Slow/Swappy C++ compilation
@ 2002-10-13  2:27 Tony Bryant
  2002-10-13 12:14 ` Fergus Henderson
  2002-10-14  0:11 ` Tony Bryant
  0 siblings, 2 replies; 4+ messages in thread
From: Tony Bryant @ 2002-10-13  2:27 UTC (permalink / raw)
  To: gcc

I've got a relatively small C++ application here that has one global variable 
of an "Everything" class.

My main.cc file is:

//-------------
#include "everything.h"
static TProgramBase Everything;
//-------------

with "everything.h" itself including everything else needed for the definition 
of TEverything (which is uses templates quite heavily)

This compiles fast (<3 secs), and gcc uses less than 5Mb of RAM doing so

If I change this to:

//-------------
#include "everything.h"
class TProgramExtended
{
public:
	TProgramBase EverythingButTheGirl;
};
static TProgramExtended Everything;
//--------------

This compiles as fast and with the same low memory footprint too.

However:

//-------------
#include "everything.h"
class TProgramExtended : public TProgramBase
{
public:
	TProgramExtended();
};
//---------------

this takes over 160Mb of RAM to compile! About 15 seconds if it doesn't start 
swapping.

That's 160Mb to compile a unit without any code emitted!

If you are wondering TProgramBase's constructor is NOT defined as inline.

BTW I'm running gcc 3.1 for sh-elf on RH7.3, -O level has no effect on this 
problem.

What is going on here?

What diagnostics could I usefully run?


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

* Re: Slow/Swappy C++ compilation
  2002-10-13  2:27 Slow/Swappy C++ compilation Tony Bryant
@ 2002-10-13 12:14 ` Fergus Henderson
  2002-10-14  0:11 ` Tony Bryant
  1 sibling, 0 replies; 4+ messages in thread
From: Fergus Henderson @ 2002-10-13 12:14 UTC (permalink / raw)
  To: Tony Bryant; +Cc: gcc

On 13-Oct-2002, Tony Bryant <brd@paradise.net.nz> wrote:
> What diagnostics could I usefully run?

Try compiling with `-Q', `-ftime-report', and/or `-fmem-report'.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.

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

* Re: Slow/Swappy C++ compilation
  2002-10-13  2:27 Slow/Swappy C++ compilation Tony Bryant
  2002-10-13 12:14 ` Fergus Henderson
@ 2002-10-14  0:11 ` Tony Bryant
  2002-10-14  3:54   ` Zack Weinberg
  1 sibling, 1 reply; 4+ messages in thread
From: Tony Bryant @ 2002-10-14  0:11 UTC (permalink / raw)
  To: gcc

Update on my 160Mb compilation issue:

-fmem-report shows it only uses 10M! 

almost exactly the same as the non-swappy compilation (i.e written using 
composition rather than inheritance)

There's obviously something being allocated thats not included in the memory 
report?  Any ideas where I should start looking?  Perhaps related to template 
instantiation?






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

* Re: Slow/Swappy C++ compilation
  2002-10-14  0:11 ` Tony Bryant
@ 2002-10-14  3:54   ` Zack Weinberg
  0 siblings, 0 replies; 4+ messages in thread
From: Zack Weinberg @ 2002-10-14  3:54 UTC (permalink / raw)
  To: Tony Bryant; +Cc: gcc

On Mon, Oct 14, 2002 at 12:58:30PM +1300, Tony Bryant wrote:
> Update on my 160Mb compilation issue:
> 
> -fmem-report shows it only uses 10M! 
> 
> almost exactly the same as the non-swappy compilation (i.e written using 
> composition rather than inheritance)
> 
> There's obviously something being allocated thats not included in the memory 
> report?  Any ideas where I should start looking?  Perhaps related to template 
> instantiation?

-fmem-report only reports memory allocations made via the garbage
collector interface, and which are still live at the end of the
translation unit.  If the 160Mb eventually becomes garbage and is
reclaimed, or if it's not under GC control at all, you won't see it
in -fmem-report.

Patches to rectify this are welcome.

zw

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

end of thread, other threads:[~2002-10-14  3:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-13  2:27 Slow/Swappy C++ compilation Tony Bryant
2002-10-13 12:14 ` Fergus Henderson
2002-10-14  0:11 ` Tony Bryant
2002-10-14  3:54   ` Zack Weinberg

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