-
-
Notifications
You must be signed in to change notification settings - Fork 18
Improve loading time #64
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
Conversation
The goal here is to eliminate all invalidations without losing much (hopefully any) functionality. Tests do NOT pass yet.
This takes use from using output on master... 0.045090 seconds (89.05 k allocations: 5.159 MiB, 10.24% compilation time) ...to... 0.021664 seconds (39.52 k allocations: 2.371 MiB, 21.63% compilation time)
Codecov Report
@@ Coverage Diff @@
## master #64 +/- ##
==========================================
+ Coverage 98.82% 99.28% +0.46%
==========================================
Files 8 1 -7
Lines 425 420 -5
==========================================
- Hits 420 417 -3
+ Misses 5 3 -2
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
|
This does seem like a pretty good solution. |
|
Can we put downstream tests on here? |
|
I'll see if I can preemptively reduce some of these errors in ArrayInterface |
* Reduce dispatch on `Integer` Motivated by SciML/Static.jl#64, this shouldn't change how any code currently works. Just less resrtrictive dispatch patterns on `Integer`.
|
Mind bumping the minor version, to indicate this is a breaking release? |
|
There are some things I still don't have a solution to here. For example, passing StaticInt to CartesianIndex requires a new method but that creates over 100 invalidations. |
|
Which function is invalidated? |
|
I came across the issue with this line. It's because |
|
@cscherrer it might be good to get at least a preliminary look at this to make sure it gels with what you're doing |
|
Thanks @Tokazama. Getting rid of the invalidations is great! I guess this will now have some of the same challenges as Symbolics, for example julia> @variables i::Int
1-element Vector{Num}:
i
julia> i isa Integer
falseThe biggest concern here is that people get very used to writing methods like I'd normally be worried about this, but having the precedent in place makes it much less of a concern. |
Right now I know that |
Hmm. It is important that this Unfortunately, the test only makes sure that the code runs, and not that the passing of static information actually succeeded. |
Do you mean the value returned from iterating |
Yes, but IIRC CartesianIndices are more flexible than CartesianIndex. |
|
|
|
Revert non-breaking version release seeing the results. |
|
It seems to me julia> Irrational{:π} <: Real
trueI don't know of any problems this leads to (are there any?). Could this design could be adapted for |
I'm not sure I understand. Are you suggesting that we assign a symbol as the static value and then use dispatch to derive the float value, like... struct StaticFloat{sym} <: AbstractFloat end
Base.float(::StaticFloat{:float_one}) = 1.0
|
No, I think the type parameter should be set up to map easily to the "dynamic" value, so in this case just a I could be missing something, but to me this seems like evidence the problem can be solved without sacrificing the type hierarchy. |
The subtyping is what causes invalidations, not where we store the values. |
I see, so it's not type instability but invalidation, and irrational avoid this problem because they're in Base. Then the design is irrelevant to the problem, and the "just put it in Base" solution is (sadly) not getting much traction. I think I see now, thank you. |
Exactly. If you trace back what the original source is for most of these invalidations it poorly inferred methods produced when running Pkg.jl. So I figured that the safest way to avoid invalidations was to use a subtype as far away from anything the package manager would use but still has more functionality than no type hierarchy. So I chose |
chriselrod
left a comment
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.
Many packages probably still need updating, but the minor version bump means that's okay and it hopefully won't be too much work to see them update.
This supersedes #62 with a better approach to decreasing invalidations. Instead of removing methods for converting
StaticInttoIntthis subtypesNumber. This lets us keep a lot of the basic math methods at the loss of some generic index like behavior, (which we were losing anyway when removing natural conversion toInt).This gets rid of ALL invalidations on v1.7 and leaves the following on v1.8 and v1.9SnoopCompile output
I've already made a PR where I tracked down the source of these in to poor inference when filtering when running Pkg. (JuliaLang/julia#45452)EDIT: PR accepted
Here are the load times:
These are updated after a70c8e3.
I'm not working on a computer that's great for benchmarking and the time in seconds isn't very accurate, so it's probably more useful to compare allocations between this PR and master