This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bum cycles out of ggc_set_mark


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>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]