Traversing an array of value types seen as an array of Object is slow

Remi Forax forax at univ-mlv.fr
Wed Jun 27 18:56:39 UTC 2018


I maybe wrong with the conclusion but this benchmark [1] show that there is something fishy.

Benchmark                                         Mode  Cnt    Score    Error  Units
ReifiedListBenchMark.arraylist_integer_get        avgt    9    0.068 ±  0.001  ms/op
ReifiedListBenchMark.arraylist_integer_iterator   avgt    9    0.069 ±  0.001  ms/op
ReifiedListBenchMark.reifiedlist_intbox_cursor    avgt    9  516.526 ± 11.903  ms/op
ReifiedListBenchMark.reifiedlist_intbox_get       avgt    9  523.149 ±  9.194  ms/op
ReifiedListBenchMark.reifiedlist_intbox_iterator  avgt    9  514.091 ± 18.357  ms/op

A reified list uses an array created by reflection and seen as an Object[].
The creation and the population of the array is done out-of-the-band and not benchmarked,
the benchmark only test several ways to access to the array in a loop.

It seems that the JIT never try to optimize the loop for whatever reason so the loop is done by the interpreter and only the access to the array cell is JITed.

Rémi

[1] https://github.com/forax/valuetype-lworld/blob/master/src/test/java/fr.umlv.valuetype/fr/umlv/valuetype/perf/ReifiedListBenchMark.java




More information about the valhalla-dev mailing list