-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
A little experiment towards better clean up + more typed observables #2372
Conversation
But is it good that you can't change |
You can't do that right now 🤷 |
Compile Times benchmarkNote, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running: using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(display(fig))
|
To give some context: Makie.jl/GLMakie/assets/shader/sprites.vert Lines 26 to 28 in e0cb400
lines like these get replaced before shader compilation with something like |
Yeah, and WGLMakie & GLMakie at least both have a version of: function lift_convert_inner(value, key, plot_key, plot)
return lift(value) do value
return convert_attribute(value, key, plot_key)
end
end which is pretty much identical to: obs = Observable(convert_attribute(value, key, plot_key)) # creates strongly typed obs
map!(x-> convert_attribute(x, ...), obs) |
Closing this experiment for now |
I rediscovered while looking at the GLMakie backend code, that we actually are already pretty strict about atomic plot attributes, in the sense that the output type of
convert_attributes
is not allowed to change. So, e.g. if we set color to a single color, we may never change it to an array of colors, alowing to restrict color toObservable{RGBAf}
.So, at least for atomic plots, we should be able to always create strictly typed observables of the type
typeof(conver_arguments(...))
.In this PR, I'm rewriting
Attributes
to lazily convert viaconvert_attributes
to always return a typed observable...Still needs to be optional though since
Attributes
are used for so many things, but with a bit larger refactor, we may be able to flip the switch on that.Still an experiment, but may greatly help with not doing conversions multiple times, have better typed Observables and have better ways to completely clean up the observable connections of a plot.
If this works out well, we may want to make our own Attribute type for atomic plots (which then can also finally lock in the set of allowed attributes), and use a simpler type for the rest of the
Attribute
uses.