-
Notifications
You must be signed in to change notification settings - Fork 449
Display traced values in Stack Chart view #5363
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,7 @@ | |
| "common-tags": "^1.8.2", | ||
| "copy-to-clipboard": "^3.3.3", | ||
| "core-js": "^3.47.0", | ||
| "devtools-reps": "^0.27.3", | ||
|
Member
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. Looks like 0.27.4 is out now. I don't know if you need it or if it's crucial. Otherwise our dependency updates will handle it. |
||
| "escape-string-regexp": "^4.0.0", | ||
| "gecko-profiler-demangle": "^0.4.0", | ||
| "idb": "^8.0.3", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,3 +29,17 @@ | |
| .colored-border.ellipsis { | ||
| opacity: 0; | ||
| } | ||
|
|
||
| /* Colors for DevTools Reps */ | ||
| :root { | ||
| --number-color: #058b00; | ||
| --string-color: #dd00a9; | ||
| --null-color: #5c5c5f; | ||
| --object-color: #0074e8; | ||
| --caption-color: #0074e8; | ||
| --location-color: #5c5c5f; | ||
| --source-link-color: #0060df; | ||
| --node-color: #003eaa; | ||
| --reference-color: #0074e8; | ||
| --comment-node-color: #5c5c5f; | ||
|
Comment on lines
+35
to
+44
Member
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. Are they the variables used inside reps css file?
Author
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. They are - do you have a suggestion on where they should live, if you'd like them to live elsewhere?
Member
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. I think it's fine for them to live there. From the package devtools-reps perspective maybe it would be better to have a prefix in their name to make sure that they don't clash with other variables (like |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ import type { | |
|
|
||
| type ChangeMouseTimePosition = typeof changeMouseTimePosition; | ||
| import { mapCategoryColorNameToStackChartStyles } from '../../utils/colors'; | ||
| import { ValueSummaryReader } from 'devtools-reps'; | ||
| import { TooltipCallNode } from '../tooltip/CallNode'; | ||
| import { TooltipMarker } from '../tooltip/Marker'; | ||
|
|
||
|
|
@@ -624,6 +625,17 @@ class StackChartCanvasImpl extends React.PureComponent<Props> { | |
| timelineUnit === 'bytes' | ||
| ? formatBytes(duration) | ||
| : formatMilliseconds(duration); | ||
| let argumentSummaries = undefined; | ||
| if (timing.argumentValues) { | ||
| const argumentValues = timing.argumentValues[stackTimingIndex]; | ||
|
Member
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. The |
||
| if (argumentValues !== -1) { | ||
| argumentSummaries = ValueSummaryReader.getArgumentSummaries( | ||
|
Member
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. Hmm typescript says the return value of |
||
| thread.tracedValuesBuffer as ArrayBuffer, | ||
| thread.tracedObjectShapes as Array<string[] | null>, | ||
|
Comment on lines
+633
to
+634
Member
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. Can we remove these casts by checking if they are present in the if check above? if (timing.argumentValues) {Could be updated to cover these: if (timing.argumentValues && thread.tracedValuesBuffer && thread.tracedObjectShapes) {Technically if |
||
| argumentValues | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <TooltipCallNode | ||
|
|
@@ -638,6 +650,7 @@ class StackChartCanvasImpl extends React.PureComponent<Props> { | |
| callTreeSummaryStrategy="timing" | ||
| durationText={durationText} | ||
| displayStackType={displayStackType} | ||
| argumentValues={argumentSummaries} | ||
|
Member
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. It would be good to be consistent with the naming here. Either we should use |
||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,8 @@ import type { | |||||||||
| OneCategoryBreakdown, | ||||||||||
| } from 'firefox-profiler/profile-logic/profile-data'; | ||||||||||
| import type { CallNodeInfo } from 'firefox-profiler/profile-logic/call-node-info'; | ||||||||||
| import { REPS, MODE } from 'devtools-reps'; | ||||||||||
| const { Rep } = REPS; | ||||||||||
|
|
||||||||||
| import './CallNode.css'; | ||||||||||
| import classNames from 'classnames'; | ||||||||||
|
|
@@ -129,6 +131,7 @@ type Props = { | |||||||||
| readonly timings?: TimingsForPath; | ||||||||||
| readonly callTreeSummaryStrategy: CallTreeSummaryStrategy; | ||||||||||
| readonly displayStackType: boolean; | ||||||||||
| readonly argumentValues?: Array<object>; | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
@@ -358,6 +361,7 @@ export class TooltipCallNode extends React.PureComponent<Props> { | |||||||||
| thread, | ||||||||||
| durationText, | ||||||||||
| categories, | ||||||||||
| argumentValues, | ||||||||||
| displayData, | ||||||||||
| timings, | ||||||||||
| callTreeSummaryStrategy, | ||||||||||
|
|
@@ -426,6 +430,29 @@ export class TooltipCallNode extends React.PureComponent<Props> { | |||||||||
| ]; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| let argumentsElement = null; | ||||||||||
| if (argumentValues) { | ||||||||||
| if (argumentValues.length === 0) { | ||||||||||
| argumentsElement = <div className="arguments">No arguments.</div>; | ||||||||||
| } else { | ||||||||||
| const argumentValuesEl = []; | ||||||||||
| for (const previewObject of argumentValues) { | ||||||||||
| argumentValuesEl.push( | ||||||||||
| Rep({ | ||||||||||
| object: previewObject, | ||||||||||
| mode: MODE.LONG, | ||||||||||
| }) | ||||||||||
| ); | ||||||||||
| } | ||||||||||
| argumentsElement = ( | ||||||||||
| <div className="arguments"> | ||||||||||
| <div className="argumentsLabel">Arguments</div> | ||||||||||
|
Member
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. nit: to make it similar to the other fields:
Suggested change
can we also switch And looking at the tooltip, the profiler/src/components/tooltip/CallNode.css Lines 91 to 92 in 5dd4c64
tip: you can call |
||||||||||
| {argumentValuesEl} | ||||||||||
| </div> | ||||||||||
| ); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Finding current frame and parent frame URL(if there is). | ||||||||||
| let pageAndParentPageURL; | ||||||||||
| if (innerWindowIDToPageMap) { | ||||||||||
|
|
@@ -542,6 +569,7 @@ export class TooltipCallNode extends React.PureComponent<Props> { | |||||||||
| {resource} | ||||||||||
| </div> | ||||||||||
| {this._renderCategoryTimings(timings)} | ||||||||||
| {argumentsElement} | ||||||||||
| </div> | ||||||||||
| </div> | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,7 @@ export type StackTiming = { | |
| sameWidthsStart: number[]; | ||
| sameWidthsEnd: number[]; | ||
| callNode: IndexIntoCallNodeTable[]; | ||
| argumentValues?: number[]; | ||
|
Member
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. nit: could you add a comment explaining that this is used for JS execution tracing argument values? |
||
| length: number; | ||
| }; | ||
|
|
||
|
|
@@ -115,14 +116,20 @@ export function getStackTimingByDepth( | |
| } = callNodeTable; | ||
| const stackTimingByDepth: StackTimingByDepth = Array.from( | ||
| { length: maxDepthPlusOne }, | ||
| (): StackTiming => ({ | ||
| start: [], | ||
| end: [], | ||
| sameWidthsStart: [], | ||
| sameWidthsEnd: [], | ||
| callNode: [], | ||
| length: 0, | ||
| }) | ||
| (): StackTiming => { | ||
| const shape: StackTiming = { | ||
| start: [], | ||
| end: [], | ||
| sameWidthsStart: [], | ||
| sameWidthsEnd: [], | ||
| callNode: [], | ||
| length: 0, | ||
| }; | ||
| if ('argumentValues' in samples) { | ||
| shape.argumentValues = []; | ||
| } | ||
| return shape; | ||
| } | ||
| ); | ||
|
|
||
| const sameWidthsIndexToTimestampMap: SameWidthsIndexToTimestampMap = []; | ||
|
|
@@ -154,6 +161,7 @@ export function getStackTimingByDepth( | |
| let deepestOpenBoxDepth = -1; | ||
| const openBoxStartTimeByDepth = new Float64Array(maxDepthPlusOne); | ||
| const openBoxStartTickByDepth = new Float64Array(maxDepthPlusOne); | ||
| const openBoxArgsByDepth = new Int32Array(maxDepthPlusOne); | ||
|
|
||
| let currentStackTick = 0; | ||
| for (let sampleIndex = 0; sampleIndex < samples.length; sampleIndex++) { | ||
|
|
@@ -162,6 +170,14 @@ export function getStackTimingByDepth( | |
| continue; | ||
| } | ||
|
|
||
| let sampleArgs: number = -1; | ||
| if ('argumentValues' in samples && samples.argumentValues !== undefined) { | ||
| const val = samples.argumentValues[sampleIndex]; | ||
| if (val !== null) { | ||
| sampleArgs = val; | ||
| } | ||
| } | ||
|
|
||
| const sampleTime = samples.time[sampleIndex]; | ||
|
|
||
| // Phase 1: Commit open boxes which are not shared by the current call node, | ||
|
|
@@ -193,6 +209,10 @@ export function getStackTimingByDepth( | |
| stackTimingForThisDepth.sameWidthsStart[index] = startStackTick; | ||
| stackTimingForThisDepth.sameWidthsEnd[index] = currentStackTick; | ||
| stackTimingForThisDepth.callNode[index] = deepestOpenBoxCallNodeIndex; | ||
| if (stackTimingForThisDepth.argumentValues) { | ||
| stackTimingForThisDepth.argumentValues[index] = | ||
| openBoxArgsByDepth[deepestOpenBoxDepth]; | ||
| } | ||
| deepestOpenBoxCallNodeIndex = | ||
| callNodeTablePrefixColumn[deepestOpenBoxCallNodeIndex]; | ||
| deepestOpenBoxDepth--; | ||
|
|
@@ -208,6 +228,12 @@ export function getStackTimingByDepth( | |
| deepestOpenBoxDepth++; | ||
| openBoxStartTimeByDepth[deepestOpenBoxDepth] = sampleTime; | ||
| openBoxStartTickByDepth[deepestOpenBoxDepth] = currentStackTick; | ||
| if ( | ||
| 'argumentValues' in samples && | ||
| samples.argumentValues !== undefined | ||
| ) { | ||
| openBoxArgsByDepth[deepestOpenBoxDepth] = sampleArgs; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -229,6 +255,10 @@ export function getStackTimingByDepth( | |
| stackTimingForThisDepth.sameWidthsStart[index] = startStackTick; | ||
| stackTimingForThisDepth.sameWidthsEnd[index] = currentStackTick; | ||
| stackTimingForThisDepth.callNode[index] = deepestOpenBoxCallNodeIndex; | ||
| if (stackTimingForThisDepth.argumentValues) { | ||
| stackTimingForThisDepth.argumentValues[index] = | ||
| openBoxArgsByDepth[deepestOpenBoxDepth]; | ||
| } | ||
| deepestOpenBoxCallNodeIndex = | ||
| callNodeTablePrefixColumn[deepestOpenBoxCallNodeIndex]; | ||
| deepestOpenBoxDepth--; | ||
|
|
||
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.
nit: it would be good to add a comment here saying that
\\.[jt]sx?$is the default regexp and we change it to make sure that mjs files are included.