RFR: 8300236: Use VarHandle access in Data(Input | Output)Stream classes [v4]

Per Minborg pminborg at openjdk.org
Mon Jan 23 10:19:11 UTC 2023


On Mon, 23 Jan 2023 08:11:15 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/util/access/ByteArrayAccess.java line 614:
>> 
>>> 612:     /*
>>> 613:      * Methods for packing primitive values into byte arrays starting at offset zero.
>>> 614:      */
>> 
>> Is the only advantage to the zero offset versions in the API, shorter invocations with fewer parameters? 
>> Is there any performance difference?
>
> Very good question. I will take a look at it. A fixed value is inserted in the original var handle so potentially it might improve performance that way too.

No significant performance increase:


2-parameters
Benchmark                                             Mode  Cnt  Score   Error  Units
PrimitiveFieldSerializationBenchmark.serializeData    avgt    8  6.761 ± 0.126  ns/op
PrimitiveFieldSerializationBenchmark.serializeRecord  avgt    8  6.890 ± 0.093  ns/op

3-parameters
Benchmark                                             Mode  Cnt  Score   Error  Units
PrimitiveFieldSerializationBenchmark.serializeData    avgt    8  6.850 ± 0.074  ns/op
PrimitiveFieldSerializationBenchmark.serializeRecord  avgt    8  6.855 ± 0.057  ns/op

-------------

PR: https://git.openjdk.org/jdk/pull/12076


More information about the core-libs-dev mailing list