-
Notifications
You must be signed in to change notification settings - Fork 8
type stability and time to first widget improvements #48
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
src/backend.jl
Outdated
| struct DummyBackend <: AbstractBackend; end | ||
|
|
||
| const backends = AbstractBackend[DummyBackend()] | ||
| const backends = Type[DummyBackend] |
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.
That's interesting, I had no idea that somehow it was better to use types rather than instances for this. OTOH, this means the change is breaking (as I imagine the old Interact / InteractBase will try to set an instance as backend rather than a type).
I imagine we should bump to version 0.7 to reflect the breakage.
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.
Yeah, types dont specialise methods they pass through unless Type{T} is used. And the vector is stable. But actually this change is probably not needed now. Previously the theme was checked in every method, meaning constant unstable method dispatch. But I changed the code to just get it once and pass it through, which will mean there is only the first unstable function call. I will see how it goes changing it back.
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.
Ok I reverted this change. It does still seem like a little more compilation, but with basically no calls to gettheme and all the other changes here, in AssetRegistry.jl and WebIO.jl I'm still getting 3 seconds to a slider.
|
@piever can you approve the test run? This is ready to go. |
|
Thanks for finalizing this (latency improvement is pretty impressive!) and sorry about the annoyance that you can't run tests just by pushing, not sure if there's an easy way to allow you to do that... It seems like this has some issues with If that's not possible, I imagine a possible release strategy could be:
|
|
Yeah I noticed that too after pushing this. I'll look for a way to do this where InteractBase.jl works as is. |
b404d52 to
43d1c27
Compare
|
Ok this should be fine with InteractBase.jl. I found some simpler ways to get some of the type stability benefits without any breaking changes. It's more like 4 seconds load time, not such a huge improvement here, mostly in the AssetRegistry PR. But type stability fixes to WebIO will help a bit more, and a few in InteractBase.jl |
43d1c27 to
85d713f
Compare
|
This seems like a less invasive approach, I've left a few minor comments which should be straightforward to address. There's one thing I'd like to understand better though. When you say
how exactly does that word? Is it just fixed in InteractBase by preferring |
|
Yes, passing |
|
Ok this should be good to merge |
This PR aims to improve the load time of widgets.
TTF
Interact.slider(1:10)is currently 15 seconds on my machine, after this PR -and the AssetRegistry PR- it is down to53.Hopefully it can be 1 second or less.
There are some problems with the design of AssetRegistry.jl and Wigets.jl that exacerbate the current load time.
First, using JSON3 instead of JSON in AssetRegistryjl is a huge improvement for all widgets -
slider(1:10)in about 7 seconds.JuliaGizmos/AssetRegistry.jl#15
Second, because backends/themes are passed to all methods in InteractBase, but they are stored in a type unstableThis change is remeoved so as not to be so breaking, and removing most of the unstableVector, type instability propagates everywhere. Using the type ofAbstractBackendandWidgetThemeinstead of the constructed backend/theme means most methods wont specialise unless we specifically need them to, and the vector isVector{Type}. This combined with fixing the type stability of various uses ofDictbringssliderin InteractBase.jl down to 5 seconds, and closer to full type stability.getthemecalls in InteractBase comes close anyway.The last (I think) major problem is that the eltype of observables is known from the passed in range (e.g.Int64above) but it's lost, and has to be detected again in an unstable way in theWidgetconstructor. We should as much as possible propagate those types throughout. Is there a reason it is detected again fromoutput_obs?This will be a breaking change, and needs companion PRs in at least InteractBase.jl and Interact.jl. I'm writing all of these simultaneously, as making the whole ecosytem faster is the goal.Edit: moving to always passing the eltype parameterStoWidget{T,S}brings the TTFS down to 3 seconds !! This also seems to be backwards compatible, just using one type parameter or passingnothingas the second type parameter triggers the original behaviour.This was actually solvable with a few tweaks to the constructor methods to keep type stability, and is no longer breaking.
Much of the remaining performance improvments seem to be in WebIO.jl