-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
Bokeh Elements only send data once if completely static #502
Conversation
@@ -149,6 +150,8 @@ def __init__(self, element, plot=None, show_labels=['x', 'y'], **params): | |||
self.current_ranges = None | |||
super(ElementPlot, self).__init__(element, **params) | |||
self.handles = {} if plot is None else self.handles['plot'] | |||
element_ids = self.hmap.traverse(lambda x: id(x), [Element]) |
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.
Traversing a holomap should be quick but won't be O(1). Still going to be a lost faster than what we had before though!
I think I understand what is going on and this optimization makes sense. That said, I do think this is a special case of a more general optimization where you detect blocks of constant ids (e.g you could have one of As the general optimization is more tricky and this will improve most common cases, I think this very worthwhile. |
I should also add that this optimization makes an assumption we use throughout HoloViews: elements are treated as immutable. If you modify an element with a given id, this optimization would be invalid. This is worth mentioning as immutability is our default assumption but nothing stops people from mutating data in an element and I certainly can think of cases where this would be more efficient performance-wise. |
Agreed, that's definitely an optimization worth considering, now that bokeh server has settled down a little bit we can consider hooking into their events API and designing a storage format which will allow us to dynamically update plot components on the front end. The simplest approach would probably to send a dictionary of references along with the minimized data. On each frame the widget looks up the appropriate references in the data store and updates the plot with the data. |
Ready to merge. Can open another issue to discuss how we can remove redundant data in static bokeh plots if you think it's worth it. |
I've just realized that mutation isn't an issue: once it is in the plotting code, the user won't be able to do such things. As the tests are passing, I'll merge now. |
Bokeh Elements only send data once if completely static
Often times when exploring some dataset using the widgets some Elements are completely static, while others change when dragging the slider such as in the homepage example where there is a large image that is completely static. Currently that data gets sent multiple times, this PR detects if a frame is completely static and ensures that the data is only sent when first initializing the plot. This speeds up and reduces the memory footprint of the homepage example by a factor of ~40.