Skip to content
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

Merged
merged 1 commit into from
Feb 12, 2016

Conversation

philippjfr
Copy link
Member

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.

@@ -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])
Copy link
Contributor

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!

@jlstevens
Copy link
Contributor

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 id0 followed by a million of id1).

As the general optimization is more tricky and this will improve most common cases, I think this very worthwhile.

@jlstevens
Copy link
Contributor

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.

@philippjfr
Copy link
Member Author

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 id0 followed by a million of id1).

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.

@philippjfr
Copy link
Member Author

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.

@jlstevens
Copy link
Contributor

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.

jlstevens added a commit that referenced this pull request Feb 12, 2016
Bokeh Elements only send data once if completely static
@jlstevens jlstevens merged commit 769a1da into master Feb 12, 2016
@jlstevens jlstevens deleted the bokeh_static branch February 13, 2016 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants