-
Notifications
You must be signed in to change notification settings - Fork 3
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
Extreme compile times for some functions #9
Comments
Digging a bit deeper, it turns out that we're also suffering from invenia/Intervals.jl#144 julia> using SnoopCompile
julia> invalidations = @snoopr begin
using DescriptorSystems;
G = rss(2,2,4);
gnugap(G, G)
end;
julia> trees = SnoopCompile.invalidation_trees(invalidations);
julia> @show length(SnoopCompile.uinvalidated(invalidations)) # show total invalidations
length(SnoopCompile.uinvalidated(invalidations)) = 1900
1900
julia> show(trees[end]) # show the most invalidated method
inserting convert(::Type{T}, interval::Intervals.AnchoredInterval{P, T}) where {P, T} in Intervals at /home/fredrikb/.julia/packages/Intervals/ua9cq/src/anchoredinterval.jl:181 invalidated: there are almost 2000 invalidations from running the small code snippet above which is huge, and about half of those comes from invenia/Intervals.jl#144 |
Yes, I am aware of this problem. Probably you are right, an it is related to #8. You probably recall that when I tried to alleviate the issue, I faced some bugs in the implementation of
So, I stopped investing more time in this direction, until this bug will be corrected in the LTS version, Fortunately, my implementation can overcome this Julia bug:
I hope I will be able to dedicate more time to this issue after finishing the implementation of the FaultDetectionTools.jl (probably in the next 2-3 months). Regarding the invalidation aspect, I don't understand what is going on. I never used the mentioned conversion funtion directly. It is only a guess, but this function is probably imported via the Polynomials package, which has |
Just to clarify, the invalidation problem is not due to this package. I mentioned it on slack yesterday and got the answer that they might be able to solve it in Intervals.jl where the problem lies. |
I tried this again in julia v1.8-beta1 with DescriptorSystems v1.3 and the timing has improved by 20 seconds, a great step! julia> @time gnugap(G, G)
38.420655 seconds (115.38 M allocations: 5.127 GiB, 4.95% gc time, 99.99% compilation time) but it still takes quite a long time. Apparently, I can't really figure out what the remaining problem is, it appears as if execution reaches the call to using Revise
using SnoopCompileCore
using DescriptorSystems;
G = rss(2,2,4);
tinf = @snoopi_deep ghinfnorm(G);
using ProfileView, SnoopCompile
ProfileView.view(flamegraph(tinf)) leads to a similar looking plot with what appears to be a call to |
The call to disc || E == I || rcond(E) >= n*eps(float(real(T1))) || (return Inf, Inf) |
It looks like the compilataion time has regressed again on julia v1.8.0-rc1
up from 38.42 seconds a few posts up. The same version of DescriptorSystems (v1.3.2) on julia v1.7 is a bit better, but still very long compile time julia> @time gnugap(G, G)
72.154130 seconds (135.50 M allocations: 6.680 GiB, 3.71% gc time, 99.95% compilation time)
(6.21299328221319e-16, Inf) EDIT: Somthing was off with my initial benchmark, it's actually a slight bit faster on 1.8
still, much worse than it was in #9 (comment) |
I fixed the issues related to possible type instability in
In Julia 1.8, there are no red lines anymore in the output. Also Inspecting with the cursor the result of The compilation times are hopefully better, although probably still too long. I should have a look to the precompilation possibilities or producing sysimages. |
I've experienced quite extreme compile times for some functions, here's an example
This problem is likely to be related to #8, since type piracy is likely to lead to method invalidations and inference problems that in turn cause recompilation of a lot of base methods. To investigate this hypothesis, we can make use of SnoopCompile.jl
This displays the following graph
The colored flames indicates stacks, and their extent in the horizontal direction indicate their run time. Notice how there is a large horizontal gap in the flame graph, followed immediately by the stack for
Base.typed_hvcat
(where I've held the mouse to display the method name in the screenshot. This is a clear indication that the type piracy of #8 causes huge compile times, likely due to type inference problems.Running
@code_warntype [G G]
indicates that there are type inference problems present when concatenating systems:
notice variables
E::Any
and@_13::Union{UniformScaling, Matrix{Float64}}
.The other gaps in the flame graph points to the folowing methods
as well as https://github.com/andreasvarga/DescriptorSystems.jl/blob/main/src/dss.jl#L52
The text was updated successfully, but these errors were encountered: