Skip to content
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

Support @inbounds in setindex!(::Array, ::AbstractArray, ::AbstractVector} #20910

Merged
merged 1 commit into from
Mar 7, 2017

Conversation

nalimilan
Copy link
Member

Previously this annotation wouldn't have any effect on Array, contrary to
what happens with the general AbstractArray fallback method.
Also always use @inbounds for X[count] since count depends on the length of I,
(which is checked), and mark setindex_shape_check() as a bounds check.

Fixes #20907.

…ctor}

Previously this annotation wouldn't have any effect on Array, contrary to
what happens with the general AbstractArray fallback method.
Also always use @inbounds for X[count] since count depends on the length of I,
(which is checked), and mark setindex_shape_check() as a bounds check.
@nalimilan
Copy link
Member Author

Failures are #20906. We should probably run Nanosoldier if it passes the review, though.

@ararslan
Copy link
Member

ararslan commented Mar 6, 2017

I've restarted CI now that #20906 has been merged.

@ararslan ararslan added the domain:arrays [a, r, r, a, y, s] label Mar 6, 2017
@blakejohnson
Copy link
Contributor

LGTM

@mbauman
Copy link
Sponsor Member

mbauman commented Mar 6, 2017

@nanosoldier runbenchmarks(ALL, vs = ":master")

@mbauman
Copy link
Sponsor Member

mbauman commented Mar 6, 2017

With regards to using @boundscheck blocks for setindex_shape_check, I think that's fine. We could eventually do the same for the general AbstractArray methods. I didn't worry too much about it since it's typically much cheaper than the real work.

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

@KristofferC KristofferC merged commit 9771c78 into master Mar 7, 2017
@KristofferC KristofferC deleted the nl/setindex! branch March 7, 2017 06:52
@blakejohnson
Copy link
Contributor

That array comprehension slowdown is troubling. Can you reproduce that locally, @nalimilan?

@KristofferC
Copy link
Sponsor Member

KristofferC commented Mar 7, 2017

It is a very noisy benchmark that warns every second time the benchmarks are run which is why I merged anyway. I can double check to make sure?

@simonster
Copy link
Member

@_propagate_inbounds_meta includes @inline. I'm not sure it's a good idea to inline a function as big as setindex!(A::Array, X::AbstractArray, I::AbstractVector{Int}).

@blakejohnson
Copy link
Contributor

Unfortunately, our @inbounds mechanism requires inlining in order to have any effect.

@simonster
Copy link
Member

I am aware. It just seems weird to be inlining a 13 line function to make it possible to elide bounds checks. That can have serious consequences in terms of compilation time even for people not using @inbounds.

In this case, maybe we could do something like:

function setindex!(A::Array, X::AbstractArray, I::AbstractVector{Int})
    @_inline_meta
    @boundscheck return checked_setindex!(A, X, I)
    unchecked_setindex!(A, X, I)
end

The method splitting could be done automatically with a macro, although that may not be so easy this early in bootstrap.

@blakejohnson
Copy link
Contributor

If we can make that work, I agree that it would be better.

@nalimilan
Copy link
Member Author

Makes sense. Though that would be unsafe_setindex!.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:arrays [a, r, r, a, y, s]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants