Bench testing Octave in Debian and Gentoo

I was interested in seeing whether numerical computations such as matrix multiply would be faster in Gentoo. The theory is that apps in Gentoo will be faster because they are compiled for your own CPU when installed, and therefore will be better optimized compared to a downloaded binary.

I initially tried to do the comparison in R, but I soon realised that R is quite unusual in that it is always compiled when installed in any Linux distro.

I chose to use Octave instead of R. Octave is a FOSS version of Matlab. It is used for matrix calculations. I installed Octave in Debian, as a downloaded binary, and in Gentoo as a compiled package. The Debian install was a slightly older version.

The particular matrix arithmetic I am interested in is a fivefold matrix product of the form
A’ * B’ * C * B * A
where A , B, and C are matrices of the same size.

To do that in Octave I wrote

A=rand(5000,5000);
B=rand(5000,5000);
C=rand(5000,5000);
tic(); D= A' * B' * C * B * A; toc()

so it sets up 3 matrices with 5000 rows and columns, and fills them with random numbers. Then it does the five way multiply, and reports elapsed seconds

Elapsed time is 6.32531 seconds.

Then repeated it for matrix sizes ranging from 2500 to 15000.
At 15000 my machine started to swap ( it has 8Gb ram).
Did the same in Debian and Gentoo.
Results are shown in the graph below

So Debian and Gentoo versions of Octave perform virtually the same ( Gentoo was actually slightly slower) for all matrix sizes up until the machine starts to swap at size=15000; Then when swapping is involved Gentoo is slightly faster.

Well, so much for the theory. Compiling Octave natively does not help to speed up matrix arithmetic. If swapping is involved Gentoo may be superior.

I think I have to conclude that matrix arithmetic has already been optimised and parallelised in the libopenblas.so library code so that what CPU it is compiled for makes very little extra improvement.

To those who have not tried Octave… it is a fine calculator… there is not much difference between a matrix and a spreadsheet in structure, but the operations differ. Octave is not just for matrix arithmetic, it can draw graphs, do statistics, and can be used as a programming language.

2 Likes