Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs-developer/CHANGELOG-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ Older versions are not documented in this changelog but can be found in [process

## Gecko profile format

### Version 28

A new `unique-string` marker schema format type has been added, allowing markers to carry unique-strings in their payloads.

### Version 27

The `optimizations` field is removed from the `frameTable` schema.
Expand Down
2 changes: 1 addition & 1 deletion src/app-logic/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { MarkerPhase } from 'firefox-profiler/types';
// The current version of the Gecko profile format.
// Please don't forget to update the gecko profile format changelog in
// `docs-developer/CHANGELOG-formats.md`.
export const GECKO_PROFILE_VERSION = 27;
Comment thread
AdamBrouwersHarries marked this conversation as resolved.
export const GECKO_PROFILE_VERSION = 28;

// The current version of the "processed" profile format.
// Please don't forget to update the processed profile format changelog in
Expand Down
8 changes: 7 additions & 1 deletion src/components/app/MenuButtons/MetaInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import type {
ExtraProfileInfoSection,
} from 'firefox-profiler/types';
import type { ConnectedProps } from 'firefox-profiler/utils/connect';
import { UniqueStringArray } from 'firefox-profiler/utils/unique-string-array';

import './MetaInfo.css';

Expand Down Expand Up @@ -148,7 +149,12 @@ class MetaInfoPanelImpl extends React.PureComponent<Props, State> {
<div className="moreInfoRow" key={label}>
<span className="metaInfoWideLabel">{label}</span>
<div className="moreInfoValue">
{formatFromMarkerSchema('moreInfo', format, value)}
{formatFromMarkerSchema(
'moreInfo',
format,
value,
new UniqueStringArray()
)}
</div>
</div>
);
Expand Down
7 changes: 6 additions & 1 deletion src/components/tooltip/Marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,12 @@ class MarkerTooltipContents extends React.PureComponent<Props> {
key={schema.name + '-' + key}
label={label || key}
>
{formatMarkupFromMarkerSchema(schema.name, format, value)}
{formatMarkupFromMarkerSchema(
schema.name,
format,
value,
thread.stringTable
)}
</TooltipDetail>
);
}
Expand Down
7 changes: 7 additions & 0 deletions src/profile-logic/gecko-profile-versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,13 @@ const _upgraders = {
}
convertToVersion27Recursive(profile);
},
[28]: (_) => {
// This version bump added a new marker schema format type, named "unique-string",
// which older frontends will not be able to display.
// No upgrade is needed, as older versions of firefox would not generate
// marker data with unique-string typed data, and no modification is needed in the
// frontend to display older formats.
},
// If you add a new upgrader here, please document the change in
// `docs-developer/CHANGELOG-formats.md`.
};
Expand Down
46 changes: 37 additions & 9 deletions src/profile-logic/marker-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
MarkerIndex,
MarkerPayload,
} from 'firefox-profiler/types';
import type { UniqueStringArray } from '../utils/unique-string-array';

/**
* The marker schema comes from Gecko, and is embedded in the profile. However,
Expand Down Expand Up @@ -142,6 +143,7 @@ export function getSchemaFromMarker(
export function parseLabel(
markerSchema: MarkerSchema,
categories: CategoryList,
stringTable: UniqueStringArray,
label: string
): (Marker) => string {
// Split the label on the "{key}" capture groups.
Expand Down Expand Up @@ -262,7 +264,12 @@ export function parseLabel(
return '';
}
return format
? formatFromMarkerSchema(markerSchema.name, format, value)
? formatFromMarkerSchema(
markerSchema.name,
format,
value,
stringTable
)
: value;
};
}
Expand Down Expand Up @@ -327,14 +334,18 @@ export function getLabelGetter(
markerSchemaList: MarkerSchema[],
markerSchemaByName: MarkerSchemaByName,
categoryList: CategoryList,
stringTable: UniqueStringArray,
labelKey: LabelKey
): (MarkerIndex) => string {
// Build up a list of label functions, that are tied to the schema name.
const labelFns: Map<string, (Marker) => string> = new Map();
for (const schema of markerSchemaList) {
const labelString = schema[labelKey];
if (labelString) {
labelFns.set(schema.name, parseLabel(schema, categoryList, labelString));
labelFns.set(
schema.name,
parseLabel(schema, categoryList, stringTable, labelString)
);
}
}

Expand Down Expand Up @@ -381,7 +392,8 @@ export function getLabelGetter(
export function formatFromMarkerSchema(
markerType: string,
format: MarkerFormatType,
value: any
value: any,
stringTable: UniqueStringArray
): string {
if (value === undefined || value === null) {
console.warn(
Expand Down Expand Up @@ -414,7 +426,12 @@ export function formatFromMarkerSchema(
}
return row.map((cell, j) => {
const { format } = columns[j];
return formatFromMarkerSchema(markerType, format || 'string', cell);
return formatFromMarkerSchema(
markerType,
format || 'string',
cell,
stringTable
);
});
});
rows.push(...cellRows);
Expand All @@ -432,6 +449,8 @@ export function formatFromMarkerSchema(
case 'string':
// Make sure a non-empty string is returned here.
return String(value) || '(empty)';
case 'unique-string':
return stringTable.getString(value, '(empty)');
case 'duration':
case 'time':
return formatTimestamp(value);
Expand All @@ -456,7 +475,9 @@ export function formatFromMarkerSchema(
throw new Error('Expected an array for list format');
}
return value
.map((v) => formatFromMarkerSchema(markerType, 'string', v))
.map((v) =>
formatFromMarkerSchema(markerType, 'string', v, stringTable)
)
.join(', ');
default:
console.warn(
Expand All @@ -479,14 +500,15 @@ const URL_SCHEME_REGEXP = /^http(s?):\/\//;
export function formatMarkupFromMarkerSchema(
markerType: string,
format: MarkerFormatType,
value: any
value: any,
stringTable: UniqueStringArray
): React.Element<any> | string {
if (value === undefined || value === null) {
console.warn(`Formatting ${value} for ${JSON.stringify(markerType)}`);
return '(empty)';
}
if (format !== 'url' && typeof format !== 'object' && format !== 'list') {
return formatFromMarkerSchema(markerType, format, value);
return formatFromMarkerSchema(markerType, format, value, stringTable);
}
if (typeof format === 'object') {
switch (format.type) {
Expand Down Expand Up @@ -526,7 +548,8 @@ export function formatMarkupFromMarkerSchema(
{formatMarkupFromMarkerSchema(
markerType,
columns[i].type || 'string',
cell
cell,
stringTable
)}
</td>
);
Expand All @@ -553,7 +576,12 @@ export function formatMarkupFromMarkerSchema(
<ul className="marker-list-value">
{value.map((entry, i) => (
<li key={i}>
{formatFromMarkerSchema(markerType, 'string', value[i])}
{formatFromMarkerSchema(
markerType,
'string',
value[i],
stringTable
)}
</li>
))}
</ul>
Expand Down
3 changes: 3 additions & 0 deletions src/selectors/per-thread/markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ export function getMarkerSelectorsPerThread(
ProfileSelectors.getMarkerSchema,
ProfileSelectors.getMarkerSchemaByName,
ProfileSelectors.getCategories,
threadSelectors.getStringTable,
() => 'tooltipLabel',
getLabelGetter
);
Expand All @@ -427,6 +428,7 @@ export function getMarkerSelectorsPerThread(
ProfileSelectors.getMarkerSchema,
ProfileSelectors.getMarkerSchemaByName,
ProfileSelectors.getCategories,
threadSelectors.getStringTable,
() => 'tableLabel',
getLabelGetter
);
Expand All @@ -440,6 +442,7 @@ export function getMarkerSelectorsPerThread(
ProfileSelectors.getMarkerSchema,
ProfileSelectors.getMarkerSchemaByName,
ProfileSelectors.getCategories,
threadSelectors.getStringTable,
() => 'chartLabel',
getLabelGetter
);
Expand Down
2 changes: 1 addition & 1 deletion src/test/store/__snapshots__/profile-view.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ Object {
"startTime": 0,
"symbolicated": true,
"toolkit": "",
"version": 27,
"version": 28,
},
"pages": Array [
Object {
Expand Down
24 changes: 12 additions & 12 deletions src/test/unit/__snapshots__/profile-conversion.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ Object {
"symbolicated": true,
"toolkit": undefined,
"updateChannel": undefined,
"version": 27,
"version": 28,
"visualMetrics": undefined,
},
"pages": Array [],
Expand Down Expand Up @@ -100230,7 +100230,7 @@ Object {
"symbolicated": true,
"toolkit": undefined,
"updateChannel": undefined,
"version": 27,
"version": 28,
"visualMetrics": undefined,
},
"pages": Array [],
Expand Down Expand Up @@ -382170,7 +382170,7 @@ Object {
"startTime": 0,
"symbolicated": true,
"toolkit": "",
"version": 27,
"version": 28,
},
"pages": Array [],
"threads": Array [
Expand Down Expand Up @@ -430874,7 +430874,7 @@ Object {
"startTime": 0,
"symbolicated": true,
"toolkit": "",
"version": 27,
"version": 28,
},
"pages": Array [],
"threads": Array [
Expand Down Expand Up @@ -479578,7 +479578,7 @@ Object {
"startTime": 0,
"symbolicated": true,
"toolkit": "",
"version": 27,
"version": 28,
},
"pages": Array [],
"threads": Array [
Expand Down Expand Up @@ -482618,7 +482618,7 @@ Object {
"startTime": 0,
"symbolicated": true,
"toolkit": "",
"version": 27,
"version": 28,
},
"pages": Array [],
"threads": Array [
Expand Down Expand Up @@ -485736,7 +485736,7 @@ Object {
"startTime": 0,
"symbolicated": true,
"toolkit": "",
"version": 27,
"version": 28,
},
"pages": Array [],
"threads": Array [
Expand Down Expand Up @@ -486936,7 +486936,7 @@ Object {
"symbolicated": true,
"toolkit": undefined,
"updateChannel": undefined,
"version": 27,
"version": 28,
"visualMetrics": undefined,
},
"pages": Array [],
Expand Down Expand Up @@ -494461,7 +494461,7 @@ Object {
"symbolicated": true,
"toolkit": undefined,
"updateChannel": undefined,
"version": 27,
"version": 28,
"visualMetrics": undefined,
},
"pages": Array [],
Expand Down Expand Up @@ -513874,7 +513874,7 @@ Object {
"symbolicated": true,
"toolkit": undefined,
"updateChannel": undefined,
"version": 27,
"version": 28,
"visualMetrics": undefined,
},
"pages": Array [],
Expand Down Expand Up @@ -521392,7 +521392,7 @@ Object {
"symbolicated": true,
"toolkit": undefined,
"updateChannel": undefined,
"version": 27,
"version": 28,
"visualMetrics": undefined,
},
"pages": Array [],
Expand Down Expand Up @@ -544990,7 +544990,7 @@ Object {
"startTime": 0,
"symbolicated": true,
"toolkit": "",
"version": 27,
"version": 28,
},
"pages": Array [],
"threads": Array [
Expand Down
6 changes: 3 additions & 3 deletions src/test/unit/__snapshots__/profile-upgrading.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Object {
"symbolicated": true,
"toolkit": undefined,
"updateChannel": undefined,
"version": 27,
"version": 28,
"visualMetrics": undefined,
},
"pages": Array [],
Expand Down Expand Up @@ -7975,7 +7975,7 @@ Object {
"stackwalk": 1,
"startTime": 1460221352723.438,
"toolkit": "cocoa",
"version": 27,
"version": 28,
},
"pausedRanges": Array [],
"processes": Array [
Expand Down Expand Up @@ -9436,7 +9436,7 @@ Object {
"stackwalk": 1,
"startTime": 1460221352723.438,
"toolkit": "cocoa",
"version": 27,
"version": 28,
},
"pages": Array [
Object {
Expand Down
Loading