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

Add @inline for do blocks #35116

Closed
wants to merge 1 commit into from
Closed

Add @inline for do blocks #35116

wants to merge 1 commit into from

Conversation

tkf
Copy link
Member

@tkf tkf commented Mar 15, 2020

This PR makes @inline work with do blocks. This is very useful for writing high-performance code with higher-order functions such as foreach, foldl, and reduce.

@StefanKarpinski
Copy link
Member

Alternately, should do blocks be automatically marked for probably inlining?

@JeffBezanson
Copy link
Member

Alternately, should do blocks be automatically marked for probably inlining?

I would prefer not to do that, since many uses of do blocks don't need that level of performance, and it will add compile time cost. It's easier to mark cases where you need performance than to mark cases where you don't need performance, especially since the only symptom would be gradual degradation in compile times.

@tkf
Copy link
Member Author

tkf commented Mar 16, 2020

I think a long term solution would be to have call-site inlining as the caller has a good guess for what should be inlined in this case (e.g., foreach requires inlining but open does not).

@JeffBezanson
Copy link
Member

Yes, call-site inlining would be good. Now that you mention it, the syntax in this PR conflicts with it --- @inline f() do ... end would mean f should be inlined if we had that feature.

@StefanKarpinski
Copy link
Member

IIRC, @vtjnash claimed that call site inlining would be "fairly trivial to implement" like three yrs ago.

@tkf
Copy link
Member Author

tkf commented Mar 16, 2020

Maybe inline both is what you'd want in this case? For finer control, how about

Normal call

f(a, b) do c, d
end

Inline only f:

@inline(f(a, b)) do c, d
end

Inline only do block:

f(a, b) do c, d
    @inline  # just like @_inline_meta
end

@aviatesk
Copy link
Member

Superseded by #41312.

@aviatesk aviatesk closed this Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants