-
Notifications
You must be signed in to change notification settings - Fork 43
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
Specialize on Type
s and use if-else instead of Val
-dispatches
#383
Conversation
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.
This does mean that we can't easily extend the options to construct other samplers though 😕 A bit annoying if we have to mess around with if statements for this, no?
And do we really care that the constructors result in dynamic dispatch?
IMO the whole
I started to go through the code since we saw performance regressions when updating from AdvancedHMC 0.4 to 0.6 (and therefore had to revert to 0.4 for the time being). We are not dealing with these constructors though, it was just a by-product. |
What would you suggest instead?:)
Hmm interesting. How bad? |
IMO
One of our tests regressed from 1.273538 seconds (9.12 M allocations: 3.126 GiB, 17.24% gc time) to 1.998561 seconds (14.89 M allocations: 5.109 GiB, 18.50% gc time) I wonder if the increase in number of allocations points to an increase in type inference issues. |
Hmm, maybe, maybe. I'm slightly worried that this is still a bit "too much" for some users. However, I do agree that the current symbol-based approach also isn't ideal 😕 |
Isn't this the same as e.g. |
Sure, but that is a single configuration field; it does get a bit verbose if you have to do this for a several, no? But maybe we can take this discussion elsewhere 👍 Regarding the PR, I'll approve:) |
The PR tries to improve a few things I noticed when skimming through the code, most noteably
missing specializations on
Type
s: Julia does not specialize onT::Type
, one has to use::Type{T}
misuse of
Val
in type-unstable code involvingSymbol
s: this does not recover type stability but leads to dynamic dispatches which are quite slow. Compare, e.g.,