Skip to content

Commit

Permalink
Make tensorboard profiler plugin active when there's runs data
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 583236032
  • Loading branch information
zzzaries authored and copybara-github committed Nov 17, 2023
1 parent efba205 commit 8b49288
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions plugin/tensorboard_plugin_profile/profile_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,28 +404,11 @@ def __init__(self, context):
def is_active(self):
"""Whether this plugin is active and has any profile data to show.
Detecting profile data is expensive, so this process runs asynchronously
and the value reported by this method is the cached value and may be stale.
Returns:
Whether any run has profile data.
"""
# If we are already active, we remain active and don't recompute this.
# Otherwise, try to acquire the lock without blocking; if we get it and
# we're still not active, launch a thread to check if we're active and
# release the lock once the computation is finished. Either way, this
# thread returns the current cached value to avoid blocking.
if not self._is_active and self._is_active_lock.acquire(False):
if self._is_active:
self._is_active_lock.release()
else:

def compute_is_active():
self._is_active = any(self.generate_runs())
self._is_active_lock.release()

new_thread = threading.Thread(
target=compute_is_active, name='DynamicProfilePluginIsActiveThread')
new_thread.start()
if not self._is_active:
self._is_active = any(self.generate_runs())
return self._is_active

def get_plugin_apps(self):
Expand Down

0 comments on commit 8b49288

Please sign in to comment.