Skip to content

Commit 324bdf3

Browse files
qiuminxunfelt
authored andcommitted
A few bug fixes and improvements of TPU profile plugin (#1245)
1) Fix a bug that streaming trace viewer loads wrong host names 2) Fix a bug that streaming trace viewer doesn't fetch dynamic traces 3) Add throbler to streaming trace viewer when waiting for data to load 4) Show overview page always as the first tool 5) Improve color code of overview page: green => good, orange => moderate red => bad
1 parent 4cbaf6d commit 324bdf3

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

tensorboard/components/tf_trace_viewer/tf-trace-viewer.html

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,11 @@
123123
this._displayOverlay("Trace data URL is not provided.", "Trace Viewer");
124124
return null;
125125
}
126-
this._throbber.className = "active";
127-
128126
this._loadTrace();
129127
},
130128

131-
_loadTrace : function() {
129+
_loadTrace : function(requestedRange, replaceModel) {
130+
this._throbber.className = "active";
132131
if (!this._isStreaming) {
133132
// Send HTTP request to get the trace data.
134133
var req = new XMLHttpRequest();
@@ -149,7 +148,7 @@
149148
};
150149
req.send(null);
151150
} else {
152-
this._loadStreamingTrace();
151+
this._loadStreamingTrace(requestedRange, replaceModel);
153152
}
154153
},
155154

@@ -174,13 +173,6 @@
174173
tf_component_traceviewer.length(fetch);
175174
if (!tf_component_traceviewer.within(preserve, this._loadedRange) ||
176175
zoomFactor > tf_component_traceviewer.ZOOM_RATIO) {
177-
console.log("loading more data: ", {
178-
zoomFactor: zoomFactor,
179-
loadedRange: this._loadedRange,
180-
viewport: viewport,
181-
preserve: preserve,
182-
fetch: fetch,
183-
});
184176
this._loadTrace(fetch, /*replaceModel=*/false);
185177
}
186178
},

tensorboard/plugins/profile/overview_page/overview-page.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
.steptime-average {
4545
font-weight: bold;
4646
font-style: italic;
47-
color: red;
47+
color: var(--summary-color, green);
4848
}
4949
.table-style {
5050
table-layout: auto;
@@ -71,7 +71,7 @@
7171
text-transform: capitalize;
7272
}
7373
div.bottleneck-statement {
74-
color: red;
74+
color: var(--summary-color, green);
7575
font-weight: bolder;
7676
font-style: italic;
7777
}
@@ -219,6 +219,7 @@
219219
var runEnvironmentJson = this._data[2];
220220
var recommendationJson = this._data[3];
221221

222+
var statement = recommendationJson.p['statement'];
222223
this.set('_host_idle_time_percent', generalAnalysisJson.p['host_idle_time_percent']);
223224
this.set('_device_idle_time_percent', generalAnalysisJson.p['device_idle_time_percent']);
224225
this.set('_mxu_utilization_percent', generalAnalysisJson.p['mxu_utilization_percent']);
@@ -234,6 +235,13 @@
234235
this.set('_build_target', runEnvironmentJson.p['build_target']);
235236
this.set('_statement', recommendationJson.p['statement']);
236237
this.set('_show_error_message', this._error_message!='');
238+
239+
if (statement.includes('HIGHLY')) {
240+
this.customStyle['--summary-color'] = 'red';
241+
} else if (statement.includes('MODERATE')) {
242+
this.customStype['--summary-color'] = 'orange';
243+
}
244+
237245
this.updateStyles();
238246

239247
this._showDeviceStepChart(inputAnalysisJson);

tensorboard/plugins/profile/profile_plugin.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,18 @@ def index_impl(self):
180180
removed_tool = 'trace_viewer@' if self.stub is None else 'trace_viewer'
181181
if removed_tool in run_to_tools[run]:
182182
run_to_tools[run].remove(removed_tool)
183+
run_to_tools[run].sort()
184+
op = 'overview_page'
185+
if op in run_to_tools[run]:
186+
# keep overview page at the top of the list
187+
run_to_tools[run].remove(op)
188+
run_to_tools[run].insert(0, op)
183189
return run_to_tools
184190

185191
@wrappers.Request.application
186192
def tools_route(self, request):
187193
run_to_tools = self.index_impl()
194+
188195
return http_util.Respond(request, run_to_tools, 'application/json')
189196

190197
def host_impl(self, run, tool):
@@ -260,7 +267,8 @@ def data_impl(self, request):
260267
grpc_request.repository_root = self.plugin_logdir
261268
grpc_request.session_id = run[:-1]
262269
grpc_request.tool_name = 'trace_viewer'
263-
grpc_request.host_name = host
270+
# Remove the trailing dot if present
271+
grpc_request.host_name = host.rstrip('.')
264272

265273
grpc_request.parameters['resolution'] = request.args.get('resolution')
266274
if request.args.get('start_time_ms') is not None:

0 commit comments

Comments
 (0)