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

Force inlining on indices(A, d) #18014

Merged
merged 1 commit into from
Aug 17, 2016
Merged

Force inlining on indices(A, d) #18014

merged 1 commit into from
Aug 17, 2016

Conversation

timholy
Copy link
Sponsor Member

@timholy timholy commented Aug 13, 2016

Addresses f9fb4da#commitcomment-18621877.

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

@nanosoldier
Copy link
Collaborator

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

@KristofferC
Copy link
Sponsor Member

That was anticlimactic.

@timholy
Copy link
Sponsor Member Author

timholy commented Aug 13, 2016

Might just reflect the state of our performance tests. But since it tends to be something you call at the beginning of a loop (once), it shouldn't affect performance that much.

(Bounds-checking was once implemented using indices(A, d), but the new version uses the whole incides tuple to avoid the branch on checking that d falls within the dimensions of A. Back in that era, this change would have mattered a lot.)

@timholy
Copy link
Sponsor Member Author

timholy commented Aug 13, 2016

Despite the lack of improvement on our benchmarks, I suspect this is still worth doing, but I'll leave this open for further comments.

@@ -51,7 +51,11 @@ size{N}(x, d1::Integer, d2::Integer, dx::Vararg{Integer, N}) = (size(x, d1), siz

Returns the valid range of indices for array `A` along dimension `d`.
"""
indices{T,N}(A::AbstractArray{T,N}, d) = d <= N ? indices(A)[d] : OneTo(1)
function indices{T,N}(A::AbstractArray{T,N}, d)
@_inline_meta
Copy link
Member

Choose a reason for hiding this comment

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

whats wrong with @inline?

I notice Base has a lot of @_inline_meta but I don't understand why

Copy link
Contributor

Choose a reason for hiding this comment

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

Needed before @inline is usable, typically before some array functions are defined.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

To expand a bit: since macros run at code-loading time (not compilation time), julia has to be capable of doing everything that the @inline macro calls in its internal implementation. At this point, array.jl hasn't even been loaded yet.

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks!

@kshyatt kshyatt added performance Must go faster domain:arrays [a, r, r, a, y, s] labels Aug 17, 2016
@timholy
Copy link
Sponsor Member Author

timholy commented Aug 17, 2016

There don't seem to be any objections, so let's do this.

@timholy timholy merged commit 21b2693 into master Aug 17, 2016
@timholy timholy deleted the teh/force_inlining_indices branch August 17, 2016 14:26
@tkelman
Copy link
Contributor

tkelman commented Aug 20, 2016

If you think this should be backported, do speak up.

@timholy
Copy link
Sponsor Member Author

timholy commented Aug 20, 2016

woof woof

(I don't think this is very important, but there's also no reason not to have it, and it might save someone from a #17126-like annoyance.)

tkelman pushed a commit that referenced this pull request Aug 20, 2016
(cherry picked from commit 95b858a)
ref #18014
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] performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants