RFR: 8310843: Reimplement ByteArray and ByteArrayLittleEndian with Unsafe [v10]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Jul 20 16:49:48 UTC 2023


On Thu, 20 Jul 2023 16:39:59 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>>> Here's with the same parameters as the one you are using:
>> 
>> I don't understand why there is such a difference. I have replicated similar results on several other devices:
>> 
>> Apple M1:
>> 
>> Benchmark                      Mode  Cnt        Score       Error   Units
>> ByteArray.readByte            thrpt    5  1418606.665 ±  2308.711  ops/ms
>> ByteArray.readByteFromBuffer  thrpt    5   879084.678 ± 20981.303  ops/ms
>> ByteArray.readInt             thrpt    5  1404164.063 ±  4845.412  ops/ms
>> ByteArray.readIntFromBuffer   thrpt    5   829768.843 ±  8730.467  ops/ms
>> ByteArray.readLong            thrpt    5  1400713.660 ±  1924.752  ops/ms
>> ByteArray.readLongFromBuffer  thrpt    5   825721.508 ±  4146.961  ops/ms
>> 
>> 
>> 
>> Intel Celeron N5105:
>> 
>> Benchmark                      Mode  Cnt       Score        Error   Units
>> ByteArray.readByte            thrpt    5  927248.807 ±  29630.442  ops/ms
>> ByteArray.readByteFromBuffer  thrpt    5  448374.359 ±   3210.571  ops/ms
>> ByteArray.readInt             thrpt    5  719143.935 ± 183584.747  ops/ms
>> ByteArray.readIntFromBuffer   thrpt    5  398578.488 ±    100.058  ops/ms
>> ByteArray.readLong            thrpt    5  742555.147 ±  13006.710  ops/ms
>> ByteArray.readLongFromBuffer  thrpt    5  398771.660 ±   1673.524  ops/ms
>> 
>> 
>> AMD Ryzen 7 5800X:
>> 
>> Benchmark                      Mode  Cnt        Score       Error   Units
>> ByteArray.readByte            thrpt    5  1784096.905 ± 47611.535  ops/ms
>> ByteArray.readByteFromBuffer  thrpt    5   992974.747 ± 19389.011  ops/ms
>> ByteArray.readInt             thrpt    5  1719368.129 ± 70606.284  ops/ms
>> ByteArray.readIntFromBuffer   thrpt    5   919654.075 ±  9292.283  ops/ms
>> ByteArray.readLong            thrpt    5  1719873.280 ± 18441.122  ops/ms
>> ByteArray.readLongFromBuffer  thrpt    5   921992.992 ±  6439.747  ops/ms
>
> On a newer processor/OS (Alder Lake/Ubuntu 22.04) I see a bit more difference:
> 
> 
> Benchmark                      Mode  Cnt       Score       Error   Units
> ByteArray.readByte            thrpt    5  680397.046 ± 27504.022  ops/ms
> ByteArray.readByteFromBuffer  thrpt    5  576449.569 ±  3633.135  ops/ms
> ByteArray.readInt             thrpt    5  685419.089 ±  6740.268  ops/ms
> ByteArray.readIntFromBuffer   thrpt    5  542887.418 ±  2863.907  ops/ms
> ByteArray.readLong            thrpt    5  687949.037 ±  3510.613  ops/ms
> ByteArray.readLongFromBuffer  thrpt    5  548120.950 ±  5461.145  ops/ms
> 
> 
> But still far from 2x.

For full disclosure, I'm running the benchmark using the JDK microbenchmark support. My JMH version is a bit behind. I've updated it to 1.35 (which is the latest I see being used around here) and getting similar results.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14636#discussion_r1269722383


More information about the core-libs-dev mailing list