public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Speeding up GC
@ 2002-08-17  5:13 Tim Josling
  2002-08-18  0:25 ` Guillermo Ballester Valor
  0 siblings, 1 reply; 32+ messages in thread
From: Tim Josling @ 2002-08-17  5:13 UTC (permalink / raw)
  To: gcc

I ran a few more tests (Pentium III with 256mb ram, 1Ghz).

1. I set minimum storage used so that gc_collect never did anything. This
increased the build time by about 3% compared to normal. The largest program
insn-recog.c just fit into my 256mb of ram. If the build is 3% slower, then
GCC must be about 5% slower because phase 1 of the build is the native
compiler, and there are various shell scripts and other programs that run as
well, diluting the speedup, so the GCC speedup is more than the bootstrap
speedup.

2. Replace ggc-page.c with a routine that just allocated everything with
xmalloc. I had to add a 4 bytes header for the storage length because
gc_realloc is used in half a dozen places. This bootstrapped about 3% faster
than the normal bootstrap, meaning the compiler was about 5% faster.

Implications from this:

1. GC overhead is high. Allocating with xmalloc was 5% faster, even though no
storage was freed. It was 10% faster than running the GC allocation code but
not freeing anything. So the combined effect of the extra path length from
gc_alloc and the cache hit from non-locality is at least 10%. In fact it is
probably more, because I had to allocate the extra 4 bytes, and so I used more
memory, and additionally, I did not align the storage which usually would have
a performance impact. None of the above overhead of GC is captured in the GCC
reports, which therefore greatly understate the cost of GC.

2. GC overhead in -O0 is very high. The percentage of GC overhead in
non-optimised compiles is far greater, based on my earlier profiles. It is
reported (by gprof) as ~10-12%. So it is probably more like 20-25% (based on
ratios above), which is very large.

3. A new GCC default and option are needed. It would in my opinion be a good
idea to have a heuristic which said

- If the file is small, do not do GC. Instead do simple contiguous allocation.
We should align things properly, and also we should change gc_realloc to
require the callers to provide the old length so we don't have to store the
length.

- If the file is very large, use GC. The default size could be a configure
option.

- Allow user to override and force use or non-use of GC.

I would clean up and submit this patch but it is just to hard too get patches
onto gcc if you do not have write access.

4. This all makes it appear that there are a lot of performance wins to be
found in GCC. Future changes to GC should be done after testing of the effect
on performance.

Tim Josling

^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: Speeding up GC
@ 2002-06-05  4:56 Robert Dewar
  0 siblings, 0 replies; 32+ messages in thread
From: Robert Dewar @ 2002-06-05  4:56 UTC (permalink / raw)
  To: aoliva, rth; +Cc: davem, espie, gcc

> On Tue, Jun 04, 2002 at 03:41:10PM -0300, Alexandre Oliva wrote:
> > ... and doing garbage collection on obstacks, instead of on
> > individual objects?

I would assume that a PL-1 style area approach might be used ???

^ permalink raw reply	[flat|nested] 32+ messages in thread
* Speeding up GC
@ 2002-06-03  6:25 Martin v. Löwis
  2002-06-03  6:39 ` David S. Miller
  2002-06-03 18:10 ` Richard Henderson
  0 siblings, 2 replies; 32+ messages in thread
From: Martin v. Löwis @ 2002-06-03  6:25 UTC (permalink / raw)
  To: gcc

While profiling cc1plus, I notice that a large amount of time is spent
in marking objects during GC. I suspect that, for each collection, the
same objects are marked over and over again.

It appears that speed-ups are possible by not traversing parts of the
graph that are known not to have changed since the previous
collection.

While it is, in general, not possible to determine whether an object
has changed, I believe that for certain objects (in particular DECL
nodes), there is a point in time when they are "frozen", meaning that
they won't change anymore. I suggest to record this fact in the
object (with the opportunity to unfreeze the object).

During GC traversal, GC should detect "immutable" objects. An object
can be marked immutable if it is frozen, and all contained objects are
immutable. Then, when marking objects, GC should not traverse into
immutable objects.

An exception probably needs to be made for identifiers: they are
always mutable, since the associated decls might change. However, it
is not necessary to traverse into identifiers from other tree nodes,
since all identifiers are GC roots, anyway.

In my specific application, 20% of the memory is consumed by
PARM_DECLs. I believe that those would be candidates for being marked
as immutable, and that the containers immediately storing them could
be marked as immutable as well (after the list of parameters for a
declaration has been built). All those PARM_DECLs indeed live up to
the end of the compilation; they are never collected, and never
changed. Thus, GC traversal could completely ignore them.

Does this approach have a chance of speeding up GC? What do you think?

Regards,
Martin

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

end of thread, other threads:[~2002-08-18  0:25 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <j47klg8pfy.fsf@informatik.hu-berlin.de.suse.lists.egcs>
     [not found] ` <20020603180553.A13829@redhat.com.suse.lists.egcs>
2002-06-04  3:52   ` Speeding up GC Andi Kleen
2002-06-04  6:57     ` John Levon
2002-06-04  7:14       ` Paul Koning
2002-06-04  7:37         ` David S. Miller
2002-06-04  7:51           ` Daniel Berlin
2002-06-04  7:53             ` David S. Miller
2002-06-04  7:58               ` Andi Kleen
2002-06-04  8:08                 ` David S. Miller
2002-06-04  8:55                   ` law
2002-06-04  8:17                 ` Marc Espie
2002-06-04  9:21                 ` Joe Buck
2002-06-04  8:10           ` Marc Espie
2002-06-04  8:58             ` David S. Miller
2002-06-04  9:05               ` Marc Espie
2002-06-04  9:35                 ` David S. Miller
2002-06-04  8:43           ` law
2002-06-04  8:59             ` David S. Miller
2002-06-04 10:15           ` Richard Henderson
2002-06-04 10:22             ` David S. Miller
2002-08-17  5:13 Tim Josling
2002-08-18  0:25 ` Guillermo Ballester Valor
  -- strict thread matches above, loose matches on Subject: below --
2002-06-05  4:56 Robert Dewar
2002-06-03  6:25 Martin v. Löwis
2002-06-03  6:39 ` David S. Miller
2002-06-03 18:10 ` Richard Henderson
2002-06-04  2:34   ` Marc Espie
2002-06-04  3:15     ` David S. Miller
2002-06-04 11:42       ` Alexandre Oliva
2002-06-04 12:10         ` Richard Henderson
2002-06-04 12:39           ` David S. Miller
2002-06-04 12:38         ` David S. Miller
2002-06-04 10:03     ` Richard Henderson

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