RFR (S) 8146801: Allocating short arrays of non-constant size is slow

Vladimir Kozlov vladimir.kozlov at oracle.com
Wed Mar 2 17:29:43 UTC 2016

The prefetching assumes that next allocation will be of the same type (instance or array). The prefetching is done for 
future allocation and not a current one. So we can't change it based on size of current allocation.
Yes, it is very simple approach and we can do better by searching other allocations in current code. But I doubt it will 
give us a lot of benefits.

My experiments back then showed that prefetching helps offset zeroing cost (in some degree) because cache lines are 
fetched already. Skipping some prefetching may have negative effect. Memory accesses are more costly then instruction count.


On 3/2/16 5:05 AM, Vladimir Ivanov wrote:
>>   I've no idea whether it would matter in real code.  AFAIK, prefetchnta
>> will bring the line into L1 on modern Intel.  Prefetching beyond the
>> small array allocation would seem undesirable as it increases
>> instruction stream size for no benefit and may bring in lines that
>> aren't needed at all.
> Still guessing, but considering it still prefetches lines from current TLAB, consequent allocations may benefit. Actual
> performance should heavily depend on allocation rate though.
> Best regards,
> Vladimir Ivanov

More information about the hotspot-compiler-dev mailing list