Skip to content

Commit

Permalink
Make scalars is_active short circuit if apt (#621)
Browse files Browse the repository at this point in the history
This change makes the `is_active` method of the scalars plugin
short-circuit if it discovers that any run has at least 1 relevant tag.

This change preserves existing behavior, so there are no changes to
tests (which check for the preservation of behavior).

Test plan: Start TensorBoard pointed at the scalars demo data. Note that
the scalars plugin loads. Start TensorBoard pointed at the PR curves
demo data. The scalars plugin is inactive.

Use `time.time()` to log the time it takes for some internal events file
(with over 30K tags in one specific run) with and without this change.

With this change, the scalars dashboard takes 0.0s to load. Without this
change, it takes 12.0s. Sometimes, the frontend won't load because
`is_active` takes too long to respond.

Granted, one might reason that a user should not have 30K tags ... but
even so, that should not block the rest of TensorBoard from loading.
  • Loading branch information
chihuahua authored Oct 5, 2017
1 parent bc1e71f commit ce70c15
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tensorboard/plugins/scalar/scalars_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def get_plugin_apps(self):

def is_active(self):
"""The scalars plugin is active iff any run has at least one scalar tag."""
return bool(self._multiplexer) and any(self.index_impl().values())
if not self._multiplexer:
return False

return bool(self._multiplexer.PluginRunToTagToContent(metadata.PLUGIN_NAME))

def index_impl(self):
"""Return {runName: {tagName: {displayName: ..., description: ...}}}."""
Expand Down

0 comments on commit ce70c15

Please sign in to comment.