-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance regression in h5read #752
Comments
Dupe of #742. We have outstanding PRs that address these performance issues, should be fixed in the next week or so. |
Best bet is to wait if you can. |
Is this a duplicate? The output suggests this is just reading a single Float32 value, while PR #745 is all about avoiding the (ab)use of large tuples in fixed-length arrays/compound data types. I think this case should be independent of that. Edit: I just noticed the indexing — What is the complete data type and shape of the @laborg — the one thing I'd be interested in seeing further is whether you can show the same regression on a bare |
I'll leave this open until, we have feedback from OP. |
An MWE, taken from the HDF5 docs, shown on 0.13.7 and master: 0.13.7
master
So there is also a regression in |
With that extra bit of info, I don't think it's the read time which has change significantly — rather, the time to open the dataset itself is longer. julia> using HDF5, BenchmarkTools
[ Info: Precompiling HDF5 [f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f]
julia> h5write("/tmp/test.h5", "mygroup/A", collect(reshape(1:120, 15, 8)))
julia> fid = h5open("/tmp/test.h5", "r")
HDF5 data file: /tmp/test.h5
# HDF5 v0.13.7:
julia> HDF5.libversion
v"1.10.4"
julia> @btime read($(fid["mygroup/A"]));
6.478 μs (21 allocations: 1.94 KiB)
julia> @btime $(fid["mygroup/A"])[$(2:3:15), $(3:5)];
17.027 μs (64 allocations: 2.83 KiB)
julia> @btime fid["mygroup/A"];
3.514 μs (1 allocation: 32 bytes)
# HDF5 master:
julia> HDF5.libversion
v"1.12.0"
julia> @btime read($(fid["mygroup/A"]));
7.566 μs (13 allocations: 1.61 KiB)
julia> @btime $(fid["mygroup/A"])[$(2:3:15), $(3:5)];
11.769 μs (36 allocations: 1.83 KiB)
julia> @btime fid["mygroup/A"];
13.872 μs (3 allocations: 96 bytes)
# HDF5 PR #745
julia> HDF5.libversion
v"1.12.0"
julia> @btime read($(fid["mygroup/A"]));
8.718 μs (14 allocations: 1.62 KiB)
julia> @btime $(fid["mygroup/A"])[$(2:3:15), $(3:5)];
13.382 μs (36 allocations: 1.80 KiB)
julia> @btime fid["mygroup/A"];
13.592 μs (3 allocations: 96 bytes) Read-all is slightly slower, but there's a corresponding improvement in indexed reads going from HDF5.jl v0.13.7 to 0.14/master when the opened I haven't yet tried isolating whether that's due to |
When there are no keyword arguments, just use the global `DEFAULT_PROPERTIES` rather than creating new `HDF5.Properties` with default values. This improves the regression identified in issue JuliaIO#752. Specifically, the benchmark used in JuliaIO#752 (comment) is improved from ```julia julia> @btime fid["mygroup/A"]; 13.872 μs (3 allocations: 96 bytes) ``` on master to ```julia julia> @btime fid["mygroup/A"]; 6.778 μs (1 allocation: 32 bytes) ``` with this commit.
PR #753 helps, but it's not conclusive. There's a regression in reads on Julia v1.5 that doesn't show up as clearly on Julia's master branch. I've run the test julia> @btime read(fid, "mygroup/A") using both Julia versions for various combinations of HDF5.jl: v0.13.7, master (~0.14.1), PR #753 (makes fewer properties objects), PR #745 (reworks read type normalization), and finally a branch which merges 745 and 753 onto master. The results look good for Julia 1.6/master, but there's still a regression on v1.5 (and presumably all v1.3–1.5):
|
Is the regression related to v1.5 compiler issues? The v1.6 numbers look very good. If it's related to the compiler failing to optimize, perhaps there's not much we can do for now. |
Yes, there must be something in the code that Julia v1.6 can better optimize than older versions can. A while back when I started investigating for #745 I had assumed there'd be a performance break between Julia v1.4 and v1.5 due to v1.5's ability to inline more structs, but since it's actually a break between v1.5 and v1.6, the cause must be something else. I haven't yet figured out what new feature it must be, though. There are probably more fixes like #753 which can eat away at the regression and slowly improve performance (across all Julia versions), but I suspect there's always going to be a performance gap between v1.5- versus v1.6+ just due to the compiler being more capable. |
When there are no keyword arguments, just use the global `DEFAULT_PROPERTIES` rather than creating new `HDF5.Properties` with default values. This improves the regression identified in issue #752. Specifically, the benchmark used in #752 (comment) is improved from ```julia julia> @btime fid["mygroup/A"]; 13.872 μs (3 allocations: 96 bytes) ``` on master to ```julia julia> @btime fid["mygroup/A"]; 6.778 μs (1 allocation: 32 bytes) ``` with this commit.
So, some unfortunate news: I can't reproduce my own timings from #752 (comment), particularly where Julia v1.6 seemed to be able to outperform v1.5. My guess at this point is that somehow I managed to get extra method specializations from whatever route of branch-switching I did while I wanted to figure out what feature might be most responsible for the apparent performance difference between Julia v1.5 and v1.6, so in prepping for the ability to run across more git branches, I coded up a script to do the timing rather than doing it all by hand. Notably, the script launches a new Julia process (without my startup file) for each timing, so there can't be any interaction with
Quick observations:
|
I think this might be a separate issue but continuous calls to On Julia master + HDF5 14.1 + HDF5_jll 1.12 and 1.10!
Maybe some resources aren't freed properly? on Julia master + HDF 0.13.7 + HDF5_jll 1.10
|
I had a hunch and with this changes:
...performance of |
Thanks for that tip — that's easy enough to patch; see #754. Adding another test to my script (but reducing the range of commits being tested) on Julia v1.5.3: |
@jmert that scripts looks very useful, do you mind sharing it? |
Sure — it's a bit of a mess and should probably be properly using the full tools of https://gist.github.com/jmert/b4af1ba8928985f990afbe0284dcaf2e |
closing this as I think we've addressed most of the "major" regressions |
My system:
On 0.13.7:
on 14.1
Any way to work around this, besides downgrading?
The text was updated successfully, but these errors were encountered: