-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core(tracehouse): allow nested trace events without an end #9785
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ describe('Main Thread Tasks', () => { | |
duration: 100, | ||
selfTime: 50, | ||
group: taskGroups.other, | ||
unbounded: false, | ||
}); | ||
|
||
expect(taskB).toEqual({ | ||
|
@@ -112,6 +113,7 @@ describe('Main Thread Tasks', () => { | |
duration: 50, | ||
selfTime: 20, | ||
group: taskGroups.other, | ||
unbounded: false, | ||
}); | ||
}); | ||
|
||
|
@@ -232,6 +234,7 @@ describe('Main Thread Tasks', () => { | |
duration: 110, | ||
selfTime: 5, | ||
group: taskGroups.other, | ||
unbounded: true, | ||
}); | ||
|
||
expect(taskB).toEqual({ | ||
|
@@ -245,6 +248,7 @@ describe('Main Thread Tasks', () => { | |
duration: 105, | ||
selfTime: 95, | ||
group: taskGroups.other, | ||
unbounded: true, | ||
}); | ||
}); | ||
|
||
|
@@ -362,6 +366,7 @@ describe('Main Thread Tasks', () => { | |
duration: 100, | ||
selfTime: 50, | ||
group: taskGroups.other, | ||
unbounded: false, | ||
}, | ||
{ | ||
parent: taskA, | ||
|
@@ -374,6 +379,7 @@ describe('Main Thread Tasks', () => { | |
duration: 50, | ||
selfTime: 50, | ||
group: taskGroups.other, | ||
unbounded: false, | ||
}, | ||
]); | ||
}); | ||
|
@@ -406,6 +412,7 @@ describe('Main Thread Tasks', () => { | |
duration: 100, | ||
selfTime: 100, | ||
group: taskGroups.other, | ||
unbounded: false, | ||
}, | ||
{ | ||
parent: undefined, | ||
|
@@ -418,6 +425,7 @@ describe('Main Thread Tasks', () => { | |
duration: 0, | ||
selfTime: 0, | ||
group: taskGroups.other, | ||
unbounded: false, | ||
}, | ||
]); | ||
}); | ||
|
@@ -452,6 +460,7 @@ describe('Main Thread Tasks', () => { | |
duration: 100, | ||
selfTime: 25, | ||
group: taskGroups.other, | ||
unbounded: false, | ||
}, | ||
{ | ||
parent: taskA, | ||
|
@@ -464,10 +473,61 @@ describe('Main Thread Tasks', () => { | |
duration: 75, | ||
selfTime: 75, | ||
group: taskGroups.other, | ||
unbounded: false, | ||
}, | ||
]); | ||
}); | ||
|
||
it('should handle child events that extend >1ms beyond parent event because missing E', () => { | ||
/* | ||
An artistic rendering of the below trace: | ||
████████████████TaskA██████████████████ | ||
█████████TaskB██████████████████ | ||
*/ | ||
const traceEvents = [ | ||
...boilerplateTrace, | ||
{ph: 'B', name: 'TaskA', pid, tid, ts: baseTs, args}, | ||
{ph: 'B', name: 'TaskB', pid, tid, ts: baseTs + 25e3, args}, | ||
{ph: 'E', name: 'TaskA', pid, tid, ts: baseTs + 100e3, args}, | ||
{ph: 'I', name: 'MarkerToPushOutTraceEnd', pid, tid, ts: baseTs + 110e3, args}, | ||
]; | ||
|
||
traceEvents.forEach(evt => Object.assign(evt, {cat: 'devtools.timeline'})); | ||
|
||
const tasks = run({traceEvents}); | ||
const [taskA, taskB] = tasks; | ||
expect(tasks).toEqual([ | ||
{ | ||
parent: undefined, | ||
attributableURLs: [], | ||
|
||
children: [taskB], | ||
event: traceEvents.find(event => event.name === 'TaskA'), | ||
startTime: 0, | ||
endTime: 100, | ||
duration: 100, | ||
selfTime: 25, | ||
group: taskGroups.other, | ||
unbounded: false, | ||
}, | ||
{ | ||
parent: taskA, | ||
attributableURLs: [], | ||
|
||
children: [], | ||
event: traceEvents.find(event => event.name === 'TaskB' && event.ph === 'B'), | ||
startTime: 25, | ||
endTime: 100, | ||
duration: 75, | ||
selfTime: 75, | ||
group: taskGroups.other, | ||
unbounded: true, | ||
}, | ||
]); | ||
}); | ||
|
||
// Invalid sets of events. | ||
// All of these should have `traceEnd` pushed out to avoid falling into one of our mitigation scenarios. | ||
const invalidEventSets = [ | ||
[ | ||
// TaskA overlaps with TaskB, X first | ||
|
@@ -499,12 +559,6 @@ describe('Main Thread Tasks', () => { | |
{ph: 'X', name: 'TaskA', pid, tid, ts: baseTs, dur: 100e3, args}, | ||
{ph: 'E', name: 'TaskB', pid, tid, ts: baseTs + 10e3, args}, | ||
], | ||
[ | ||
{ph: 'I', name: 'MarkerToPushOutTraceEnd', pid, tid, ts: baseTs + 110e3, args}, | ||
// TaskB is missing an E event within an X | ||
{ph: 'X', name: 'TaskA', pid, tid, ts: baseTs, dur: 100e3, args}, | ||
{ph: 'B', name: 'TaskB', pid, tid, ts: baseTs + 10e3, args}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
], | ||
]; | ||
|
||
for (const invalidEvents of invalidEventSets) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe put a note on this one to identify what it means?