-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove some typeasserts that were causing severe performance issues
- Loading branch information
Showing
2 changed files
with
10 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
024bbce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JeffBezanson this commit has the following effects on printfd timing:
~30 (baseline number, from 0.2 / 0.3)
~120 (prior commit)
~40 (prior commit, but with patch to perf.jl)
~20 (this commit, with this patch)
~26 (0.3 with only patch to perf.jl)
~80 (with this patch, but without patch to perf.jl)
I think inference needs to be taught to drop unnecessary typeasserts so that it can do better remove_redundant_temp_vars, SSA reduction, and/or tuple allocation.
024bbce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like
typeassert
should be added to the pure builtins list. Yes, it should also have a custom inliner. Kind of surprised we didn't do that already.It's debatable whether the change to
perf.jl
is legit --- we should make both versions fast.024bbce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this slowdown is because I declare
out::IO
in the function call, so it can't inline it because it can't verify thatio
is anIO
. adding a typeassert in theperf.jl
change also fixes the performance issuei would make the first version fast by adding a inference transformation that converted into the second version (by inlining the
open
function, adding an inlining pass to remove single use closures, and rerunning type-inference after inlining a function with a parameter of typeFunction
).so I it depends on what you want this function to test. i would suggest splitting it into two, if we don't already have tests for the performance of anonymous functions
024bbce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
however, i think this would be fixed by codegen-ing a typeassert at this line, instead of returning NF:
julia/base/inference.jl
Line 2012 in c8c7aae
024bbce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is typeassert actually pure? it has ramifications for control flow, which make it hard to rearrange safely
024bbce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All it might do is throw an error, but other functions in the pure builtins list do too.
024bbce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i'm working a pull request now
024bbce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually we'll also need better codegen of typeasserts with tuple types. I think we punt on those right now.