-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
50 x perfomance regression in 0.5.0 when indexing > 4 dimensional array #18774
Comments
Thanks for the report. If you're willing to share code privately, let us know. cc: @mbauman. |
As a first pass, you could try adding an inline annotation to import Base: to_index, to_indexes
@inline to_indexes(i1, I...) = (to_index(i1), to_indexes(I...)...) |
@mbauman: is that suggestion meant as a work-around or a way of debugging the perf issue? |
It's a stab at a remote debugging attempt. If it resolves the issue it's a very easy fix. |
@mbauman, forcing the inlining indeed resolves the regression, bravo! I don't know what I am doing which is contrary to the inlining heuristic (though the indexing is by a mixture of inlined functions, scalars, and array elements)... If you would like to look at the code privately let me know. |
I also experienced this issue in a code which is much slower on 0.5 than 0.4. I made an example.
0.4:
0.5:
For me the cutoff is from 5 to 6 dimensional arrays. I tried running the code @mbauman posted, but it didn't fix the issue. Using a linear index fixes the issue. |
Force inlining on getindex and to_indexes (fixes #18774)
I'm not sure this is completely fixed. I have a 6 dimensional stencil computation testcase here that shows a slowdown compared to julia 0.4. I build 0.6 commit 4ec2db0* (2016-10-29 05:01 UTC), so it should have the most recent fix. 0.4 timing:
0.5 timing:
0.6 timing:
The profiler is running the second time, which is why the second run is slower. The profile results: 0.4:
0.6:
Its better than 0.5, but |
cc @timholy |
Would be great if you'd contribute that to BaseBenchmarks. |
Sure, I'll put together a PR this weekend. |
Finally got the benchmark together and merged. @tkelman backport? |
#19097 is already labeled |
Ah, I missed that. Thanks. |
I have a private code which is experiencing a severe performance regression:
0.4.6:
0.072002 seconds (324.63 k allocations: 41.946 MB, 46.46% gc time)
,0.5.0:
3.908818 seconds (18.74 M allocations: 512.229 MB, 1.76% gc time)
.Profiling the code on 0.5.0 indicates that almost all the time is spent in
to_indexes
following an assignment operation on a 5-dimensional matrix:L[flmidx(l,m),tidx,elidx[1],elidx[2],elidx[3]] += val
.If I rewrite the subscript as a linear index:
L[sub2ind(size(L),flmidx(l,m),tidx,elidx[1],elidx[2],elidx[3])] += val
,the regression is avoided
0.5.0:
0.075638 seconds (698.01 k allocations: 54.585 MB, 13.93% gc time)
.Notes:
@inline
and the assignment with@inbounds
This looks very much like #11819, though the example in said issue does not demonstrate a regression.
I have tried repeatedly to create a suitable MWE, but the regression disappears when I change almost anything about the setting of the assignment. If someone from core Julia would like to have a look, please let me know.
The text was updated successfully, but these errors were encountered: