Better performance metrics
Summary: Current metrics are deltas from an initial set timestamp. This works but is limiting or affecting the overall accuracy of them. The aim of this task is to replace the deltas with actual measurements for the operations. This way we can add/remove operations in between which will not create any impact of them. Reviewed By: LukeDefeo Differential Revision: D44026823 fbshipit-source-id: fd7d62c4eab86bab8239b44beecd5c133f6d11c7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6cc4705ae4
commit
5d0e0137d5
@@ -7,31 +7,31 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {PerfStatsEvent} from '../types';
|
import {PerformanceStatsEvent} from '../types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {DataSource, DataTable, DataTableColumn} from 'flipper-plugin';
|
import {DataSource, DataTable, DataTableColumn} from 'flipper-plugin';
|
||||||
|
|
||||||
export function PerfStats(props: {events: DataSource<PerfStatsEvent, number>}) {
|
export function PerfStats(props: {
|
||||||
|
events: DataSource<PerformanceStatsEvent, number>;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<DataTable<PerfStatsEvent> dataSource={props.events} columns={columns} />
|
<DataTable<PerformanceStatsEvent>
|
||||||
|
dataSource={props.events}
|
||||||
|
columns={columns}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDiff(start: number, end: number): string {
|
function formatDiff(ms: number): string {
|
||||||
const ms = end - start;
|
|
||||||
return `${ms.toFixed(0)}ms`;
|
return `${ms.toFixed(0)}ms`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: DataTableColumn<PerfStatsEvent>[] = [
|
const columns: DataTableColumn<PerformanceStatsEvent>[] = [
|
||||||
{
|
{
|
||||||
key: 'txId',
|
key: 'txId',
|
||||||
title: 'TXID',
|
title: 'TXID',
|
||||||
onRender: (row: PerfStatsEvent) => {
|
onRender: (row: PerformanceStatsEvent) => {
|
||||||
try {
|
return row.txId;
|
||||||
return new Date(row.txId).toISOString();
|
|
||||||
} catch {
|
|
||||||
return row.txId;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -45,53 +45,50 @@ const columns: DataTableColumn<PerfStatsEvent>[] = [
|
|||||||
{
|
{
|
||||||
key: 'start',
|
key: 'start',
|
||||||
title: 'Start',
|
title: 'Start',
|
||||||
onRender: (row: PerfStatsEvent) => {
|
onRender: (row: PerformanceStatsEvent) => {
|
||||||
return new Date(row.start).toISOString();
|
return new Date(row.start).toISOString();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'traversalComplete',
|
key: 'traversalMS',
|
||||||
title: 'Traversal time (Main thread)',
|
title: 'Traversal time (Main thread)',
|
||||||
onRender: (row: PerfStatsEvent) => {
|
onRender: (row: PerformanceStatsEvent) => {
|
||||||
return formatDiff(row.start, row.traversalComplete);
|
return formatDiff(row.traversalMS);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'snapshotComplete',
|
key: 'snapshotMS',
|
||||||
title: 'Snapshot time (Main thread)',
|
title: 'Snapshot time (Main thread)',
|
||||||
onRender: (row: PerfStatsEvent) => {
|
onRender: (row: PerformanceStatsEvent) => {
|
||||||
return formatDiff(row.traversalComplete, row.snapshotComplete);
|
return formatDiff(row.snapshotMS);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'queuingComplete',
|
key: 'queuingMS',
|
||||||
title: 'Queuing time',
|
title: 'Queuing time',
|
||||||
onRender: (row: PerfStatsEvent) => {
|
onRender: (row: PerformanceStatsEvent) => {
|
||||||
return formatDiff(row.snapshotComplete, row.queuingComplete);
|
return formatDiff(row.queuingMS);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'deferredComputationComplete',
|
key: 'deferredComputationMS',
|
||||||
title: 'Deferred processing time',
|
title: 'Deferred processing time',
|
||||||
onRender: (row: PerfStatsEvent) => {
|
onRender: (row: PerformanceStatsEvent) => {
|
||||||
return formatDiff(row.queuingComplete, row.deferredComputationComplete);
|
return formatDiff(row.deferredComputationMS);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'serializationComplete',
|
key: 'serializationMS',
|
||||||
title: 'Serialization time',
|
title: 'Serialization time',
|
||||||
onRender: (row: PerfStatsEvent) => {
|
onRender: (row: PerformanceStatsEvent) => {
|
||||||
return formatDiff(
|
return formatDiff(row.serializationMS);
|
||||||
row.deferredComputationComplete,
|
|
||||||
row.serializationComplete,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'socketComplete',
|
key: 'socketMS',
|
||||||
title: 'Socket send time',
|
title: 'Socket send time',
|
||||||
onRender: (row: PerfStatsEvent) => {
|
onRender: (row: PerformanceStatsEvent) => {
|
||||||
return formatDiff(row.serializationComplete, row.socketComplete);
|
return formatDiff(row.socketMS);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
FrameworkEventType,
|
FrameworkEventType,
|
||||||
Metadata,
|
Metadata,
|
||||||
MetadataId,
|
MetadataId,
|
||||||
PerfStatsEvent,
|
PerformanceStatsEvent,
|
||||||
Snapshot,
|
Snapshot,
|
||||||
UINode,
|
UINode,
|
||||||
} from './types';
|
} from './types';
|
||||||
@@ -73,11 +73,34 @@ export function plugin(client: PluginClient<Events>) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const perfEvents = createDataSource<PerfStatsEvent, 'txId'>([], {
|
const perfEvents = createDataSource<PerformanceStatsEvent, 'txId'>([], {
|
||||||
key: 'txId',
|
key: 'txId',
|
||||||
limit: 10 * 1024,
|
limit: 10 * 1024,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message handling below is a temporary measure for a couple of weeks until
|
||||||
|
* clients migrate to the newer message/format.
|
||||||
|
*/
|
||||||
client.onMessage('perfStats', (event) => {
|
client.onMessage('perfStats', (event) => {
|
||||||
|
const stat = {
|
||||||
|
txId: event.txId,
|
||||||
|
observerType: event.observerType,
|
||||||
|
nodesCount: event.nodesCount,
|
||||||
|
start: event.start,
|
||||||
|
traversalMS: event.traversalComplete - event.start,
|
||||||
|
snapshotMS: event.snapshotComplete - event.traversalComplete,
|
||||||
|
queuingMS: event.queuingComplete - event.snapshotComplete,
|
||||||
|
deferredComputationMS:
|
||||||
|
event.deferredComputationComplete - event.queuingComplete,
|
||||||
|
serializationMS:
|
||||||
|
event.serializationComplete - event.deferredComputationComplete,
|
||||||
|
socketMS: event.socketComplete - event.serializationComplete,
|
||||||
|
};
|
||||||
|
client.logger.track('performance', 'subtreeUpdate', stat, 'ui-debugger');
|
||||||
|
perfEvents.append(stat);
|
||||||
|
});
|
||||||
|
client.onMessage('performanceStats', (event) => {
|
||||||
client.logger.track('performance', 'subtreeUpdate', event, 'ui-debugger');
|
client.logger.track('performance', 'subtreeUpdate', event, 'ui-debugger');
|
||||||
perfEvents.append(event);
|
perfEvents.append(event);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export type Events = {
|
|||||||
subtreeUpdate: SubtreeUpdateEvent;
|
subtreeUpdate: SubtreeUpdateEvent;
|
||||||
coordinateUpdate: CoordinateUpdateEvent;
|
coordinateUpdate: CoordinateUpdateEvent;
|
||||||
perfStats: PerfStatsEvent;
|
perfStats: PerfStatsEvent;
|
||||||
|
performanceStats: PerformanceStatsEvent;
|
||||||
metadataUpdate: UpdateMetadataEvent;
|
metadataUpdate: UpdateMetadataEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -47,6 +48,10 @@ export type InitEvent = {
|
|||||||
frameworkEventMetadata?: FrameworkEventMetadata[];
|
frameworkEventMetadata?: FrameworkEventMetadata[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This performance event should not be used and soon will
|
||||||
|
* be removed. PerformanceStatsEvent should be used instead.
|
||||||
|
*/
|
||||||
export type PerfStatsEvent = {
|
export type PerfStatsEvent = {
|
||||||
txId: number;
|
txId: number;
|
||||||
observerType: string;
|
observerType: string;
|
||||||
@@ -60,6 +65,19 @@ export type PerfStatsEvent = {
|
|||||||
nodesCount: number;
|
nodesCount: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type PerformanceStatsEvent = {
|
||||||
|
txId: number;
|
||||||
|
observerType: string;
|
||||||
|
nodesCount: number;
|
||||||
|
start: number;
|
||||||
|
traversalMS: number;
|
||||||
|
snapshotMS: number;
|
||||||
|
queuingMS: number;
|
||||||
|
deferredComputationMS: number;
|
||||||
|
serializationMS: number;
|
||||||
|
socketMS: number;
|
||||||
|
};
|
||||||
|
|
||||||
export type UpdateMetadataEvent = {
|
export type UpdateMetadataEvent = {
|
||||||
attributeMetadata: Record<MetadataId, Metadata>;
|
attributeMetadata: Record<MetadataId, Metadata>;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user