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

Optimization for bokeh comms messages in dynamic mode #822

Merged
merged 4 commits into from Aug 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions holoviews/plotting/bokeh/element.py
Expand Up @@ -575,10 +575,20 @@ def current_handles(self):
handles = []
if self.static and not self.dynamic:
return handles

previous_id = self.handles.get('previous_id', None)
current_id = id(self.current_frame)
for handle in self._update_handles:
if (handle == 'source' and self.dynamic and
current_id == previous_id):
continue
if handle in self.handles:
handles.append(self.handles[handle])

# Cache frame object id to skip updating if unchanged
if self.dynamic:
self.handles['previous_id'] = current_id

if self.overlaid:
return handles

Expand Down
7 changes: 4 additions & 3 deletions holoviews/plotting/bokeh/util.py
Expand Up @@ -45,7 +45,7 @@
'FixedTicker', 'FuncTickFormatter', 'LogTickFormatter']

# List of attributes that can safely be dropped from the references
IGNORED_ATTRIBUTES = ['data', 'palette']
IGNORED_ATTRIBUTES = ['data', 'palette', 'image', 'x', 'y']

# Model priority order to ensure some types are updated before others
MODEL_PRIORITY = ['Range1d', 'Title', 'Image', 'LinearColorMapper',
Expand Down Expand Up @@ -189,7 +189,7 @@ def get_ids(obj):
ids = [get_ids(o) for o in obj]
elif isinstance(obj, dict):
ids = [(v,) if k == 'id' else get_ids(v)
for k, v in obj.items()]
for k, v in obj.items() if not k in IGNORED_ATTRIBUTES]
return list(itertools.chain(*ids))


Expand Down Expand Up @@ -239,7 +239,8 @@ def compute_static_patch(document, models):
update_types[obj['type']].append(key)
events = [delete_refs(e, IGNORED_MODELS)
for _, e in sorted(events, key=lambda x: x[0])]
events = [e for e in events if all(i in requested_updates for i in get_ids(e))]
events = [e for e in events if all(i in requested_updates for i in get_ids(e))
if 'new' in e]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like anything with the substring 'new' will be included. Even if it is safe, it would be good to at least have a comment justifying this condition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. The events are dictionaries and only events which actually include a new value need to be sent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And 'new' is in there as a string? Ok!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'new' is the key containing the updated value. Not sure why there are events without a 'new' value in the first place since they have no effect anyway.

value_refs = {ref_id: delete_refs(val, IGNORED_MODELS, IGNORED_ATTRIBUTES)
for ref_id, val in value_refs.items()}
references = [val for val in value_refs.values()
Expand Down