The program attached to this CR iterates over an array and updates each element. When running with preview mode, the array is a flat array because Optional<T> is then the migrated version of the class.
With relatively small arrays, the flat arrays provides better performance than the regular non-flat array. But as the size of the array increases, there's a point where the performance with the flat array is worse than with the regular array.
See the numbers below, the argument to the BigArray program is the size of the array:
$ time ./build/lworld/images/jdk/bin/java BigArray 30000000
real 2m34.366s
user 31m24.417s
sys 0m8.088s
$ time ./build/lworld/images/jdk/bin/java --enable-preview BigArray 30000000
real 2m22.388s
user 22m6.393s
sys 0m13.141s
$ time ./build/lworld/images/jdk/bin/java BigArray 50000000
real 4m38.651s
user 58m36.268s
sys 0m6.766s
$ time ./build/lworld/images/jdk/bin/java --enable-preview BigArray 50000000
real 4m55.254s
user 39m23.206s
sys 0m29.518s
$ time ./build/lworld/images/jdk/bin/java BigArray 80000000
real 11m23.695s
user 141m22.966s
sys 0m7.543s
$ time ./build/lworld/images/jdk/bin/java --enable-preview BigArray 80000000
real 14m0.379s
user 83m52.127s
sys 1m37.123s
With relatively small arrays, the flat arrays provides better performance than the regular non-flat array. But as the size of the array increases, there's a point where the performance with the flat array is worse than with the regular array.
See the numbers below, the argument to the BigArray program is the size of the array:
$ time ./build/lworld/images/jdk/bin/java BigArray 30000000
real 2m34.366s
user 31m24.417s
sys 0m8.088s
$ time ./build/lworld/images/jdk/bin/java --enable-preview BigArray 30000000
real 2m22.388s
user 22m6.393s
sys 0m13.141s
$ time ./build/lworld/images/jdk/bin/java BigArray 50000000
real 4m38.651s
user 58m36.268s
sys 0m6.766s
$ time ./build/lworld/images/jdk/bin/java --enable-preview BigArray 50000000
real 4m55.254s
user 39m23.206s
sys 0m29.518s
$ time ./build/lworld/images/jdk/bin/java BigArray 80000000
real 11m23.695s
user 141m22.966s
sys 0m7.543s
$ time ./build/lworld/images/jdk/bin/java --enable-preview BigArray 80000000
real 14m0.379s
user 83m52.127s
sys 1m37.123s