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

Various fixes for bokeh static_source optimization #1413

Merged
merged 5 commits into from
May 28, 2017

Conversation

philippjfr
Copy link
Member

In #1396 it was suggested that the static_source optimization in bokeh should only kick in if both the element and its data are static.

@jlstevens
Copy link
Contributor

Looks good.

I can't really see how to test this right now so I'll merge once the tests pass.

@philippjfr
Copy link
Member Author

So this approach does not work since it just disables the optimization entirely. The issue is twofold a) when a custom style is applied the element id changes, b) something in the plotting pipeline applies a dynamic method to the data, which again ends up changing the element id. Therefore the plotting code never sees the same element id twice and the optimization does nothing. Will have to think about this.

@jlstevens
Copy link
Contributor

Problem b) seems like the real issue to me as I don't think disabling the optimization for a) means it will always be disabled.

@philippjfr philippjfr force-pushed the static_source_opt_fix branch from 28350a3 to bdc69a7 Compare May 28, 2017 11:53
@@ -488,6 +489,7 @@ def __init__(self, data, id=None, **params):
"""
self.data = data
self.id = id
self._plot_id = plot_id or obj_id(self)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just use __builtins__.id to avoid the name shadowing issue.

@@ -488,6 +489,7 @@ def __init__(self, data, id=None, **params):
"""
self.data = data
self.id = id
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ever actually set the id via the constructor?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, probably for clone. Nevermind my question!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, clone does all the time.

else:
current_id = id(element.data)
current_id = element._plot_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it no longer taking into account the id of the data? It seems to do that in tabular...

@@ -147,7 +147,7 @@ def sync_sources(self):
from the same object.
"""
get_sources = lambda x: (id(x.current_frame.data), x)
filter_fn = lambda x: (x.shared_datasource and x.current_frame and
filter_fn = lambda x: (x.shared_datasource and x.current_frame is not None and
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to confirm: is this a a fix unrelated to the optimization itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems so, not sure why I pushed it here, but it is an important fix.

previous_id = self.handles.get('previous_id', None)
current_id = id(self.current_frame.data) if self.current_frame else None
current_id = None if self.current_frame is None else id(element)+id(element.data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Summing ids is not a safe test for uniqueness as many pairs of ids could sum to the same value (even if it is unlikely!). Note that collisions might not even be that rare as the id doesn't return a hash - it is more like to a memory address.

To check the identity of both the element and the data I would use the tuple (id(element), id(element.data)) and not the sum.

@jlstevens
Copy link
Contributor

Looks good with the latest fixes. One last import issue to fix and then I'll merge once the tests go green. That said, are there any meaningful unit tests we should set up to test the optimization?

@philippjfr philippjfr force-pushed the static_source_opt_fix branch from a80c3cb to 43b3c38 Compare May 28, 2017 18:52
@philippjfr philippjfr force-pushed the static_source_opt_fix branch from 43b3c38 to a203695 Compare May 28, 2017 19:22
@jlstevens
Copy link
Contributor

Thanks for adding the unit tests! Merging.

@jlstevens jlstevens merged commit bd7b264 into master May 28, 2017
@philippjfr philippjfr deleted the static_source_opt_fix branch June 17, 2017 17:04
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants