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

@inbounds annotations for filter #30156

Merged
merged 1 commit into from
Dec 11, 2018
Merged

@inbounds annotations for filter #30156

merged 1 commit into from
Dec 11, 2018

Conversation

andyferris
Copy link
Member

No description provided.

@andyferris
Copy link
Member Author

Is travis MacOS build busted for everyone?

@@ -2345,7 +2345,7 @@ function filter!(f, a::AbstractVector)

for acurr in a
if f(acurr)
a[i] = acurr
@inbounds a[i] = acurr
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a policy for @inbounds, AbstractArray and the iteration protocol. I.e is it ok to segfault if someone implemented the iteration protocol erroneously?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is iterating over the index space of a: foreach(i -> a[i] = a[i], eachindex(a)). I think it's OK to assume that is required to hold.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK the policy is that AbstractArray implementations which opt-in to using @boundscheck assert that they are correct, so it's OK to crash if that's not the case. See #20469 and linked issues.

base/array.jl Outdated Show resolved Hide resolved
@@ -2345,7 +2345,7 @@ function filter!(f, a::AbstractVector)

for acurr in a
if f(acurr)
a[i] = acurr
@inbounds a[i] = acurr
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is iterating over the index space of a: foreach(i -> a[i] = a[i], eachindex(a)). I think it's OK to assume that is required to hold.

@andyferris andyferris merged commit 58f9bf7 into master Dec 11, 2018
@andyferris andyferris deleted the ajf/inbounds-filter branch December 11, 2018 02:06
@andyferris
Copy link
Member Author

Should performance improvements like this one be backported?

@andyferris andyferris added the performance Must go faster label Dec 11, 2018
@KristofferC
Copy link
Sponsor Member

Yes

@andyferris andyferris mentioned this pull request Dec 11, 2018
52 tasks
KristofferC pushed a commit that referenced this pull request Dec 12, 2018
KristofferC pushed a commit that referenced this pull request Dec 30, 2018
@KristofferC KristofferC mentioned this pull request Dec 30, 2018
53 tasks
@StefanKarpinski StefanKarpinski added status:triage This should be discussed on a triage call backport 1.0 and removed status:triage This should be discussed on a triage call labels Jan 31, 2019
@KristofferC KristofferC removed backport 1.0 status:triage This should be discussed on a triage call labels Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants