This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Bum cycles out of ggc_set_mark
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 22 Aug 2002 11:55:08 -0700
- Subject: Re: Bum cycles out of ggc_set_mark
- References: <20020822172325.GA24984@codesourcery.com>
Zack Weinberg <zack@codesourcery.com> writes:
> While it seems to have been demonstrated that the major performance
> problems with GC are indirect, there are workloads for which
> ggc_set_mark takes >10% of runtime. One obvious thing to do to speed
> it up, is get rid of the integer divide operation smack in the middle
> of the critical path. We know all the divisors in advance and we know
> that the remainder will always be zero, which means we can apply the
> general technique for replacing a divide with a multiply and a shift.
> On my system, this theoretically saves 36 cycles per call to
> ggc_set_mark.
>
> The appended patch does just this. Unfortunately it has less impact
> than I was hoping - shaves 12 seconds off user time for a bootstrap,
> gives only 3% speedup on a test case that spends 33% of runtime in the
> garbage collector (as measured by -ftime-report). It might still be
> worth doing, though.
A 10% speedup of GC is pretty good. The patch is OK.
> zw
>
> * ggc-page.c: Avoid division in ggc_set_mark.
> (DIV_MULT, DIV_SHIFT, OFFSET_TO_BIT, inverse_table,
> compute_inverse): New.
> (ggc_set_mark, ggc_marked_p): Use OFFSET_TO_BIT.
> (init_ggc): Initialize inverse_table.
--
- Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>