-
Notifications
You must be signed in to change notification settings - Fork 17
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
Type unstability in make_interval
#91
Comments
But it finds the correct type in the end for |
I'm not sure I understand what you mean; according to the output, f(x) is I'll try to push later what I've done so far; at least for this case, it solves the problem. |
I can see that julia> f(Interval(1.0))
[2.0, 2.0]
julia> typeof(ans)
ValidatedNumerics.Interval{Float64} Or what am I missing? |
Ok, but this is not what the compiler gets. (The issue is like the problem to pass functions as arguments of functions: as I understand it, your function may be ok, but the compiler doesn't know it.) What we should aim is to get something like @code_warntype f(1.0)
Variables:
#self#::#f
x::Float64
Body:
begin # none, line 1:
return (Base.box)(Base.Float64,(Base.add_float)((Base.box)(Float64,(Base.sitofp)(Float64,1)),x::Float64))
end::Float64 That is, the compiler knows it will get a |
Yes you're right. What is not clear to me is why that's happening for |
I think the problem is related to the use of macros and changes in the rounding modes. At least this is the common thing of the cases I've isolated; see #92. This things do have a performance penalty, which I is improved, but not totally away. |
Could you add some performance-related tests or notebooks in a new |
I'll add the kind of things I've tested, but I don't quite know how to make a nice comparison of the performance of the same module. |
EDIT: I guess I will have to correct something; while the tests |
I'm not quite sure why, but with the current master, this issue is not appearing in julia v0.5: julia> VERSION
v"0.5.0-dev+3040"
julia> f(x) = 1+x
f (generic function with 1 method)
julia> @code_warntype f(Interval(1.0))
Variables:
#self#::#f
x::ValidatedNumerics.Interval{Float64}
Body:
begin # none, line 1:
return (top(_apply))(Base.+,(Base.promote)(1,x::ValidatedNumerics.Interval{Float64})::Tuple{ValidatedNumerics.Interval{Float64},ValidatedNumerics.Interval{Float64}})::ValidatedNumerics.Interval{Float64}
end::ValidatedNumerics.Interval{Float64} Also, comparing this (julia v0.5) case with the first example quoted (julia v0.4), the number of intermediate generated variables is larger in v0.4, which is reflected in the allocation when
Maybe all this is solved by JuliaLang/julia#13412 |
OK, that's good to know! Yes, issue 13412 seems to have solved a lot of problems! The slow tests on 0.5 is a problem. I reported it as an issue but there doesn't seem to be any progress yet. |
One place where our tests hang for a long time is around "minimal_pow" tests... |
Yes, the problem is that there is a very large number of tests in that set, and the time scales very badly with the number of tests for some reason: JuliaLang/julia#15346 |
That problem was introduced by JuliaLang/julia#13412 ! |
I think you are right that the root source of the type instability was passing functions to functions. However, this is fixed in 0.5 by JuliaLang/julia#13412, and I do not think that we should rewrite everything to avoid doing this. (Unfortunately, that change also introduced the problem that the long test suites are extremely slow.) |
Closing for now. Feel free to reopen if you think it's necessary. |
I just became across an issue that suggests that there is somewhere/somehow type instability in ValidatedNumerics.jl. The following example illustrates the problem:
Note the
Any
s appearing inGenSym(2)
, that suggest looking atmake_interval()
, and going further, I think thatsplit_interval_string()
may be responsible.Using,
f(x)=x
, orexp(x)
, is type stable.The text was updated successfully, but these errors were encountered: