Skip to content
Open
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
7 changes: 4 additions & 3 deletions src/actions/profile-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1271,9 +1271,10 @@ function _findOtherVisibleThread(
const localTracks = getLocalTracks(getState(), globalTrack.pid);
const localTrackOrder = getLocalTrackOrder(getState(), globalTrack.pid);
const hiddenLocalTracks = getHiddenLocalTracks(getState(), globalTrack.pid);
const localTrackIndexesToIgnore = localTrackIndexesToIgnoreByPid
? (localTrackIndexesToIgnoreByPid.get(globalTrack.pid) ?? new Set())
: new Set();
const localTrackIndexesToIgnore: Set<TrackIndex> =
localTrackIndexesToIgnoreByPid
? (localTrackIndexesToIgnoreByPid.get(globalTrack.pid) ?? new Set())
: new Set();

for (const trackIndex of localTrackOrder) {
const track = localTracks[trackIndex];
Expand Down
10 changes: 4 additions & 6 deletions src/app-logic/url-handling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ function convertHiddenLocalTracksByPidFromString(
return new Map();
}

const hiddenLocalTracksByPid = new Map();
const hiddenLocalTracksByPid: Map<Pid, Set<TrackIndex>> = new Map();

for (const stringPart of rawText.split('~')) {
if (!stringPart.includes('-')) {
Expand Down Expand Up @@ -679,7 +679,7 @@ function convertLocalTrackOrderByPidFromString(
return new Map();
}

const localTrackOrderByPid = new Map();
const localTrackOrderByPid: Map<Pid, TrackIndex[]> = new Map();

for (const stringPart of rawText.split('~')) {
if (!stringPart.includes('-')) {
Expand Down Expand Up @@ -1018,12 +1018,10 @@ const _upgraders: {
.join('~');
}
if (query.thread) {
const selectedThreads = new Set(
const selectedThreads: Set<number> = new Set(
query.thread.split(',').map((n: string) => +n)
);
query.thread = encodeUintSetForUrlComponent(
selectedThreads as Set<number>
);
query.thread = encodeUintSetForUrlComponent(selectedThreads);
}

// In this version, uintarray-encoding started supporting a range syntax:
Expand Down
4 changes: 2 additions & 2 deletions src/components/shared/AssemblyView-codemirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function addressTimingsToLineTimings(
addressTimings: AddressTimings,
map: AddressToLineMap
): LineTimings {
const totalLineHits = new Map();
const totalLineHits: Map<LineNumber, number> = new Map();
for (const [address, hitCount] of addressTimings.totalAddressHits) {
const line = map.addressToLine(address);
if (line !== null) {
Expand All @@ -158,7 +158,7 @@ function addressTimingsToLineTimings(
}
}

const selfLineHits = new Map();
const selfLineHits: Map<LineNumber, number> = new Map();
for (const [address, hitCount] of addressTimings.selfAddressHits) {
const line = map.addressToLine(address);
if (line !== null) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/tooltip/GCMarker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ function _filterInterestingPhaseTimes(
/*
* Build the tree.
*/
const tree = new Map();
const tree: Map<string, PhaseTreeNode> = new Map();
for (const phase of phaseTimes) {
const components = phase.name.split('.');
_treeInsert(tree, components, phase);
Expand Down
4 changes: 2 additions & 2 deletions src/profile-logic/call-node-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ export class CallNodeInfoInverted implements CallNodeInfo {
// Pass 1: Count the deep nodes per func, and build up a list of funcs.
// We will need to create a child for each deep node func, and each child will
// need to know how many deep nodes it has.
const deepNodeCountPerFunc = new Map();
const deepNodeCountPerFunc: Map<IndexIntoFuncTable, number> = new Map();
const callNodeTable = this._callNodeTable;
for (let i = 0; i < parentDeepNodeCount; i++) {
const selfNode = parentSelfNodes[i];
Expand Down Expand Up @@ -1212,7 +1212,7 @@ export class CallNodeInfoInverted implements CallNodeInfo {
// partitions; one partition per child, in the right order.
const startIndexPerChild = new Uint32Array(childCount);
const deepNodeCountPerChild = new Uint32Array(childCount);
const funcToChildIndex = new Map();
const funcToChildIndex: Map<IndexIntoFuncTable, number> = new Map();

let nextChildStartIndex = 0;
for (let childIndex = 0; childIndex < childCount; childIndex++) {
Expand Down
15 changes: 10 additions & 5 deletions src/profile-logic/import/art-trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Parses the ART trace format and converts it to the Gecko profile format.

import type {
IndexIntoFrameTable,
IndexIntoStackTable,
} from 'firefox-profiler/types';

// These profiles are obtained from Android in two ways:
// - Programmatically, from the Debug API: https://developer.android.com/studio/profile/cpu-profiler#debug-api
// - Or via the profiler UI in Android Studio.
Expand Down Expand Up @@ -562,7 +567,7 @@ function procureSamplingInterval(trace: ArtTrace) {

// Gather up to 500 time deltas between method actions on a thread.
const deltas: number[] = [];
const previousTimestampByThread = new Map();
const previousTimestampByThread: Map<number, number> = new Map();
const numberOfActionsToConsider = Math.min(500, methodActions.length);
for (let i = 0; i < numberOfActionsToConsider; i++) {
const { tid, globalTime } = methodActions[i];
Expand Down Expand Up @@ -617,7 +622,7 @@ export function getSpecialCategory(
return s.substring(0, firstPeriodPos);
}

const significantSegmentCounter = new Map();
const significantSegmentCounter: Map<string, number> = new Map();
for (let i = 0; i < methods.length; i++) {
const significantSegment = getSignificantNamespaceSegment(
methods[i].className
Expand Down Expand Up @@ -787,8 +792,8 @@ class ThreadBuilder {

_currentStack: number | null = null;
_nextSampleTimestamp = 0;
_stackMap = new Map();
_frameMap = new Map();
_stackMap: Map<string, IndexIntoStackTable> = new Map();
_frameMap: Map<number, IndexIntoFrameTable> = new Map();
_registerTime = 0;
_name;
_pid;
Expand Down Expand Up @@ -939,7 +944,7 @@ export function convertArtTraceProfile(
const { summaryDetails, threads, methods, methodActions } = trace;
const categoryInfo = new CategoryInfo(methods);
const methodMap = new Map(methods.map((m) => [m.methodId, m]));
const threadBuilderMap = new Map();
const threadBuilderMap: Map<number, ThreadBuilder> = new Map();

if (methodActions.length > 0) {
for (let i = 0; i < methodActions.length; i++) {
Expand Down
11 changes: 6 additions & 5 deletions src/profile-logic/import/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,11 @@ function getThreadInfo(

profile.threads.push(thread);

const nodeIdToStackId = new Map();
const nodeIdToStackId: Map<number | void, IndexIntoStackTable | null> =
new Map();
nodeIdToStackId.set(undefined, null);

const threadInfo = {
const threadInfo: ThreadInfo = {
thread,
nodeIdToStackId,
funcKeyToFuncId: new Map(),
Expand Down Expand Up @@ -518,8 +519,8 @@ async function processTracingEvents(
ensureExists(profile.meta.categories)
);

const threadInfoByPidAndTid = new Map();
const threadInfoByThread = new Map();
const threadInfoByPidAndTid: Map<string, ThreadInfo> = new Map();
const threadInfoByThread: Map<RawThread, ThreadInfo> = new Map();
for (const profileEvent of profileEvents) {
// The thread info is all of the data that makes it possible to process an
// individual thread.
Expand Down Expand Up @@ -574,7 +575,7 @@ async function processTracingEvents(
} = thread;

if (nodes) {
const parentMap = new Map();
const parentMap: Map<number, number> = new Map();
for (const node of nodes) {
const { callFrame, id: nodeIndex } = node;
let parent: number | void = undefined;
Expand Down
10 changes: 7 additions & 3 deletions src/profile-logic/import/linux-perf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
* 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 type { MixedObject } from 'firefox-profiler/types';
import type {
IndexIntoFrameTable,
IndexIntoStackTable,
MixedObject,
} from 'firefox-profiler/types';

/**
* The "perf script" format is the plain text format that is output by an
Expand Down Expand Up @@ -118,7 +122,7 @@ export function convertPerfScriptProfile(
};
const stringTable: string[] = [];

const stackMap = new Map();
const stackMap: Map<string, IndexIntoStackTable> = new Map();
function getOrCreateStack(frame: number, prefix: number | null) {
const key = prefix === null ? `${frame}` : `${frame},${prefix}`;
let stack = stackMap.get(key);
Expand All @@ -130,7 +134,7 @@ export function convertPerfScriptProfile(
return stack;
}

const frameMap = new Map();
const frameMap: Map<string, IndexIntoFrameTable> = new Map();
function getOrCreateFrame(frameString: string): number {
let frame = frameMap.get(frameString);
if (frame === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/profile-logic/js-tracer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function getScriptLocationToFuncIndex(
sources: SourceTable
): ScriptLocationToFuncIndex {
const { funcTable } = thread;
const scriptLocationToFuncIndex = new Map();
const scriptLocationToFuncIndex: ScriptLocationToFuncIndex = new Map();
for (let funcIndex = 0; funcIndex < funcTable.length; funcIndex++) {
if (!funcTable.isJS[funcIndex]) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/profile-logic/marker-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export function correlateIPCMarkers(
recvThreadName: formatThreadName(recvTid),
};

const addedThreadIds = new Set();
const addedThreadIds: Set<number> = new Set();
if (startEndpointMarker) {
addedThreadIds.add(startEndpointMarker.tid);
correlations.set(
Expand Down Expand Up @@ -1331,7 +1331,7 @@ export function groupScreenshotsById(
getMarker: (markerIndex: MarkerIndex) => Marker,
markerIndexes: MarkerIndex[]
): Map<string, Marker[]> {
const idToScreenshotMarkers = new Map();
const idToScreenshotMarkers: Map<string, Marker[]> = new Map();
for (const markerIndex of markerIndexes) {
const marker = getMarker(markerIndex);
const { data } = marker;
Expand Down
2 changes: 1 addition & 1 deletion src/profile-logic/marker-schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ export function markerPayloadMatchesSearch(
export function computeStringIndexMarkerFieldsByDataType(
markerSchemas: MarkerSchema[]
): Map<string, string[]> {
const stringIndexMarkerFieldsByDataType = new Map();
const stringIndexMarkerFieldsByDataType: Map<string, string[]> = new Map();

// 'CompositorScreenshot' markers currently don't have a schema (#5303),
// hardcode the url field (which is a string index) until they do.
Expand Down
24 changes: 12 additions & 12 deletions src/profile-logic/merge-compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ function mergeCategories(categoriesPerProfile: Array<CategoryList | void>): {
const newCategoryIndexByName: Map<string, IndexIntoCategoryList> = new Map();

const translationMaps = categoriesPerProfile.map((categories) => {
const translationMap = new Map();
const translationMap: TranslationMapForCategories = new Map();

if (!categories) {
// Profiles that are imported may not have categories. Ignore it when attempting
Expand Down Expand Up @@ -482,7 +482,7 @@ function mergeStringArrays(stringArraysPerProfile: Array<string[]>): {
const newStringTable = StringTable.withBackingArray(newStringArray);

const translationMaps = stringArraysPerProfile.map((stringArray) => {
const translationMap = new Map();
const translationMap: TranslationMapForStrings = new Map();
for (let i = 0; i < stringArray.length; i++) {
translationMap.set(i, newStringTable.indexForString(stringArray[i]));
}
Expand All @@ -503,7 +503,7 @@ function mergeSources(
const mapOfInsertedSources: Map<string, IndexIntoSourceTable> = new Map();

const translationMaps = sourcesPerProfile.map((sources, profileIndex) => {
const translationMap = new Map();
const translationMap: TranslationMapForSources = new Map();
if (!sources) {
return translationMap;
}
Expand Down Expand Up @@ -725,11 +725,11 @@ function mergeLibs(libsPerProfile: Lib[][]): {
} {
const mapOfInsertedLibs: Map<string, IndexIntoLibs> = new Map();

const translationMaps: Array<Map<IndexIntoLibs, IndexIntoLibs>> = [];
const translationMaps: Array<TranslationMapForLibs> = [];
const newLibTable: Lib[] = [];

for (const libs of libsPerProfile) {
const translationMap = new Map();
const translationMap: TranslationMapForLibs = new Map();

libs.forEach((lib, i) => {
const insertedLibKey = [lib.name, lib.debugName].join('#');
Expand Down Expand Up @@ -765,7 +765,7 @@ function combineResourceTables(threads: ReadonlyArray<RawThread>): {
const newResourceTable = getEmptyResourceTable();

threads.forEach((thread) => {
const translationMap = new Map();
const translationMap: TranslationMapForResources = new Map();
const { resourceTable } = thread;

for (let i = 0; i < resourceTable.length; i++) {
Expand Down Expand Up @@ -811,7 +811,7 @@ function combineNativeSymbolTables(threads: ReadonlyArray<RawThread>): {
const newNativeSymbols = getEmptyNativeSymbolTable();

threads.forEach((thread) => {
const translationMap = new Map();
const translationMap: TranslationMapForNativeSymbols = new Map();
const { nativeSymbols } = thread;

for (let i = 0; i < nativeSymbols.length; i++) {
Expand Down Expand Up @@ -861,7 +861,7 @@ function combineFuncTables(

threads.forEach((thread, threadIndex) => {
const { funcTable } = thread;
const translationMap = new Map();
const translationMap: TranslationMapForFuncs = new Map();
const resourceTranslationMap = translationMapsForResources[threadIndex];

for (let i = 0; i < funcTable.length; i++) {
Expand Down Expand Up @@ -931,7 +931,7 @@ function combineFrameTables(

threads.forEach((thread, threadIndex) => {
const { frameTable } = thread;
const translationMap = new Map();
const translationMap: TranslationMapForFrames = new Map();
const funcTranslationMap = translationMapsForFuncs[threadIndex];
const nativeSymbolTranslationMap =
translationMapsForNativeSymbols[threadIndex];
Expand Down Expand Up @@ -993,7 +993,7 @@ function combineStackTables(

threads.forEach((thread, threadIndex) => {
const { stackTable } = thread;
const translationMap = new Map();
const translationMap: TranslationMapForStacks = new Map();
const frameTranslationMap = translationMapsForFrames[threadIndex];

for (let i = 0; i < stackTable.length; i++) {
Expand Down Expand Up @@ -1042,7 +1042,7 @@ function combineSamplesDiffing(
ThreadAndWeightMultiplier,
]
): { samples: RawSamplesTable; translationMaps: TranslationMapForSamples[] } {
const translationMaps = [new Map(), new Map()];
const translationMaps: TranslationMapForSamples[] = [new Map(), new Map()];
const [
{
thread: { samples: samples1, tid: tid1 },
Expand Down Expand Up @@ -1427,7 +1427,7 @@ function mergeMarkers(

threads.forEach((thread, threadIndex) => {
const translationMapForStacks = translationMapsForStacks[threadIndex];
const translationMap = new Map();
const translationMap: TranslationMapForMarkers = new Map();
const { markers } = thread;

for (let markerIndex = 0; markerIndex < markers.length; markerIndex++) {
Expand Down
2 changes: 1 addition & 1 deletion src/profile-logic/mozilla-symbolication-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function getV5ResultForLibRequest(
);
}

const results = new Map();
const results: Map<number, AddressResult> = new Map();
for (let i = 0; i < addressInfo.length; i++) {
const address = addressArray[i];
const info = addressInfo[i];
Expand Down
4 changes: 3 additions & 1 deletion src/profile-logic/process-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import type {
Pid,
GeckoMarkerSchema,
GeckoSourceTable,
IndexIntoCategoryList,
} from 'firefox-profiler/types';
import { decompress, isGzip } from 'firefox-profiler/utils/gz';

Expand Down Expand Up @@ -1548,7 +1549,8 @@ export function insertExternalMarkersIntoProfile(
}
}

const categoryMap = new Map();
const categoryMap: Map<IndexIntoCategoryList, IndexIntoCategoryList> =
new Map();
for (let i = 0; i < externalMarkers.categories.length; ++i) {
const cat = externalMarkers.categories[i];
let index = geckoProfile.meta.categories.findIndex(
Expand Down
Loading