-
-
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
Deprecate linearindices in favor of LinearIndices #26775
Conversation
Triage accepts but the failures seem related. |
I did a few spot checks on performance here — iteration over |
9917005
to
a80c8c5
Compare
a80c8c5
to
786e282
Compare
7f274a0
to
5c6da0c
Compare
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan |
5c6da0c
to
94255ce
Compare
I've fixed the failures. One of them was interesting: on 32-bit, Regarding the Nanosoldier run,the |
Nanosoldier has been updated and retuned with Milan's changes. @nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan |
What's the status of this? It's 1.0 tagged. |
Sorry, I haven't investigated the |
I'm looking into it now. |
That seems to have done the trick for most of the regressions. Looks like there is still a bonus allocation in May as well have nanosoldier double-check my work: @nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan |
It appears that all CI builds time out (even after restarting one). Really weird. |
Looks like building the |
Good catch! That's intriguing. Test is the only affected module, and yet it doesn't use Can you detail what you suspect about code invalidation? BTW, I've checked that the problem is not due to Matt's last commit, and yet it didn't happen before I rebased. So maybe some interaction with a recent change on master. |
d68752b
to
c6b6100
Compare
Unfortunately, your fix has reintroduced the failure on 32-bit I mentioned above. I've pushed another commit which seems to also fix the problem, by moving the |
_all_match_first(f::F, inds) where F<:Function = true | ||
|
||
# keys with an IndexStyle | ||
keys(s::IndexStyle, A::AbstractArray, B::AbstractArray...) = eachindex(s, A, B...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method isn't documented and doesn't seem to be used. Probably better remove it? It's not clear whether it should call eachindex
rather than LinearIndices
/CartesianIndices
.
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan |
Most regressions seem to be spurious (as they don't appear in both Nanosoldier runs), except for |
…earIndices, ::AbstractRange) Plus two small fixes.
3a3683c
to
1ad025b
Compare
@nanosoldier |
base/indices.jl
Outdated
@@ -357,11 +357,16 @@ LinearIndices(A::Union{AbstractArray,SimpleVector}) = LinearIndices(axes(A)) | |||
IndexStyle(::Type{<:LinearIndices}) = IndexLinear() | |||
axes(iter::LinearIndices) = iter.indices | |||
size(iter::LinearIndices) = map(unsafe_length, iter.indices) | |||
length(iter::LinearIndices) = prod(size(iter)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If something is iterable and has a known length, it makes sense to define length
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it's also an AbstractArray
, in which case exactly this definition is defined as a fallback. I defined it because (like you) I was thinking about it as an iterable — but Milan is also correct that this is an array and doesn't technically need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah of course; I see.
Ah, thanks for cleaning that up! I'm still not entirely satisfied about the use of
|
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan |
Looks like all real performance regressions are fixed now! Regarding the use of For |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good as it is. Barring any other comments, let's merge in the next 24 hours.
This broke master since I merged #26993 and this PR didn't run CI after that merge, failure:
(Sorry for the breakage, but I guess this proves that it is nice to have strict mode enabled :) ) |
A couple of depwarns that was caught by doctests julia> prod(1:20)
┌ Warning: `LinearIndices(inds::Vararg{AbstractUnitRange{Int}, N}) where N` is deprecated, use `LinearIndices(inds)` instead.
│ caller = _mapreduce(::typeof(identity), ::typeof(Base.mul_prod), ::IndexLinear, ::UnitRange{Int64}) at reduce.jl:334
└ @ Base reduce.jl:334
2432902008176640000
julia> copyto!([1.0, 2.0], 1:2)
┌ Warning: `LinearIndices(inds::Vararg{AbstractUnitRange{Int}, N}) where N` is deprecated, use `LinearIndices(inds)` instead.
│ caller = copyto!(::IndexLinear, ::Array{Float64,1}, ::IndexLinear, ::UnitRange{Int64}) at abstractarray.jl:718
└ @ Base abstractarray.jl:718
2-element Array{Float64,1}:
1.0
2.0 We really need #27000 -- the doctests are as important as the regular tests, and as shown here, covers some different paths. |
Seems like the case with Lines 1582 to 1586 in 4c665b7
should not be deprecated? |
I'm not reproducing that. There are the N=1 methods just below the lines you posted. |
Yea, cause I included them in #27037 😄 |
That's awesome. Thanks so much @fredrikekre! I need to drink more coffee and change my issue-reading order! |
I've filed #27090 about the |
LinearIndices
is strictly more powerful thanlinearindices
: these two functions return arrays holding the same elements, but the former also preserves the shape and indices of the original array. Also improve docstrings.Part of #25901.
Not all uses of
linearindices
in Base can be replaced withLinearIndices
, because of the order in which array support is defined. For these cases, I usedeachindex(IndexLinear(), A)
, which needs to continue to work anyway and return a range of linear indices. This is why I marked this as RFC: while it simplifies the public API, one still needs to choose betweenLinearIndices
andeachindex
. In particular, I'm not sure whetherlinearindices
/eachindex
can be more efficient (since it returns simple ranges) thanLinearIndices
, at least in terms of compilation time.