Skip to content

Commit 0c2562c

Browse files
authored
Provide an option to display stacks all with the same widths in the stack chart (#5195)
The goal for this patch is to make shorter behaviors much easier to see. This is useful especially for debugging (and especially when used with the jstracer) rather than for profiling.
2 parents e8a6de5 + 0c5df04 commit 0c2562c

File tree

16 files changed

+1828
-370
lines changed

16 files changed

+1828
-370
lines changed

locales/en-US/app.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ StackSettings--call-tree-strategy-native-deallocations-sites = Deallocation Site
811811
StackSettings--invert-call-stack = Invert call stack
812812
.title = Sort by the time spent in a call node, ignoring its children.
813813
StackSettings--show-user-timing = Show user timing
814+
StackSettings--use-stack-chart-same-widths = Use the same width for each stack
814815
815816
StackSettings--panel-search =
816817
.label = Filter stacks:

src/actions/profile-view.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,22 @@ export function changeShowUserTimings(
16891689
};
16901690
}
16911691

1692+
export function changeStackChartSameWidths(
1693+
stackChartSameWidths: boolean
1694+
): ThunkAction<void> {
1695+
return (dispatch) => {
1696+
sendAnalytics({
1697+
hitType: 'event',
1698+
eventCategory: 'profile',
1699+
eventAction: 'toggle stack chart same widths',
1700+
});
1701+
dispatch({
1702+
type: 'CHANGE_STACK_CHART_SAME_WIDTHS',
1703+
stackChartSameWidths,
1704+
});
1705+
};
1706+
}
1707+
16921708
/**
16931709
* This action toggles changes between using a summary view that shows only self time
16941710
* for the JS tracer data, and a stack-based view (similar to the stack chart) for the

src/app-logic/url-handling.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ type StackChartQuery = {|
196196
search: string, // "js::RunScript"
197197
invertCallstack: null | void,
198198
showUserTimings: null | void,
199+
sameWidths: null | void,
199200
ctSummary: string,
200201
|};
201202

@@ -305,18 +306,19 @@ export function getQueryStringFromUrlState(urlState: UrlState): string {
305306
const selectedTab = urlState.selectedTab;
306307
switch (selectedTab) {
307308
case 'stack-chart':
309+
// Stack chart uses all of the CallTree's query strings but also has
310+
// additional query strings.
311+
query = (baseQuery: StackChartQueryShape);
312+
query.showUserTimings = urlState.profileSpecific.showUserTimings
313+
? null
314+
: undefined;
315+
query.sameWidths = urlState.profileSpecific.stackChartSameWidths
316+
? null
317+
: undefined;
318+
/* fallsthrough */
308319
case 'flame-graph':
309320
case 'calltree': {
310-
if (selectedTab === 'stack-chart') {
311-
// Stack chart uses all of the CallTree's query strings but also has an
312-
// additional query string.
313-
query = (baseQuery: StackChartQueryShape);
314-
query.showUserTimings = urlState.profileSpecific.showUserTimings
315-
? null
316-
: undefined;
317-
} else {
318-
query = (baseQuery: CallTreeQueryShape);
319-
}
321+
query = (baseQuery: CallTreeQueryShape);
320322

321323
query.search = urlState.profileSpecific.callTreeSearchString || undefined;
322324
query.invertCallstack = urlState.profileSpecific.invertCallstack
@@ -544,6 +546,7 @@ export function stateFromLocation(
544546
),
545547
invertCallstack: query.invertCallstack === undefined ? false : true,
546548
showUserTimings: query.showUserTimings === undefined ? false : true,
549+
stackChartSameWidths: query.sameWidths === undefined ? false : true,
547550
committedRanges: query.range ? parseCommittedRanges(query.range) : [],
548551
selectedThreads,
549552
callTreeSearchString: query.search || '',

src/components/shared/StackSettings.js

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ import {
1111
changeInvertCallstack,
1212
changeCallTreeSearchString,
1313
changeShowUserTimings,
14+
changeStackChartSameWidths,
1415
} from 'firefox-profiler/actions/profile-view';
1516
import {
1617
getInvertCallstack,
1718
getSelectedTab,
1819
getShowUserTimings,
20+
getStackChartSameWidths,
1921
getCurrentSearchString,
2022
} from 'firefox-profiler/selectors/url-state';
2123
import { getProfileUsesMultipleStackTypes } from 'firefox-profiler/selectors/profile';
@@ -40,6 +42,7 @@ type StateProps = {|
4042
+allowSwitchingStackType: boolean,
4143
+invertCallstack: boolean,
4244
+showUserTimings: boolean,
45+
+stackChartSameWidths: boolean,
4346
+currentSearchString: string,
4447
+hasUsefulJsAllocations: boolean,
4548
+hasUsefulNativeAllocations: boolean,
@@ -49,6 +52,7 @@ type DispatchProps = {|
4952
+changeInvertCallstack: typeof changeInvertCallstack,
5053
+changeShowUserTimings: typeof changeShowUserTimings,
5154
+changeCallTreeSearchString: typeof changeCallTreeSearchString,
55+
+changeStackChartSameWidths: typeof changeStackChartSameWidths,
5256
|};
5357

5458
type Props = ConnectedProps<OwnProps, StateProps, DispatchProps>;
@@ -62,6 +66,10 @@ class StackSettingsImpl extends PureComponent<Props> {
6266
this.props.changeShowUserTimings(e.currentTarget.checked);
6367
};
6468

69+
_onUseStackChartSameWidths = (e: SyntheticEvent<HTMLInputElement>) => {
70+
this.props.changeStackChartSameWidths(e.currentTarget.checked);
71+
};
72+
6573
_onSearch = (value: string) => {
6674
this.props.changeCallTreeSearchString(value);
6775
};
@@ -72,6 +80,7 @@ class StackSettingsImpl extends PureComponent<Props> {
7280
invertCallstack,
7381
selectedTab,
7482
showUserTimings,
83+
stackChartSameWidths,
7584
hideInvertCallstack,
7685
currentSearchString,
7786
hasUsefulJsAllocations,
@@ -112,17 +121,30 @@ class StackSettingsImpl extends PureComponent<Props> {
112121
</label>
113122
)}
114123
{selectedTab !== 'stack-chart' ? null : (
115-
<label className="photon-label photon-label-micro photon-label-horiz-padding">
116-
<input
117-
type="checkbox"
118-
className="photon-checkbox photon-checkbox-micro stackSettingsCheckbox"
119-
onChange={this._onShowUserTimingsClick}
120-
checked={showUserTimings}
121-
/>
122-
<Localized id="StackSettings--show-user-timing">
123-
Show user timing
124-
</Localized>
125-
</label>
124+
<>
125+
<label className="photon-label photon-label-micro photon-label-horiz-padding">
126+
<input
127+
type="checkbox"
128+
className="photon-checkbox photon-checkbox-micro stackSettingsCheckbox"
129+
onChange={this._onShowUserTimingsClick}
130+
checked={showUserTimings}
131+
/>
132+
<Localized id="StackSettings--show-user-timing">
133+
Show user timing
134+
</Localized>
135+
</label>
136+
<label className="photon-label photon-label-micro photon-label-horiz-padding">
137+
<input
138+
type="checkbox"
139+
className="photon-checkbox photon-checkbox-micro stackSettingsCheckbox"
140+
onChange={this._onUseStackChartSameWidths}
141+
checked={stackChartSameWidths}
142+
/>
143+
<Localized id="StackSettings--use-stack-chart-same-widths">
144+
Use the same width for each stack
145+
</Localized>
146+
</label>
147+
</>
126148
)}
127149
</li>
128150
)}
@@ -154,6 +176,7 @@ export const StackSettings = explicitConnect<
154176
invertCallstack: getInvertCallstack(state),
155177
selectedTab: getSelectedTab(state),
156178
showUserTimings: getShowUserTimings(state),
179+
stackChartSameWidths: getStackChartSameWidths(state),
157180
currentSearchString: getCurrentSearchString(state),
158181
hasUsefulJsAllocations:
159182
selectedThreadSelectors.getHasUsefulJsAllocations(state),
@@ -164,6 +187,7 @@ export const StackSettings = explicitConnect<
164187
changeInvertCallstack,
165188
changeCallTreeSearchString,
166189
changeShowUserTimings,
190+
changeStackChartSameWidths,
167191
},
168192
component: StackSettingsImpl,
169193
});

0 commit comments

Comments
 (0)