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

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Jul 20 16:26:43 UTC 2023


On Thu, 20 Jul 2023 16:12:12 GMT, Glavo <duke at openjdk.org> wrote:

>> I just ran your benchmark above - which is similar as I said to the ones we already have in the JDK. Results:
>> 
>> Benchmark                     Mode  Cnt  Score   Error  Units
>> ByteArray.readByte            avgt   30  3.619 ± 0.051  ns/op
>> ByteArray.readByteFromBuffer  avgt   30  3.936 ± 0.071  ns/op
>> ByteArray.readInt             avgt   30  3.653 ± 0.054  ns/op
>> ByteArray.readIntFromBuffer   avgt   30  3.798 ± 0.019  ns/op
>> ByteArray.readLong            avgt   30  3.637 ± 0.053  ns/op
>> ByteArray.readLongFromBuffer  avgt   30  3.922 ± 0.012  ns/op
>> 
>> 
>> I don't see 2x slowdown. Which JDK are you using? Which platform?
>
>> I don't see 2x slowdown. Which JDK are you using? Which platform?
> 
> I tried running the benchmarks with OpenJDK 20.0.1 and my own jdk built from master and the results were similar. The test platform is based on Ubuntu 23.04, and the CPU is AMD Ryzen 7 3700X.
> 
> Here's the benchmark configuration I use:
> 
> 
> @Warmup(iterations = 5, time = 3)
> @Measurement(iterations = 5, time = 2)
> @Fork(value = 1, jvmArgsAppend = {"-XX:+UseG1GC", "-Xms4g", "-Xmx4g"})
> @BenchmarkMode(Mode.Throughput)
> @OutputTimeUnit(TimeUnit.MILLISECONDS)
> @State(Scope.Benchmark)
> 
> 
> Also, I just ran the benchmarks on my ARM machine (Ubuntu 22.04, RK3588) and here are the results:
> 
> 
> Benchmark                      Mode  Cnt       Score       Error   Units
> ByteArray.readByte            thrpt    5  637843.606 ± 23657.623  ops/ms
> ByteArray.readByteFromBuffer  thrpt    5  350328.152 ±  3635.769  ops/ms
> ByteArray.readInt             thrpt    5  633518.784 ±  2558.021  ops/ms
> ByteArray.readIntFromBuffer   thrpt    5  327456.830 ±  4588.002  ops/ms
> ByteArray.readLong            thrpt    5  627409.162 ± 29301.498  ops/ms
> ByteArray.readLongFromBuffer  thrpt    5  328154.906 ±  1067.439  ops/ms

Here's with the same parameters as the one you are using:

Benchmark                      Mode  Cnt       Score       Error   Units
ByteArray.readByte            thrpt    5  268722.378 ±  5979.787  ops/ms
ByteArray.readByteFromBuffer  thrpt    5  254333.844 ±  6975.034  ops/ms
ByteArray.readInt             thrpt    5  271849.915 ±  4746.869  ops/ms
ByteArray.readIntFromBuffer   thrpt    5  263109.760 ±  2764.372  ops/ms
ByteArray.readLong            thrpt    5  271635.129 ± 14705.673  ops/ms
ByteArray.readLongFromBuffer  thrpt    5  252633.826 ±  2950.184  ops/ms

(Java 22/Ubuntu 20.04 on Ryzen 3900X here).

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

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


More information about the core-libs-dev mailing list