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

optimize (a little bit) faster #31338

Merged
merged 2 commits into from
Mar 25, 2019
Merged

optimize (a little bit) faster #31338

merged 2 commits into from
Mar 25, 2019

Conversation

vtjnash
Copy link
Sponsor Member

@vtjnash vtjnash commented Mar 13, 2019

Simplifies some code patterns that the compiler can't optimize.

Adds a fast-path to subtype to attempt to handle common simple cases. We also still probably should duplicate parts of this fast path in the compiler (to handle the pattern x isa AnySSAValue), since it is now heavily used by the optimizer code in various hot-paths.

Also updates a few of the inlining costs to reflect that certain operations have non-zero expected cost in aggregate. This helps to put an eventual cap on the inlining of large functions that consist mostly of these operations.

@@ -780,8 +780,10 @@ function renumber_ssa2(val::SSAValue, ssanums::Vector{Any}, used_ssa::Vector{Int
if do_rename_ssa
val = ssanums[id]
end
if isa(val, SSAValue) && used_ssa !== nothing
Copy link
Member

Choose a reason for hiding this comment

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

Is there a performance advantage to avoiding the && here?

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.

yeah, inference can't see through &&, so it's best not to combine isa with anything else in the same expression

@Keno
Copy link
Member

Keno commented Mar 13, 2019

Optimizer parts look fine to me. @JeffBezanson should look at the subtyping improvements.

src/subtype.c Outdated Show resolved Hide resolved
}
if (jl_obvious_subtype((jl_value_t*)temp, y, subtype) && *subtype)
return 1;
return 0;
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't this be simplified to

return (jl_obvious_subtype((jl_value_t*)temp, y, subtype) && *subtype)

?

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.

yes, but it would break the symmetry with the rest of the function

@vtjnash vtjnash changed the title [WIP] optimize (a little bit) faster optimize (a little bit) faster Mar 19, 2019
@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Mar 22, 2019

@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 @ararslan

This is a new subtype pre-process step that attempts to look for
easily computable reasons that the result must be false (or true).
Since it can avoid allocating an `stenv` and otherwise setting up the
state needed for handling TypeVar constraints precisely,
it is hoped to save time (on average) by filtering out easy cases.
help performance by removing bits of code highlighted by profiling as
possible hot-spots.
@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Mar 22, 2019

@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 @ararslan

@vtjnash vtjnash merged commit bea863e into master Mar 25, 2019
@vtjnash vtjnash deleted the jn/opt-faster branch March 25, 2019 17:18
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.

5 participants