optimize KlassInfoTable size to power of 2

Andrew Haley aph at redhat.com
Mon Dec 10 12:29:39 UTC 2018


On 12/10/18 6:24 AM, 臧琳 wrote:
>      My observation is that when “jmap histo” iterating objects , the object’s klass
>    is identified and then hash idx in KlassInfoTable’s buckets[] is calculated by mod
> of _num_bucktes, which would issue a heavy instruction idiv on x86 platform. It
> means for every object scanned, a idiv instruction is issued, which lag the performance espically when
> there are large number of objects in heap.

I'm surprised that GCC uses idiv in this case: it has an optimization for
constant modulo which doesn't use division. There is sometimes an
advantage for using hash tables of prime size. Is it that the size of
the table is not a constant that GCC can see?

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


More information about the serviceability-dev mailing list