Why is partial loading of matfile "inefficient" for -v7, but still faster?

3 Ansichten (letzte 30 Tage)
When executing the following code, I get a warning that partial loading the -v7 *.mat file is "inefficient" and am told to use -v7.3 instead. However, when I test the execution times of each, it is actually the -v7 file which is faster. Why is this? To what "inefficiencies" does the warning refer?
>> whos
Name Size Bytes Class
b 1x1 8 double
c 641x143 366652 uint32
d 1x143 19296 cell
e 1x1 128 cell
>> save('G:\deletme0.mat','b','c','d','e')
>> save('G:\deletme1.mat','b','c','d','e','-v7.3')
>> save('G:\deletme2.mat','b','c','d','e','-v7.3','-nocompression')
>> tic; m = matfile('G:\deletme0.mat'); q = m.c(1:10,1:50); toc
Warning: The file 'G:\deletme0.mat' was saved in a format that does not support partial loading. Temporarily loading variable 'c' into memory. To use partial loading efficiently, save MAT-files with the -v7.3 flag. > In matlab.io.MatFile/inefficientPartialLoad (line 144) In matlab.io.MatFile/subsref (line 462)
Elapsed time is 0.009319 seconds.
>> tic; m = matfile('G:\deletme1.mat'); q = m.c(1:10,1:50); toc
Elapsed time is 0.013688 seconds.
>> tic; m = matfile('G:\deletme2.mat'); q = m.c(1:10,1:50); toc
Elapsed time is 0.013699 seconds.

Akzeptierte Antwort

Philip Borghesani
Philip Borghesani am 23 Mär. 2017
V7 matfiles are faster in general and can be much faster if many small structures are saved. When working with large files containing large variables V7.3 files can be partially loaded reducing time and memory while the entire V7 file must be loaded to extract any variable.
You might see different results if the sizes of c and d were in the millions.
  1 Kommentar
Joseph Hall
Joseph Hall am 23 Mär. 2017
Bearbeitet: Joseph Hall am 23 Mär. 2017
Thank you. Below shows a quick test which confirms your suggestion that -v7.3 files can be more efficient/faster than -v7 when partial-loading a larger size matrix.
>> a = zeros(1e6,50);
>> whos a
Name Size Bytes Class Attributes
a 1000000x50 400000000 double
>> save('G:\deletme0.mat','a','-v7')
>> save('G:\deletme1.mat','a','-v7.3')
>> save('G:\deletme2.mat','a','-v7.3','-nocompression')
>> tic; m = matfile('G:\deletme0.mat'); q = m.a(1:10,1:50); toc
Warning: The file 'G:\deletme0.mat' was saved in a format that does not
support partial loading. Temporarily loading variable 'a' into memory. To use
partial loading efficiently, save MAT-files with the -v7.3 flag.
> In matlab.io.MatFile/inefficientPartialLoad (line 144)
In matlab.io.MatFile/subsref (line 462)
Elapsed time is 0.228414 seconds.
>> tic; m = matfile('G:\deletme1.mat'); q = m.a(1:10,1:50); toc
Elapsed time is 0.006759 seconds.
>> tic; m = matfile('G:\deletme2.mat'); q = m.a(1:10,1:50); toc
Elapsed time is 0.036743 seconds.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Workspace Variables and MAT-Files finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by