[bug #68091] Inefficient Integer Data Loading from MAT-Files

Rik <[email protected]> Mon, 27 Apr 2026 07:58:15 -0400 (EDT)
Newsgroups gmane.comp.gnu.octave.bugs
Message-ID <[email protected]>
Please use the bug tracker to post updates to a bug report.  The mailing list is intended as a read-only notification stream.  Info posted to this mailing list address won't appear in the tracker database where it is most useful.

Update of bug #68091 (group octave):

                  Status:                    None => Ready For Test
           Fixed Release:                    None => 12.1.0 (current default)

    _______________________________________________________

Follow-up Comment #13:

@foreverllama: I pushed your changeset.  See cset ID b2069f031cd2.

I rewrote the commit message to this:


Refactor integer load in MAT-files for performance speed up (bug #68091)

New templatized function which checks at compile-time whether source data
type and destination data type are the same in which case a direct copy
can be made, rather than copying into a temporary buffer.

* ls-mat5.cc (read_mat5_integer_data_storage): New templatized function to
  replace macro READ_INTEGER_DATA.
  (read_mat5_integer_data): Replace READ_INTEGER_DATA macro invocations with
  read_mat5_integer_data_storage() function calls.


Octave coding guidelines have the bug number at the end.

I also sorted the list of *#include* directives and renamed the template type
"StorageT" to "storageT" since CamelCase is generally frowned on in Octave.
The list of coding conventions is at
https://wiki.octave.org/C%2B%2B_style_guide.

Note, I didn't find a performance difference for the test case given


a1 = randi(255, 3000, 3000, "uint8");
save("test.mat", "a1", "-v7", "-nocompression");

% Before patch
tic; load("test.mat"); toc % Elapsed time is 0.285283 seconds.
% After patch
tic; load("test.mat"); toc % Elapsed time is 0.0412259 seconds.


I get an error at the *save* command because Octave does not support the
*"-nocompression"* flag.  There is bug #68268 that I filed for that.  I will
probably push my changeset there just to get started on the testing of that
feature.

However, if I use an uncompressed format like *-v6* I do see an improvement.

*BEFORE*

tic; load("tstint.mat"); toc
Elapsed time is 0.00272012 seconds.


*AFTER*


tic; load("tstint.mat"); toc
Elapsed time is 0.00226092 seconds.


The effect is only about 15%, but worthwhile.  It might be more important for
objects.



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68091>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCae9PVwAKCRCqLAuaBUf3
TnRjAQCgIgDXWkTCWwx1HWFinww++uh/5A4LUV126jXOk5Q2BAEAj+D6+5QKmFG0
7dbtIKrJPiJokgM4van/Nimbm7mTMw8=
=ydPb
-----END PGP SIGNATURE-----