Skip to content

Commit

Permalink
Collapse Process tracks with More than 20 threads by default to impro…
Browse files Browse the repository at this point in the history
…ve load performance.

PiperOrigin-RevId: 660111530
  • Loading branch information
Profiler Team authored and copybara-github committed Aug 6, 2024
1 parent 8250913 commit 3b153db
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions plugin/trace_viewer/tf_trace_viewer/tf-trace-viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,23 @@
this._addDataResponseSize(data.length);
}
startUpdateModel = performance.now();
this._updateModel(data, replaceModel);
const jsonData = JSON.parse(data);
if (!this._model /* first load */) {
let traceViewerTraceModelSettings = JSON.parse(localStorage.getItem('trace-viewertrace_model_settings')) || {"value": {}};
for(const traceEvent of jsonData['traceEvents']) {
if (traceEvent['name'] !== undefined && traceEvent['name'] == 'process_name') {
// Collapse the process if it has more than 20 threads.
if (traceEvent['thread_count'] !== undefined && traceEvent['thread_count'] > 20) {
// Collapse the process only if preference is not set.
if (traceViewerTraceModelSettings['value']["processes."+traceEvent['args']['name']] === undefined) {
traceViewerTraceModelSettings['value']["processes."+traceEvent['args']['name']] = {'expanded': false};
}
}
}
}
localStorage.setItem('trace-viewertrace_model_settings', JSON.stringify(traceViewerTraceModelSettings));
}
this._updateModel(jsonData, replaceModel);
if (!this._isOss) {
this._addUpdateModelLatency(performance.now() - startUpdateModel);
}
Expand Down Expand Up @@ -1346,7 +1362,6 @@
// the new data is merged with the old data.
// Returns a void promise.
_updateModel: function(data, replaceModel) {
data = JSON.parse(data);
if (!this._model /* first load */ || replaceModel) {
// Only give no events alert for first load or replace load
if (!data['returnedEventsSize']) {
Expand Down

0 comments on commit 3b153db

Please sign in to comment.