Uh oh!
There was an error while loading. Please reload this page.
use StaticArraysCore - #599
Conversation
mcabbott
commented
Sep 19, 2022
With these two PRs: julia>@time_importsusing ForwardDiff
6.3 ms IrrationalConstants
0.9 ms DiffRules
2.7 ms StaticArraysCore
2.3 ms DiffResults
19.3 ms Preferences
1.2 ms OpenLibm_jll
0.3 ms NaNMath
0.1 ms Compat
82.6 ms ChainRulesCore
3.6 ms DocStringExtensions 68.58% compilation time
0.7 ms ChangesOfVariables
0.6 ms InverseFunctions
0.7 ms LogExpFunctions
0.3 ms JLLWrappers
2.9 ms OpenSpecFun_jll 76.75% compilation time
15.5 ms SpecialFunctions
27.6 ms MacroTools
0.3 ms CommonSubexpressions
101.4 ms ForwardDiffBefore, StaticArrays completely dominates: julia>@time_importsusing ForwardDiff
6.4 ms IrrationalConstants
0.7 ms DiffRules
2.4 ms StaticArraysCore
608.7 ms StaticArrays
2.4 ms DiffResults
20.7 ms Preferences
1.2 ms OpenLibm_jll
... |
Uh oh!
There was an error while loading. Please reload this page.
mcabbott
commented
Sep 24, 2022
CI gives errors like this, which don't show up when running simple examples locally: |
devmotion
commented
Sep 24, 2022
My suspicion is that the type piracy in StaticArrays is actually a problem here: it defines functions (that it does not own) for types in StaticArraysCore (that it does not own) which are not available when the |
mcabbott
commented
Sep 24, 2022
Yes that's my guess too. I did not try very hard to replicate locally, but I did use ForwardDiff first, before loading StaticArrays. Scrolling through it looks like all are from |
devmotion
commented
Sep 24, 2022
Yes, seems that might be sufficient for ForwardDiff. However, I guess these issues could also occur in other packages for different functions and hence ideally StaticArrays would fix these type piracies. |
fredrikekre
commented
Sep 24, 2022
The only way to fix (all of) them would be to merge the two packages again, no? |
Hmm, I am not familiar with the internals of StaticArrays but from a quick look it indeed seems that most of StaticArrays is type piracy currently - and hence, as far as I understand, potentially problematic when working with |
thchr
commented
Sep 24, 2022
This seems to run counter to most of the point of having a *Core.jl package: the parent package must commit a great deal of type-piracy. For StaticArrays, it must be nearly 100% since most of its functionality comes from extending Base/stdlib functions. We could in principle put all |
devmotion
commented
Sep 24, 2022
Sure, I see that one has to commit type piracy somewhere, so the ideal I mentioned above won't be possible. However, with the current setup to me it seems that one can't use Base functionality of static arrays inside of Maybe that could be avoided for Base functions by moving all definitions with Base functions to StaticArraysCore (without stdlibs) but maybe already that would increase compilation and loading times of StaticArraysCore too much... |
mcabbott
commented
Sep 25, 2022
It might be narrower than that. Functions which act on the instance can't be called until you have one, but functions which accept the type can be called outside the returned quote, and these are the problem. Minimal example: # Core packagestruct M1 endfoo(x::Int) = x
# Foreign package@generatedfunctiongen(x::T) where T
# :(foo(x)) # no problemfoo(x) # problem# :(foo($T)) # no problemendgen(1)
# Big packagefoo(::M1) =33foo(::Type{M1}) =99# Usergen(M1())The problem code here uses ForwardDiff.jl/src/apiutils.jl Lines 21 to 25 in c6dc209 |
mcabbott
commented
Dec 12, 2022
I think this is done. The above |
KristofferC
commented
Dec 12, 2022
This could be made into an extension which would also solve the loading time. |
mcabbott
commented
Dec 12, 2022
Maybe there would be less reason to create StaticArraysCore now that extensions exist. But unless there's a plan to deprecate the core package, maybe ForwardDiff may as well use it? The next heaviest thing is ChainRulesCore, which isn't directly loaded. Perhaps all the packages for which ForwardDiff defines rules out to extensions would be a good idea. |
fredrikekre
commented
Dec 12, 2022
Hah, just posted JuliaArrays/StaticArraysCore.jl#15. If people can agree on that plan, it might be easier to not port more packages to using |
mcabbott
commented
Dec 12, 2022
Is it certain the extension feature will make 1.9? I see there are 22 packages using StaticArraysCore, but I suppose no problem to have some mixture of mechanisms for a while. |
It's on the backport branch at least. |
Closes#591. Should reduce loading time by a factor of 5 or so. Needs JuliaDiff/DiffResults.jl#22
Needs Julia 1.6.
What thoughts on dropping Julia 1.0 support that in a patch release?The version with #481 is not yet tagged. If that does throw up any surprises, then best to be able to make a patch release correcting them... so we should require Julia 1.6 before tagging that, rather than just after?Master is 0.11-DEV, and requires Julia 1.6.