Gradual slowdown of h5write in Julia HDF5 package

EDIT: Based on additional experiments, I am sure that the slowdown occurs in response to many calls to open and close routines ( h5openand close). Now I am a little short time, but I will return and add more code / details in the next few days.

Using the HDF5 package for Julia, I noticed that the function h5writestarts to slow down if you perform many iterations on calls h5writeand h5read. Interestingly, in order for the behavior to be really obvious, you need to read and write to a large number of places in a small number of files. You can get a demonstration of the behavior that I'm talking about by starting a Julia session and executing the following routine (note that you will need the HDF5 package):

#Set parameters
numFile = 10;
numLocation = 10000;
writeDir = "/home/colin/Temp/";
FloatOut = 5.5;

#Import functions
using HDF5

#Loop over read/writes.
c1 = 1;
timeMat = Array(Float64, numFile * 2, 2);  
for i in 1:numFile
    filePath = string(writeDir, "f", string(i), ".h5");
    for j in 1:numLocation
        location = string("G1/L", string(j));
        if j == 1 || j == numLocation; tic(); end;      
        h5write(filePath, location, FloatOut);
        if j == 1 || j == numLocation; timeMat[c1, 1] = toc(); end;
        if j == 1 || j == numLocation; tic(); end;
        FloatIn = h5read(filePath, location);
        if j == 1 || j == numLocation; timeMat[c1, 2] = toc(); end;
        if j == 1 || j == numLocation; c1 = c1+1; end;  
    end
    rm(filePath);
end

5.5 ( - ) 10,000 10 h5write. h5read. , timeMat (: , ). :

h5write  h5read
0.0007   0.0004
0.0020   0.0004
0.0020   0.0004
0.0031   0.0004
0.0034   0.0004
0.0049   0.0004 
0.0050   0.0004
0.0064   0.0005
0.0068   0.0004
0.0082   0.0004
0.0084   0.0005
0.0106   0.0005
0.0114   0.0005
0.0114   0.0005
0.0120   0.0005
0.0131   0.0005
0.0135   0.0005
0.0146   0.0005
0.0151   0.0005 
0.0163   0.0005

h5read . , h5write . , , . , , , ( ) . , . , , , , , , . , , - .

: Julia, hdf5, , , - .

+4
1

; , close, ccall. , C- HDF5.

, , , ; -. :

filePath = string(writeDir, "f", string(i), ".h5")
h5open(filePath, "w") do file
    global c1
    for j in 1:numLocation
        ...
        write(file, location, FloatOut)
        ...
        FloatIn = read(file, location)
        ...
    end
end

, . 100 .

, issue.

+5

Source: https://habr.com/ru/post/1548214/


All Articles