Commit 7149623d authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[tools] Improve system-analyzer

- Move map stats into a separate panel
- Don't handle selection events twice
- Simplify map-stats panel html

Change-Id: I0cd135727e69c8e42d34af3b75d42861ce06f8e4
Bug: v8:10644
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2485075Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70717}
parent 252d7b4b
...@@ -8,6 +8,7 @@ class State { ...@@ -8,6 +8,7 @@ class State {
_ic; _ic;
_selectedMapLogEntries; _selectedMapLogEntries;
_selectedIcLogEntries; _selectedIcLogEntries;
_selectedDeoptLogEntries;
_selectedSourcePositions; _selectedSourcePositions;
_nofChunks; _nofChunks;
_chunks; _chunks;
......
...@@ -78,7 +78,7 @@ found in the LICENSE file. --> ...@@ -78,7 +78,7 @@ found in the LICENSE file. -->
<script type="module"> <script type="module">
import { App } from './index.mjs'; import { App } from './index.mjs';
globalThis.app = new App("#log-file-reader", "#map-panel", globalThis.app = new App("#log-file-reader", "#map-panel", "#map-stats-panel",
"#timeline-panel", "#ic-panel", "#map-track", "#ic-track", "#deopt-track", "#timeline-panel", "#ic-panel", "#map-track", "#ic-track", "#deopt-track",
"#source-panel"); "#source-panel");
</script> </script>
...@@ -97,6 +97,7 @@ found in the LICENSE file. --> ...@@ -97,6 +97,7 @@ found in the LICENSE file. -->
</timeline-panel> </timeline-panel>
<div class="panels"> <div class="panels">
<map-panel id="map-panel"></map-panel> <map-panel id="map-panel"></map-panel>
<stats-panel id="map-stats-panel"></stats-panel>
<ic-panel id="ic-panel" onchange="app.handleSelectIc(event)"></ic-panel> <ic-panel id="ic-panel" onchange="app.handleSelectIc(event)"></ic-panel>
<source-panel id="source-panel"></source-panel> <source-panel id="source-panel"></source-panel>
</div> </div>
......
...@@ -12,6 +12,7 @@ import { SourcePosition } from "../profile.mjs"; ...@@ -12,6 +12,7 @@ import { SourcePosition } from "../profile.mjs";
import { $ } from "./helper.mjs"; import { $ } from "./helper.mjs";
import "./ic-panel.mjs"; import "./ic-panel.mjs";
import "./timeline-panel.mjs"; import "./timeline-panel.mjs";
import "./stats-panel.mjs";
import "./map-panel.mjs"; import "./map-panel.mjs";
import "./log-file-reader.mjs"; import "./log-file-reader.mjs";
import "./source-panel.mjs"; import "./source-panel.mjs";
...@@ -21,13 +22,14 @@ class App { ...@@ -21,13 +22,14 @@ class App {
_state; _state;
_view; _view;
_navigation; _navigation;
constructor(fileReaderId, mapPanelId, timelinePanelId, constructor(fileReaderId, mapPanelId, mapStatsPanelId, timelinePanelId,
icPanelId, mapTrackId, icTrackId, deoptTrackId, sourcePanelId) { icPanelId, mapTrackId, icTrackId, deoptTrackId, sourcePanelId) {
this._view = { this._view = {
__proto__: null, __proto__: null,
logFileReader: $(fileReaderId), logFileReader: $(fileReaderId),
icPanel: $(icPanelId), icPanel: $(icPanelId),
mapPanel: $(mapPanelId), mapPanel: $(mapPanelId),
mapStatsPanel: $(mapStatsPanelId),
timelinePanel: $(timelinePanelId), timelinePanel: $(timelinePanelId),
mapTrack: $(mapTrackId), mapTrack: $(mapTrackId),
icTrack: $(icTrackId), icTrack: $(icTrackId),
...@@ -65,15 +67,20 @@ class App { ...@@ -65,15 +67,20 @@ class App {
} else { } else {
throw new Error("Unknown selection type!"); throw new Error("Unknown selection type!");
} }
e.stopPropagation();
} }
showMapEntries(entries) { showMapEntries(entries) {
this._state.selectedMapLogEntries = entries; this._state.selectedMapLogEntries = entries;
this._view.mapPanel.selectedMapLogEntries = entries; this._view.mapPanel.selectedMapLogEntries = entries;
this._view.mapStatsPanel.selectedLogEntries = entries;
} }
showIcEntries(entries) { showIcEntries(entries) {
this._state.selectedIcLogEntries = entries; this._state.selectedIcLogEntries = entries;
this._view.icPanel.selectedLogEntries = entries; this._view.icPanel.selectedLogEntries = entries;
} }
showDeoptEntries(entries) {
this._state.selectedDeoptLogEntries = entries;
}
showSourcePositionEntries(entries) { showSourcePositionEntries(entries) {
//TODO: Handle multiple source position selection events //TODO: Handle multiple source position selection events
this._view.sourcePanel.selectedSourcePositions = entries this._view.sourcePanel.selectedSourcePositions = entries
...@@ -81,7 +88,16 @@ class App { ...@@ -81,7 +88,16 @@ class App {
handleTimeRangeSelect(e) { handleTimeRangeSelect(e) {
this.selectTimeRange(e.start, e.end); this.selectTimeRange(e.start, e.end);
e.stopPropagation();
}
selectTimeRange(start, end) {
this._state.selectTimeRange(start, end);
this.showMapEntries(this._state.mapTimeline.selection);
this.showIcEntries(this._state.icTimeline.selection);
this.showDeoptEntries(this._state.deoptTimeline.selection);
} }
handleShowEntryDetail(e) { handleShowEntryDetail(e) {
if (e.entry instanceof MapLogEntry) { if (e.entry instanceof MapLogEntry) {
this.selectMapLogEntry(e.entry); this.selectMapLogEntry(e.entry);
...@@ -92,12 +108,7 @@ class App { ...@@ -92,12 +108,7 @@ class App {
} else { } else {
throw new Error("Unknown selection type!"); throw new Error("Unknown selection type!");
} }
} e.stopPropagation();
selectTimeRange(start, end) {
this._state.selectTimeRange(start, end);
this._view.mapPanel.selectedMapLogEntries =
this._state.mapTimeline.selection;
this._view.icPanel.selectedLogEntries = this._state.icTimeline.selection;
} }
selectMapLogEntry(entry) { selectMapLogEntry(entry) {
this._state.map = entry; this._state.map = entry;
...@@ -136,9 +147,10 @@ class App { ...@@ -136,9 +147,10 @@ class App {
this._state.icTimeline = icTimeline; this._state.icTimeline = icTimeline;
this._state.deoptTimeline = deoptTimeline; this._state.deoptTimeline = deoptTimeline;
// Transitions must be set before timeline for stats panel. // Transitions must be set before timeline for stats panel.
this._view.mapPanel.transitions = this._state.mapTimeline.transitions;
this._view.mapTrack.data = mapTimeline;
this._view.mapPanel.timeline = mapTimeline; this._view.mapPanel.timeline = mapTimeline;
this._view.mapTrack.data = mapTimeline;
this._view.mapStatsPanel.transitions = this._state.mapTimeline.transitions;
this._view.mapStatsPanel.timeline = mapTimeline;
this._view.icPanel.timeline = icTimeline; this._view.icPanel.timeline = icTimeline;
this._view.icTrack.data = icTimeline; this._view.icTrack.data = icTimeline;
this._view.deoptTrack.data = deoptTimeline; this._view.deoptTrack.data = deoptTimeline;
......
...@@ -10,7 +10,6 @@ found in the LICENSE file. --> ...@@ -10,7 +10,6 @@ found in the LICENSE file. -->
width: 200px; width: 200px;
} }
</style> </style>
<stats-panel id="stats-panel"></stats-panel>
<div class="panel"> <div class="panel">
<h2>Map Panel</h2> <h2>Map Panel</h2>
<map-transitions id="map-transitions"></map-transitions> <map-transitions id="map-transitions"></map-transitions>
......
...@@ -25,10 +25,6 @@ defineCustomElement('map-panel', (templateText) => ...@@ -25,10 +25,6 @@ defineCustomElement('map-panel', (templateText) =>
} }
} }
get statsPanel() {
return this.$('#stats-panel');
}
get mapTransitionsPanel() { get mapTransitionsPanel() {
return this.$('#map-transitions'); return this.$('#map-transitions');
} }
...@@ -49,17 +45,8 @@ defineCustomElement('map-panel', (templateText) => ...@@ -49,17 +45,8 @@ defineCustomElement('map-panel', (templateText) =>
return this.mapDetailsPanel.mapDetails; return this.mapDetailsPanel.mapDetails;
} }
// send a timeline to the stats-panel set timeline(timeline) {
set timeline(value) { this._timeline = timeline;
console.assert(value !== undefined, "timeline undefined!");
this.statsPanel.timeline = value;
this.statsPanel.update();
}
get transitions() {
return this.statsPanel.transitions;
}
set transitions(value) {
this.statsPanel.transitions = value;
} }
set map(value) { set map(value) {
......
...@@ -49,8 +49,7 @@ found in the LICENSE file. --> ...@@ -49,8 +49,7 @@ found in the LICENSE file. -->
} }
</style> </style>
<div class="panel"> <div class="panel">
<h2>Stats Panel</h2> <h2>Map Stats</h2>
<h3>Stats</h3>
<section id="stats"> <section id="stats">
</section> </section>
</div> </div>
...@@ -10,6 +10,7 @@ defineCustomElement( ...@@ -10,6 +10,7 @@ defineCustomElement(
class StatsPanel extends V8CustomElement { class StatsPanel extends V8CustomElement {
_timeline; _timeline;
_transitions; _transitions;
_selectedLogEntries;
constructor() { constructor() {
super(templateText); super(templateText);
} }
...@@ -18,15 +19,20 @@ defineCustomElement( ...@@ -18,15 +19,20 @@ defineCustomElement(
return this.$("#stats"); return this.$("#stats");
} }
set timeline(value) { set timeline(timeline) {
//TODO(zcankara) Trigger update this._timeline = timeline;
this._timeline = value; this.selectedLogEntries = timeline.all
} }
get timeline() { get timeline() {
return this._timeline; return this._timeline;
} }
set selectedLogEntries(entries) {
this._selectedLogEntries = entries;
this.update();
}
set transitions(value) { set transitions(value) {
this._transitions = value; this._transitions = value;
} }
...@@ -37,7 +43,7 @@ defineCustomElement( ...@@ -37,7 +43,7 @@ defineCustomElement(
filterUniqueTransitions(filter) { filterUniqueTransitions(filter) {
// Returns a list of Maps whose parent is not in the list. // Returns a list of Maps whose parent is not in the list.
return this.timeline.filter((map) => { return this._selectedLogEntries.filter((map) => {
if (filter(map) === false) return false; if (filter(map) === false) return false;
let parent = map.parent(); let parent = map.parent();
if (parent === undefined) return true; if (parent === undefined) return true;
...@@ -84,7 +90,7 @@ defineCustomElement( ...@@ -84,7 +90,7 @@ defineCustomElement(
"<thead><tr><td>Color</td><td>Type</td><td>Count</td>" + "<thead><tr><td>Color</td><td>Type</td><td>Count</td>" +
"<td>Percent</td></tr></thead>"; "<td>Percent</td></tr></thead>";
let name, filter; let name, filter;
let total = this.timeline.size(); let total = this._selectedLogEntries.length;
pairs.forEach(([name, color, filter]) => { pairs.forEach(([name, color, filter]) => {
let row = this.tr(); let row = this.tr();
if (color !== null) { if (color !== null) {
...@@ -102,7 +108,7 @@ defineCustomElement( ...@@ -102,7 +108,7 @@ defineCustomElement(
this.dispatchEvent(new SelectionEvent(node.maps)); this.dispatchEvent(new SelectionEvent(node.maps));
}; };
row.appendChild(this.td(name)); row.appendChild(this.td(name));
let count = this.timeline.count(filter); let count = this.count(filter);
row.appendChild(this.td(count)); row.appendChild(this.td(count));
let percent = Math.round((count / total) * 1000) / 10; let percent = Math.round((count / total) * 1000) / 10;
row.appendChild(this.td(percent.toFixed(1) + "%")); row.appendChild(this.td(percent.toFixed(1) + "%"));
...@@ -111,11 +117,19 @@ defineCustomElement( ...@@ -111,11 +117,19 @@ defineCustomElement(
this.stats.appendChild(tableNode); this.stats.appendChild(tableNode);
} }
count(filter) {
let count = 0;
for (const map of this._selectedLogEntries) {
if (filter(map)) count++;
}
return count;
}
updateNamedTransitionsStats() { updateNamedTransitionsStats() {
let tableNode = this.table("transitionTable"); let tableNode = this.table("transitionTable");
let nameMapPairs = Array.from(this.transitions.entries()); let nameMapPairs = Array.from(this.transitions.entries());
tableNode.innerHTML = tableNode.innerHTML =
"<thead><tr><td>Propery Name</td><td>#</td></tr></thead>"; "<thead><tr><td>Count</td><td>Propery Name</td></tr></thead>";
nameMapPairs nameMapPairs
.sort((a, b) => b[1].length - a[1].length) .sort((a, b) => b[1].length - a[1].length)
.forEach(([name, maps]) => { .forEach(([name, maps]) => {
...@@ -129,8 +143,8 @@ defineCustomElement( ...@@ -129,8 +143,8 @@ defineCustomElement(
) )
) )
); );
row.appendChild(this.td(name));
row.appendChild(this.td(maps.length)); row.appendChild(this.td(maps.length));
row.appendChild(this.td(name));
tableNode.appendChild(row); tableNode.appendChild(row);
}); });
this.stats.appendChild(tableNode); this.stats.appendChild(tableNode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment