Skip to content

Commit 05a6cf6

Browse files
nfeltjart
authored andcommitted
Log time taken by is_active() calls for plugin listing (#662)
This is a preliminary step in addressing #625 that just adds logging (at INFO) for the amount of time taken by the is_active() call for each plugin loaded by TensorBoard when the plugins listing endpoint is invoked. This way as we make fixes we can monitor for regressions, and it also can help isolate the problematic plugin if we get reports from users that TensorBoard is taking a long time to respond with the list of active plugins (which is a prerequisite for basically any other usage of TensorBoard). I also bundled in a couple small tweaks to other logging lines that can help diagnose slow plugin behavior.
1 parent b46b7db commit 05a6cf6

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

tensorboard/backend/application.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,15 @@ def _serve_plugins_listing(self, request):
227227
Returns:
228228
A werkzeug.Response object.
229229
"""
230-
return http_util.Respond(
231-
request,
232-
{plugin.plugin_name: plugin.is_active() for plugin in self._plugins},
233-
'application/json')
230+
response = {}
231+
for plugin in self._plugins:
232+
start = time.time()
233+
response[plugin.plugin_name] = plugin.is_active()
234+
elapsed = time.time() - start
235+
tf.logging.info(
236+
'Plugin listing: is_active() for %s took %0.3f seconds',
237+
plugin.plugin_name, elapsed)
238+
return http_util.Respond(request, response, 'application/json')
234239

235240
def __call__(self, environ, start_response): # pylint: disable=invalid-name
236241
"""Central entry point for the TensorBoard application.

tensorboard/backend/event_processing/event_file_loader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def Load(self):
4646
Yields:
4747
All values that were written to disk that have not been yielded yet.
4848
"""
49+
tf.logging.debug('Loading events from %s', self._file_path)
4950
while True:
5051
try:
5152
with tf.errors.raise_exception_on_not_ok_status() as status:

tensorboard/backend/event_processing/plugin_event_multiplexer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def AddRunsFromDirectory(self, path, name=None):
173173
"""
174174
tf.logging.info('Starting AddRunsFromDirectory: %s', path)
175175
for subdir in GetLogdirSubdirectories(path):
176-
tf.logging.info('Adding events from directory %s', subdir)
176+
tf.logging.info('Adding run from directory %s', subdir)
177177
rpath = os.path.relpath(subdir, path)
178178
subname = os.path.join(name, rpath) if name else rpath
179179
self.AddRun(subdir, name=subname)

0 commit comments

Comments
 (0)