From 9bfc84f18fdd775fcf4698b7e3e573bd14aed235 Mon Sep 17 00:00:00 2001 From: Leszek Swirski Date: Wed, 14 Dec 2022 10:14:44 +0100 Subject: [PATCH] [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 Reviewed-by: Camillo Bruni Commit-Queue: Camillo Bruni Cr-Commit-Position: refs/heads/main@{#84829} --- tools/profview/profile-utils.js | 12 +++++------- tools/profview/profview.js | 8 ++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tools/profview/profile-utils.js b/tools/profview/profile-utils.js index e1410550a7..69fed93c74 100644 --- a/tools/profview/profile-utils.js +++ b/tools/profview/profile-utils.js @@ -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]++; diff --git a/tools/profview/profview.js b/tools/profview/profview.js index 4dd3fbf9d0..e98b0e5e65 100644 --- a/tools/profview/profview.js +++ b/tools/profview/profview.js @@ -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");