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
78 changes: 51 additions & 27 deletions report/src/components/ChartGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,61 @@ function resolveMetricKey(
return primaryKey;
}

const GROUP_ORDER = ["Latency", "Chain", "Throughput"];

const ChartGrid: React.FC<ProvidedProps> = ({ data, role }: ProvidedProps) => {
const chartData = data.flatMap((s) => s.data);
const thresholds = data[0]?.thresholds;

const visibleCharts = SORTED_CHART_CONFIG.flatMap(([metricKey, config]) => {
const resolvedKey = resolveMetricKey(data, metricKey, config.aliases);
const executionMetrics = chartData
.map((d) => d.ExecutionMetrics[resolvedKey])
.filter((v) => v !== undefined);
if (executionMetrics.length === 0) return [];
return [{ metricKey, resolvedKey, config }];
});

const grouped = visibleCharts.reduce<Record<string, typeof visibleCharts>>(
(acc, item) => {
const group = item.config.group ?? "Other";
if (!acc[group]) acc[group] = [];
acc[group].push(item);
return acc;
},
{},
);

const groupKeys = [
...GROUP_ORDER.filter((g) => grouped[g]),
...Object.keys(grouped).filter((g) => !GROUP_ORDER.includes(g)),
];

return (
<div className="charts-container">
{SORTED_CHART_CONFIG.map(([metricKey, config]) => {
const resolvedKey = resolveMetricKey(data, metricKey, config.aliases);
const thresholdKey = role ? `${role}/${metricKey}` : null;
const chartData = data.flatMap((s) => s.data);
const thresholds = data[0]?.thresholds;
const executionMetrics = chartData
.map((d) => d.ExecutionMetrics[resolvedKey])
.filter((v) => v !== undefined);

if (executionMetrics.length === 0) {
return null;
}

const chartProps = {
series: data,
metricKey: resolvedKey,
title: config.title,
description: config.description,
unit: config.unit,
thresholds,
};

return (
<div key={metricKey} className="chart-container">
<LineChart thresholdKey={thresholdKey} {...chartProps} />
{groupKeys.map((group) => (
<div key={group} className="metric-group">
<h2 className="metric-group-title">{group}</h2>
<div className="metric-group-charts">
{grouped[group].map(({ metricKey, resolvedKey, config }) => {
const thresholdKey = role ? `${role}/${metricKey}` : null;
return (
<div key={metricKey} className="chart-container">
<LineChart
thresholdKey={thresholdKey}
series={data}
metricKey={resolvedKey}
title={config.title}
description={config.description}
unit={config.unit}
thresholds={thresholds}
/>
</div>
);
})}
</div>
);
})}
</div>
))}
</div>
);
};
Expand Down
20 changes: 20 additions & 0 deletions report/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,23 @@ body {
.filter-select {
@apply p-2 rounded border border-gray-300 mt-1 bg-white;
}

/* Metric grouping */
.metric-group {
margin-bottom: 2rem;
}

.metric-group-title {
font-size: 1.25rem;
font-weight: 600;
color: #374151;
padding: 0.5rem 0;
margin-bottom: 1rem;
border-bottom: 2px solid #e5e7eb;
}

.metric-group-charts {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
gap: 1rem;
}
17 changes: 17 additions & 0 deletions report/src/metricDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,35 @@ import { ChartConfig } from "./types"; // Import from types.ts
export const CHART_CONFIG = {
"latency/send_txs": {
type: "line",
group: "Latency",
title: "Send Txs",
description: "Shows the median time taken for send txs",
unit: "ns",
},
"latency/update_fork_choice": {
type: "line",
group: "Latency",
title: "Update Fork Choice",
description: "Shows the median time taken for update fork choice",
unit: "ns",
},
"latency/get_payload": {
type: "line",
group: "Latency",
title: "Get Payload",
description: "Shows the median time taken for get payload",
unit: "ns",
},
"latency/new_payload": {
type: "line",
group: "Latency",
title: "New Payload",
description: "Shows the median time taken for new payload",
unit: "ns",
},
"chain/inserts.50-percentile": {
type: "line",
group: "Chain",
title: "Inserts",
description:
"Shows the median time taken for block processing and insertion (end-to-end)",
Expand All @@ -41,6 +46,7 @@ export const CHART_CONFIG = {
},
"chain/storage/reads.50-percentile": {
type: "line",
group: "Chain",
title: "Storage Reads",
description:
"Shows the median time taken for storage reads during block processing",
Expand All @@ -56,27 +62,31 @@ export const CHART_CONFIG = {
},
"chain/account/updates.50-percentile": {
type: "line",
group: "Chain",
title: "Account Updates",
description:
"Shows the median time taken for updating accounts during state validation",
unit: "ns",
},
"chain/account/hashes.50-percentile": {
type: "line",
group: "Chain",
title: "Account Hashes",
description:
"Shows the median time taken for hashing accounts during state validation",
unit: "ns",
},
"chain/storage/updates.50-percentile": {
type: "line",
group: "Chain",
title: "Storage Updates", // Renamed from 'Storage Writes' for consistency
description:
"Shows the median time taken for updating storage during state validation",
unit: "ns",
},
"chain/validation.50-percentile": {
type: "line",
group: "Chain",
title: "Validation (Misc)",
description:
"Shows the median time taken for miscellaneous block validation steps",
Expand All @@ -92,46 +102,53 @@ export const CHART_CONFIG = {
},
"chain/write.50-percentile": {
type: "line",
group: "Chain",
title: "Write (Misc)",
description:
"Shows the median time taken for miscellaneous block write operations (excluding commits)",
unit: "ns",
},
"chain/account/commits.50-percentile": {
type: "line",
group: "Chain",
title: "Account Commits",
description:
"Shows the median time taken for committing account changes to the DB",
unit: "ns",
},
"chain/storage/commits.50-percentile": {
type: "line",
group: "Chain",
title: "Storage Commits",
description:
"Shows the median time taken for committing storage changes to the DB",
unit: "ns",
},
"chain/snapshot/commits.50-percentile": {
type: "line",
group: "Chain",
title: "Snapshot Commits",
description:
"Shows the median time taken for committing snapshot changes to the DB",
unit: "ns",
},
"chain/triedb/commits.50-percentile": {
type: "line",
group: "Chain",
title: "TrieDB Commits",
description: "Shows the median time taken for committing TrieDB changes",
unit: "ns",
},
"transactions/per_block": {
type: "line",
group: "Throughput",
title: "Transactions per Block",
description: "Shows the number of transactions per block",
unit: "count",
},
"gas/per_block": {
type: "line",
group: "Throughput",
title: "Gas Per Block",
description: "Shows the median gas per block",
unit: "gas",
Expand Down
1 change: 1 addition & 0 deletions report/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface ChartConfig {
title: string;
description: string;
type: "line";
group?: "Latency" | "Chain" | "Throughput";
unit?:
| "ns"
| "us"
Expand Down