Skip to content

Commit a9f3a4c

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
RPP: limit the amount of initiators to draw
On a large trace, clicking on one event drew so many initiators when I was zoomed out that I could barely see any of the events. It's useful to walk back through the trace, but let's put a limit on it for both visual and performance reasons. Bug: 438484658 Change-Id: Ia1efd78f762bdb76852b075378a89f59955d7680 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6845964 Reviewed-by: Connor Clark <[email protected]> Commit-Queue: Jack Franklin <[email protected]>
1 parent ecf7539 commit a9f3a4c

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

front_end/panels/timeline/Initiators.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ describeWithEnvironment('Initiators', () => {
5858
Trace.Types.Events.Event;
5959
assert.exists(functionCallByrequestIdleCallback);
6060
});
61+
6162
it('returns the initiator data', async function() {
6263
const initiatorData = Timeline.Initiators.initiatorsDataToDraw(parsedTrace, functionCallBySetTimeout, [], []);
6364
assert.deepEqual(initiatorData[0], {

front_end/panels/timeline/Initiators.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ export interface InitiatorData {
1010
isEntryHidden?: boolean;
1111
isInitiatorHidden?: boolean;
1212
}
13+
14+
export interface InitiatorDataOptions {
15+
/**
16+
* Used to limit how far back through the chain we go; some large JS apps can
17+
* have vast amounts of initiator stacks and it's hard to render them
18+
* efficiently, and also not very useful to the user if we just show loads of
19+
* them.
20+
*/
21+
predecessorLimit: number;
22+
}
23+
24+
// We limit the amount of predecessors to 10; on large traces with large JS
25+
// stacks there can be a huge number of these. It's not super useful to
26+
// walk back too far and if we draw too many arrows on the timeline, the view becomes very cluttered and noisy.
27+
const MAX_PREDECESSOR_INITIATOR_LIMIT = 10;
28+
1329
/**
1430
* Given an event that the user has selected, this function returns all the
1531
* data of events and their initiators that need to be drawn on the flamechart.
@@ -18,11 +34,9 @@ export interface InitiatorData {
1834
* work backwards to draw each one, as well as the events initiated directly by the entry.
1935
*/
2036
export function initiatorsDataToDraw(
21-
parsedTrace: Trace.Handlers.Types.ParsedTrace,
22-
selectedEvent: Trace.Types.Events.Event,
37+
parsedTrace: Trace.Handlers.Types.ParsedTrace, selectedEvent: Trace.Types.Events.Event,
2338
hiddenEntries: Trace.Types.Events.Event[],
24-
expandableEntries: Trace.Types.Events.Event[],
25-
): readonly InitiatorData[] {
39+
expandableEntries: Trace.Types.Events.Event[]): readonly InitiatorData[] {
2640
const initiatorsData = [
2741
...findInitiatorDataPredecessors(parsedTrace, selectedEvent, parsedTrace.Initiators.eventToInitiator),
2842
...findInitiatorDataDirectSuccessors(selectedEvent, parsedTrace.Initiators.initiatorToEvents),
@@ -49,13 +63,12 @@ function findInitiatorDataPredecessors(
4963
eventToInitiator: Map<Trace.Types.Events.Event, Trace.Types.Events.Event>,
5064
): readonly InitiatorData[] {
5165
const initiatorsData: InitiatorData[] = [];
52-
5366
let currentEvent: Trace.Types.Events.Event|null = selectedEvent;
5467
const visited = new Set<Trace.Types.Events.Event>();
5568
visited.add(currentEvent);
5669

5770
// Build event initiator data up to the selected one
58-
while (currentEvent) {
71+
while (currentEvent && initiatorsData.length < MAX_PREDECESSOR_INITIATOR_LIMIT) {
5972
const currentInitiator = eventToInitiator.get(currentEvent);
6073

6174
if (currentInitiator) {

front_end/panels/timeline/TimelineFlameChartDataProvider.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,12 +1359,7 @@ export class TimelineFlameChartDataProvider extends Common.ObjectWrapper.ObjectW
13591359
const expandableEntries: Trace.Types.Events.Event[] =
13601360
ModificationsManager.activeManager()?.getEntriesFilter().expandableEntries() ?? [];
13611361

1362-
const initiatorsData = initiatorsDataToDraw(
1363-
this.parsedTrace,
1364-
event,
1365-
hiddenEvents,
1366-
expandableEntries,
1367-
);
1362+
const initiatorsData = initiatorsDataToDraw(this.parsedTrace, event, hiddenEvents, expandableEntries);
13681363

13691364
if (initiatorsData.length === 0) {
13701365
// Small optimization: cache if this entry has 0 initiators, meaning if

0 commit comments

Comments
 (0)