RFR: JDK-8150496,(zipfs) Fix performance issues in zip-fs
Aleksey Shipilev
aleksey.shipilev at oracle.com
Wed May 4 14:48:56 UTC 2016
On 05/04/2016 10:50 AM, Peter Levart wrote:
> On 05/03/2016 02:39 PM, Aleksey Shipilev wrote:
>> *) There is ever-so-subtle difference in doing either:
>>
>> 171 byte[] tmp = new byte[path.length + 1];
>> 172 System.arraycopy(path, 0, tmp, 1, path.length);
>> 173 tmp[0] = '/';
>>
>> ...or:
>>
>> 1083 byte[] name = new byte[nlen + 1];
>> 1084 name[0] = '/';
>> 1085 System.arraycopy(cen, pos + CENHDR, name, 1, nlen);
>>
>> Excess op between allocation and arraycopy breaks zeroing elimination,
>> see e.g.:
>> http://cr.openjdk.java.net/~shade/scratch/ZeroingFirstBench.java
>
> ...so when allocation of array is immediately followed with arraycopy
> where the newly allocated array is the target, only the part of the
> array that is not overwritten by arraycopy will be zeroed? Because not
> the whole array is overwritten in your example/benchmark. That's good to
> know.
Yes, only not overwritten part would be zeroed. This is a little trick
in C2. I think it works only for heads/tails, not for arbitrary
overwrites. So it is a limited micro-optimization here.
-Aleksey
More information about the core-libs-dev
mailing list