io7m-com / jtensors

Vector/matrix math package
https://www.io7m.com/software/jtensors/
ISC License
6 stars 1 forks source link

Direct matrix performance issue #7

Closed io7m closed 7 years ago

io7m commented 8 years ago

Recent benchmarks are showing that heap-backed matrices significantly outperform direct memory backed matrices. In single threaded code, the MatrixHeapArrayM4x4F type sustains about ~18 million multiplications per second, where as the MatrixDirectM4x4F type sustains only ~5 million.

Performing the multiplication with heap-backed matrices and saving the result to a direct-memory backed matrix maintains the ~18 million operations per second, so it's not clear exactly where the bottleneck is.

io7m commented 8 years ago

This benchmark performs the multiplication by reading from a pair of direct matrices and writing the result to a heap matrix. This achieves ~5 million ops per second.

This benchmark performs the multiplication by reading from a pair of heap-backed matrices and saving the result to a direct matrix. This achieves ~18 million ops per second!

It therefore seems fair to assume that the bottleneck is in reading from direct matrices.

io7m commented 7 years ago

This is irrelevant now as direct matrices are no longer used for calculations. There's nothing that can be done to speed up the new storage matrix implementation as it's entirely down to the performance of the JDK's ByteBuffer implementation.