[tools] Use code attribution in timeline view

Reflect the code attribution (in particular, "attribute non-functions to
JS functions") in the timeline view, which visualises the distribution
of each code kind. This allows easier visualisation of which tiers are
active, ignoring stubs that are shared between tiers (like ICs).

Change-Id: I1f2818ffd4e466ce18c01627865186e6a94e2bed
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4105021
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84829}
This commit is contained in:
Leszek Swirski 2022-12-14 10:14:44 +01:00 committed by V8 LUCI CQ
parent 9be597d194
commit 9bfc84f18f
2 changed files with 9 additions and 11 deletions

View File

@ -150,11 +150,7 @@ function findNextFrame(file, stack, stackPos, step, filter) {
codeId = stack[stackPos];
code = codeId >= 0 ? file.code[codeId] : undefined;
if (filter) {
let type = code ? code.type : undefined;
let kind = code ? code.kind : undefined;
if (filter(type, kind)) return stackPos;
}
if (!filter || filter(code?.type, code?.kind)) return stackPos;
stackPos += step;
}
return -1;
@ -399,8 +395,9 @@ class FunctionListTree {
class CategorySampler {
constructor(file, bucketCount) {
constructor(file, bucketCount, filter) {
this.bucketCount = bucketCount;
this.filter = filter;
this.firstTime = file.ticks[0].tm;
let lastTime = file.ticks[file.ticks.length - 1].tm;
@ -426,7 +423,8 @@ class CategorySampler {
let bucket = this.buckets[i];
bucket.total++;
let codeId = (stack.length > 0) ? stack[0] : -1;
let stackPos = findNextFrame(file, stack, 0, 2, this.filter);
let codeId = stackPos >= 0 ? stack[stackPos] : -1;
let code = codeId >= 0 ? file.code[codeId] : undefined;
let kind = resolveCodeKindAndVmState(code, vmState);
bucket[kind]++;

View File

@ -908,6 +908,7 @@ class TimelineView {
height === oldState.timelineSize.height &&
newState.file === oldState.file &&
newState.currentCodeId === oldState.currentCodeId &&
newState.callTree.attribution === oldState.callTree.attribution &&
newState.start === oldState.start &&
newState.end === oldState.end) {
// No change, nothing to do.
@ -945,11 +946,10 @@ class TimelineView {
this.selectionStart = (start - firstTime) / (lastTime - firstTime) * width;
this.selectionEnd = (end - firstTime) / (lastTime - firstTime) * width;
let stackProcessor = new CategorySampler(file, bucketCount);
let filter = filterFromFilterId(this.currentState.callTree.attribution);
let stackProcessor = new CategorySampler(file, bucketCount, filter);
generateTree(file, 0, Infinity, stackProcessor);
let codeIdProcessor = new FunctionTimelineProcessor(
currentCodeId,
filterFromFilterId(this.currentState.callTree.attribution));
let codeIdProcessor = new FunctionTimelineProcessor(currentCodeId, filter);
generateTree(file, 0, Infinity, codeIdProcessor);
let buffer = document.createElement("canvas");