This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


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

Re: libgcj performance: _Jv_LookupInterfaceMethod


Tom Tromey wrote:
> 
> >>>>> "Kresten" == Kresten Krab Thorup <krab@daimi.au.dk> writes:
> 
> Kresten> I think that you should be using `%' and not `&' to limit the
> Kresten> hash code to be in the method cache index range.
> 
> You're right.  Actually, I want to use "&" and require that the hash
> table be the right length.  Ordinarily I don't micro-optimize like
> this, but I think in this case it will pay off.

I'd agree... in fact the Alpha has no integer divide instruction; using
`%' will invoke a subroutine whereas `&' is still a single instruction.

We lose the benefit of a prime number for table size, but that's
unimportant until cache misses are significant.

> Kresten> The bug in the original code was (I believe), that I forgot
> Kresten> to reset method_cache_count after it was cleaned out.  It
> Kresten> should have been set back down to zero (in
> Kresten> _Jv_AddMethodToCache).  My hunch is, that fixing this bug
> Kresten> will make it perform better than what's there now.
> 
> I'm reluctant to introduce a loop here without data supporting it one
> way or another.  It seems like it would only be useful when there are
> many hash collisions.

With this patch I reran Bryce's interface benchmark with profiling data:

  %   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
 45.52     16.72    16.72                             __mcount_internal
 19.00     23.70     6.98                             mcount
 11.65     27.98     4.28        1  4280.00 13028.61  Bench::Bench(void)
  7.00     30.55     2.57 20000419     0.00     0.00 
_Jv_equalUtf8Consts(_Jv_Utf8Const *, _Jv_Utf8Const *)
  5.69     32.64     2.09 10000001     0.00     0.00 
_Jv_FindMethodInCache(java::lang::Class *, _Jv_Utf8Const *,
_Jv_Utf8Const *)
  2.67     33.62     0.98 20000002     0.00     0.00 
InterfaceImpl::a(void)
  2.53     34.55     0.93 20000002     0.00     0.00  AbstImpl::a(void)
  2.48     35.46     0.91 10000001     0.00     0.00 
_Jv_LookupInterfaceMethod
  1.47     36.00     0.54 10000001     0.00     0.00  Bench::a(void)
  1.03     36.38     0.38 10000001     0.00     0.00  Native::a(void)
  0.90     36.71     0.33 10000001     0.00     0.00  Bench::b(void)

No cache misses here (there's only one interface method after all).  So
it's not a great example.  It's interesting though that
_Jv_equalUtf8Consts is the top offender, and called twice for each
method lookup... hmm...

-- 
Jeff Sturm
jsturm@sigma6.com

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