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
8 changes: 8 additions & 0 deletions docs-developer/CHANGELOG-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ Note that this is not an exhaustive list. Processed profile format upgraders can

## Processed profile format

### Version 70

The `lib` column moved off the `resourceTable` and onto the `frameTable`. Previously a frame's library was reached indirectly, via `frame -> func -> resource -> lib`; now the frame points at its library directly, and `resourceTable` has no `lib` column at all. Frames with no library have their lib set to the `-1` sentinel.

This decouples resources from libraries.

The `lib` column can optionally be stored as an `Int32Array`, for profiles loaded from [JsonSlabs](https://github.com/mstange/json-slabs/) files (.jslb, .jslb.gz). Regular JS / JSON arrays are still accepted - but note that `-1` (not `null`) must be used regardless of format.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was checking where we do this lib array to Int32Array conversion and couldn't find it. I think this needs to happen in finishRawFrameTableBuilder and convertSharedTablesEligibleColumns.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Added.


### Version 69

A new marker schema display location, `timeline-network`, was added. A marker schema can list `timeline-network` in its `display` array to have markers of that type surfaced in the Network track.
Expand Down
6 changes: 2 additions & 4 deletions profiler-cli/src/test/unit/call-tree-formatting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ function buildTopDownResult(
const state = store.getState();
const threadSelectors = getThreadSelectors(0);
const callTree = threadSelectors.getCallTree(state);
const libs = profile.libs;

const regularCallTree = collectCallTree(callTree, libs, options);
const regularCallTree = collectCallTree(callTree, options);

return {
type: 'thread-samples-top-down',
Expand All @@ -76,7 +75,6 @@ function buildBottomUpResult(
const store = storeWithProfile(profile);
const state = store.getState();
const threadSelectors = getThreadSelectors(0);
const libs = profile.libs;

// Build inverted call tree (bottom-up view)
let collectedInvertedTree = null;
Expand Down Expand Up @@ -118,7 +116,7 @@ function buildBottomUpResult(
weightType
);

collectedInvertedTree = collectCallTree(invertedTree, libs, options);
collectedInvertedTree = collectCallTree(invertedTree, options);
} catch (e) {
// Failed to create inverted tree
console.error('Failed to create inverted call tree:', e);
Expand Down
2 changes: 0 additions & 2 deletions src/actions/profile-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,6 @@ export function updateBottomBoxContentsAndMaybeOpen(
bottomBoxInfo: BottomBoxInfo
): Action {
const {
libIndex,
sourceIndex,
nativeSymbols,
initialNativeSymbol,
Expand All @@ -1970,7 +1969,6 @@ export function updateBottomBoxContentsAndMaybeOpen(

return {
type: 'UPDATE_BOTTOM_BOX',
libIndex,
sourceIndex,
nativeSymbols,
currentNativeSymbol: initialNativeSymbol,
Expand Down
2 changes: 1 addition & 1 deletion src/app-logic/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const GECKO_PROFILE_VERSION = 36;
// The current version of the "processed" profile format.
// Please don't forget to update the processed profile format changelog in
// `docs-developer/CHANGELOG-formats.md`.
export const PROCESSED_PROFILE_VERSION = 69;
export const PROCESSED_PROFILE_VERSION = 70;

// The following are the margin sizes for the left and right of the timeline. Independent
// components need to share these values.
Expand Down
1 change: 0 additions & 1 deletion src/app-logic/url-handling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ export function stateFromLocation(
toValidTabSlug(pathParts[selectedTabPathPart]) || 'calltree';
const sourceView: SourceViewState = {
scrollGeneration: 0,
libIndex: null,
sourceIndex: null,
highlightedLine: null,
};
Expand Down
35 changes: 4 additions & 31 deletions src/profile-logic/bottom-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { ResourceType } from 'firefox-profiler/types';

import type {
Thread,
IndexIntoStackTable,
Expand Down Expand Up @@ -37,14 +35,8 @@ export function getBottomBoxInfoForCallNode(
thread: Thread,
samples: SamplesLikeTable
): BottomBoxInfo {
const {
stackTable,
frameTable,
funcTable,
stringTable,
resourceTable,
nativeSymbols,
} = thread;
const { stackTable, frameTable, funcTable, stringTable, nativeSymbols } =
thread;

const funcIndex = callNodeInfo.funcForNode(callNodeIndex);
const { source: sourceIndex, line: funcLine } = getOriginalPositionForFrame(
Expand All @@ -54,11 +46,6 @@ export function getBottomBoxInfoForCallNode(
funcTable,
thread.sourceLocationTable
);
const resource = funcTable.resource[funcIndex];
const libIndex =
resource !== -1 && resourceTable.type[resource] === ResourceType.Library
? resourceTable.lib[resource]
: null;
const callNodeFramePerStack = getCallNodeFramePerStack(
callNodeIndex,
callNodeInfo,
Expand Down Expand Up @@ -126,7 +113,6 @@ export function getBottomBoxInfoForCallNode(
const hottestInstructionAddress = mapGetKeyWithMaxValue(addressTimings);

return {
libIndex,
sourceIndex,
nativeSymbols: nativeSymbolInfosForCallNode,
initialNativeSymbol:
Expand All @@ -148,14 +134,8 @@ export function getBottomBoxInfoForStackFrame(
stackIndex: IndexIntoStackTable,
thread: Thread
): BottomBoxInfo {
const {
stackTable,
frameTable,
funcTable,
resourceTable,
nativeSymbols,
stringTable,
} = thread;
const { stackTable, frameTable, funcTable, nativeSymbols, stringTable } =
thread;

const frameIndex = stackTable.frame[stackIndex];
const funcIndex = frameTable.func[frameIndex];
Expand All @@ -166,12 +146,6 @@ export function getBottomBoxInfoForStackFrame(
funcTable,
thread.sourceLocationTable
);
const resource = funcTable.resource[funcIndex];
const libIndex =
resource !== -1 && resourceTable.type[resource] === ResourceType.Library
? resourceTable.lib[resource]
: null;

// Get native symbol for this frame
const nativeSymbol = frameTable.nativeSymbol[frameIndex];
const nativeSymbolInfos =
Expand All @@ -190,7 +164,6 @@ export function getBottomBoxInfoForStackFrame(
nativeSymbol !== null ? frameTable.address[frameIndex] : -1;

return {
libIndex,
sourceIndex,
nativeSymbols: nativeSymbolInfos,
initialNativeSymbol: 0,
Expand Down
6 changes: 5 additions & 1 deletion src/profile-logic/data-structures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type {
IndexIntoSubcategoryListForCategory,
IndexIntoNativeSymbolTable,
IndexIntoSourceLocationTable,
IndexIntoLibs,
InnerWindowID,
Address,
Bytes,
Expand Down Expand Up @@ -117,6 +118,7 @@ export type RawFrameTableBuilder = {
category: (IndexIntoCategoryList | null)[];
subcategory: (IndexIntoSubcategoryListForCategory | null)[];
func: IndexIntoFuncTable[];
lib: Array<IndexIntoLibs | -1>;
nativeSymbol: (IndexIntoNativeSymbolTable | null)[];
innerWindowID: (InnerWindowID | null)[];
line: (number | null)[];
Expand Down Expand Up @@ -289,6 +291,7 @@ export function getRawFrameTableBuilder(): RawFrameTableBuilder {
category: [],
subcategory: [],
func: [],
lib: [],
nativeSymbol: [],
innerWindowID: [],
line: [],
Expand All @@ -311,6 +314,7 @@ export function getRawFrameTableBuilderWithExistingContents(
category: frameTable.category.slice(),
subcategory: frameTable.subcategory.slice(),
func: Array.from(frameTable.func),
lib: Array.from(frameTable.lib),
nativeSymbol: frameTable.nativeSymbol.slice(),
innerWindowID: frameTable.innerWindowID.slice(),
line: frameTable.line.slice(),
Expand All @@ -328,6 +332,7 @@ export function finishRawFrameTableBuilder(
address: new Int32Array(builder.address),
inlineDepth: new Uint8Array(builder.inlineDepth),
func: new Int32Array(builder.func),
lib: new Int32Array(builder.lib),
};
}

Expand Down Expand Up @@ -409,7 +414,6 @@ export function getEmptyResourceTable(): ResourceTable {
// If modifying this structure, please update all callers of this function to ensure
// that they are pushing on correctly to the data structure. These pushes may not
// be caught by the type system.
lib: [],
name: [],
host: [],
type: [],
Expand Down
33 changes: 7 additions & 26 deletions src/profile-logic/global-data-collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ export class GlobalDataCollector {
_funcKeyToFuncIndex: Map<string, IndexIntoFuncTable> = new Map();
_nativeSymbolKeyToNativeSymbolIndex: Map<string, IndexIntoNativeSymbolTable> =
new Map();
_libIndexToResourceIndex: Map<IndexIntoLibs, IndexIntoResourceTable> =
new Map();
_libNameToResourceIndex: Map<IndexIntoStringTable, IndexIntoResourceTable> =
new Map();
_originToResourceIndex: Map<string, IndexIntoResourceTable> = new Map();
Expand Down Expand Up @@ -179,7 +177,6 @@ export class GlobalDataCollector {

const idIndex = this._stringTable.indexForString(extensions.id[i]);

resourceTable.lib[resourceIndex] = null;
resourceTable.name[resourceIndex] =
this._stringTable.indexForString(name);
resourceTable.host[resourceIndex] = idIndex;
Expand Down Expand Up @@ -223,7 +220,6 @@ export class GlobalDataCollector {
this._originToResourceIndex.set(origin, resourceIndex);
if (host) {
// This is a webhost URL.
resourceTable.lib[resourceIndex] = null;
resourceTable.name[resourceIndex] =
this._stringTable.indexForString(origin);
resourceTable.host[resourceIndex] =
Expand All @@ -232,7 +228,6 @@ export class GlobalDataCollector {
} else {
// This is a URL, but it doesn't point to something on the web, e.g. a
// chrome url.
resourceTable.lib[resourceIndex] = null;
resourceTable.name[resourceIndex] =
this._stringTable.indexForString(scriptURI);
resourceTable.host[resourceIndex] = null;
Expand All @@ -241,26 +236,7 @@ export class GlobalDataCollector {
return resourceIndex;
}

indexForLibResource(libIndex: IndexIntoLibs): IndexIntoResourceTable {
let resourceIndex = this._libIndexToResourceIndex.get(libIndex);
if (resourceIndex !== undefined) {
return resourceIndex;
}

const resourceTable = this._resourceTable;

resourceIndex = this._resourceTable.length++;
this._libIndexToResourceIndex.set(libIndex, resourceIndex);
resourceTable.lib[resourceIndex] = libIndex;
resourceTable.name[resourceIndex] = this._stringTable.indexForString(
this._libs[libIndex].name
);
resourceTable.host[resourceIndex] = null;
resourceTable.type[resourceIndex] = ResourceType.Library;
return resourceIndex;
}

indexForNameOnlyLibResource(
indexForLibResourceByName(
libNameStringIndex: IndexIntoStringTable
): IndexIntoResourceTable {
let resourceIndex = this._libNameToResourceIndex.get(libNameStringIndex);
Expand All @@ -272,13 +248,18 @@ export class GlobalDataCollector {

resourceIndex = this._resourceTable.length++;
this._libNameToResourceIndex.set(libNameStringIndex, resourceIndex);
resourceTable.lib[resourceIndex] = null;
resourceTable.name[resourceIndex] = libNameStringIndex;
resourceTable.host[resourceIndex] = null;
resourceTable.type[resourceIndex] = ResourceType.Library;
return resourceIndex;
}

indexForLibResourceByLib(libIndex: IndexIntoLibs): IndexIntoResourceTable {
return this.indexForLibResourceByName(
this._stringTable.indexForString(this._libs[libIndex].name)
);
}

indexForNativeSymbol(
libIndex: IndexIntoLibs,
address: Address,
Expand Down
1 change: 1 addition & 0 deletions src/profile-logic/import/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ async function processTracingEvents(
frameTable.category[frameIndex] = category;
frameTable.subcategory[frameIndex] = 0;
frameTable.func[frameIndex] = funcId;
frameTable.lib[frameIndex] = -1;
frameTable.nativeSymbol[frameIndex] = null;
frameTable.innerWindowID[frameIndex] = 0;
frameTable.line[frameIndex] =
Expand Down
2 changes: 2 additions & 0 deletions src/profile-logic/import/dhat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export function attemptToConvertDhat(json: unknown): Profile | null {
frameTable.category.push(otherCategory);
frameTable.subcategory.push(otherSubCategory);
frameTable.innerWindowID.push(null);
frameTable.lib.push(-1);
frameTable.nativeSymbol.push(null);
frameTable.inlineDepth.push(0);
frameTable.func.push(rootFuncIndex);
Expand Down Expand Up @@ -279,6 +280,7 @@ export function attemptToConvertDhat(json: unknown): Profile | null {
frameTable.category.push(otherCategory);
frameTable.subcategory.push(otherSubCategory);
frameTable.innerWindowID.push(null);
frameTable.lib.push(-1);
frameTable.nativeSymbol.push(null);
frameTable.inlineDepth.push(0);
frameTable.func.push(funcIndex);
Expand Down
1 change: 1 addition & 0 deletions src/profile-logic/import/flame-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export function convertFlameGraphProfile(profileText: string): Profile {
frameTable.category.push(category);
frameTable.subcategory.push(0);
frameTable.func.push(funcIndex);
frameTable.lib.push(-1);
frameTable.nativeSymbol.push(null);
frameTable.innerWindowID.push(null);
frameTable.line.push(null);
Expand Down
2 changes: 1 addition & 1 deletion src/profile-logic/import/simpleperf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class FirefoxResourceTable {
findOrAddResource(file: report.IFile): IndexIntoResourceTable {
let resourceIndex = this.resourcesMap.get(file.id!);
if (!resourceIndex) {
this.resourceTable.lib.push(null);
this.resourceTable.name.push(this.strings.indexForString(file.path!));
this.resourceTable.host.push(null);
this.resourceTable.type.push(1); // Library
Expand Down Expand Up @@ -177,6 +176,7 @@ class FirefoxFrameTable {
this.frameTable.category.push(category);
this.frameTable.subcategory.push(0);
this.frameTable.func.push(funcIndex);
this.frameTable.lib.push(-1);
this.frameTable.nativeSymbol.push(null);
this.frameTable.innerWindowID.push(null);
this.frameTable.line.push(null);
Expand Down
1 change: 1 addition & 0 deletions src/profile-logic/insert-stack-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export function insertStackLabels(
frameTable.func[frameIndex] = funcIndex;
frameTable.category[frameIndex] = labelCategoryIndex;
frameTable.subcategory[frameIndex] = 0;
frameTable.lib[frameIndex] = -1;
frameTable.nativeSymbol[frameIndex] = null;
frameTable.address[frameIndex] = 0;
frameTable.inlineDepth[frameIndex] = 0;
Expand Down
1 change: 1 addition & 0 deletions src/profile-logic/js-tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ export function convertJsTracerToThreadWithoutSamples(
frameTable.inlineDepth.push(0);
frameTable.category.push(otherCategory);
frameTable.func.push(funcIndex);
frameTable.lib.push(-1);
frameTable.nativeSymbol.push(null);
frameTable.innerWindowID.push(0);
frameTable.line.push(line);
Expand Down
Loading
Loading