Skip to content

Commit e755f55

Browse files
feat: add priority to tiles table
1 parent 6effba0 commit e755f55

5 files changed

Lines changed: 126 additions & 8 deletions

File tree

src/api/entities.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ export const liveTilePrimaryMetricSchema = z.object({
225225
tile_primary_metric: tilePrimaryMetricSchema,
226226
});
227227

228+
export const prioritySchema = z.enum([
229+
"floating",
230+
"startup",
231+
"normal",
232+
"critical",
233+
]);
234+
export const PriorityEnum = prioritySchema.enum;
235+
228236
export const tileMetricsSchema = z.object({
229237
timers: z.array(z.array(z.number()).nullable()),
230238
sched_timers: z.array(z.array(z.number()).nullable()),
@@ -236,6 +244,7 @@ export const tileMetricsSchema = z.object({
236244
last_cpu: z.array(z.number().nullable()),
237245
minflt: z.array(z.number().nullable()),
238246
majflt: z.array(z.number().nullable()),
247+
priority: z.array(prioritySchema).optional(),
239248
});
240249

241250
export const tileTimerSchema = z.object({

src/api/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import type {
6767
peerUpdateInfoSchema,
6868
liveProgramCacheSchema,
6969
slotCaughtUpSchema,
70+
prioritySchema,
7071
} from "./entities";
7172

7273
export type Client = z.infer<typeof clientSchema>;
@@ -121,6 +122,7 @@ export type LiveTilePrimaryMetric = z.infer<typeof liveTilePrimaryMetricSchema>;
121122
export type TilePrimaryMetric = z.infer<typeof tilePrimaryMetricSchema>;
122123

123124
export type TileMetrics = z.infer<typeof tileMetricsSchema>;
125+
export type Priority = z.infer<typeof prioritySchema>;
124126

125127
export type TxnWaterfallIn = z.infer<typeof txnWaterfallInSchema>;
126128
export type TxnWaterfallOut = z.infer<typeof txnWaterfallOutSchema>;

src/features/Overview/LiveTileMetrics/consts.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const metricGroups: {
4545
uniqueName: "Name",
4646
description:
4747
"The name and index of each tile. A tile represents a sandboxed process or individual thread that communicates with other tiles using message passing queues.",
48-
headerColWidth: 70,
48+
headerColWidth: 85,
4949
},
5050
],
5151
},
@@ -60,9 +60,16 @@ export const metricGroups: {
6060
headerColAlign: "right",
6161
},
6262
{
63-
uniqueName: "Heartbeat",
63+
uniqueName: "Hbt",
6464
description:
6565
"Liveness indicator based on a periodic heartbeat timestamp written by tiles to a chunk of shared memory.",
66+
headerColWidth: 50,
67+
headerColAlign: "right",
68+
},
69+
{
70+
uniqueName: "Priority",
71+
description:
72+
"The tile's scheduling priority. Floating tiles run on the Linux scheduler; others are pinned to a core. Startup tiles go away shortly after boot. Critical tiles never share a hyperthread pair.",
6673
headerColWidth: 70,
6774
headerColAlign: "right",
6875
},
@@ -89,12 +96,12 @@ export const metricGroups: {
8996
uniqueName: "Utilization",
9097
description:
9198
"Visualized the percentage of the tile's CPU time spent doing useful work. Time spent in a context switch is not included.",
92-
headerColWidth: 150,
99+
headerColWidth: 140,
93100
},
94101
{
95102
uniqueName: "History (1m)",
96103
description: "A historical, low-pass-filtered view of CPU utilization.",
97-
headerColWidth: 150,
104+
headerColWidth: 140,
98105
},
99106
],
100107
},

src/features/Overview/LiveTileMetrics/index.tsx

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import styles from "./liveTileMetrics.module.css";
1212
import { Bars } from "../../StartupProgress/Firedancer/Bars";
1313
import TileSparkLine from "../SlotPerformance/TileSparkLine";
1414
import { headerGap } from "../../Gossip/consts";
15-
import type { Tile, TileMetrics } from "../../../api/types";
15+
import type { Priority, Tile, TileMetrics } from "../../../api/types";
1616
import clsx from "clsx";
1717
import {
1818
useHarmonicIntervalFn,
@@ -32,6 +32,7 @@ import { isEqual } from "lodash";
3232
import type { CellProps } from "@radix-ui/themes/components/table";
3333
import TableDescriptionDialog from "./TableDescriptionDialog";
3434
import { pinnedGroups, pinnedTableWidth, unpinnedGroups } from "./consts";
35+
import { PriorityEnum } from "../../../api/entities";
3536

3637
const chartHeight = 18;
3738

@@ -107,7 +108,12 @@ function LiveMetricsTable({ isPinned }: LiveMetricsTableProps) {
107108
[styles.rightBorder]: isPinned || i !== groups.length - 1,
108109
})}
109110
>
110-
{group.name}
111+
{group.name || (
112+
<PriorityCountCell
113+
priority={liveTileMetrics.priority}
114+
alive={liveTileMetrics.alive}
115+
/>
116+
)}
111117
</Table.ColumnHeaderCell>
112118
))}
113119
</Table.Row>
@@ -182,8 +188,13 @@ function TableRow({ tile, liveTileMetrics, idx, isPinned }: TableRowProps) {
182188
if (!timers) return;
183189

184190
if (isPinned) {
191+
const isFloating =
192+
(liveTileMetrics.priority?.[idx] ??
193+
prevLiveTileMetricsIdx?.priority?.[idx]) === PriorityEnum.floating;
185194
return (
186-
<Table.Row className={styles.dataRow}>
195+
<Table.Row
196+
className={clsx(styles.dataRow, { [styles.floating]: isFloating })}
197+
>
187198
<Table.Cell className={styles.rightBorder}>
188199
{tile.kind}:{tile.kind_id}
189200
</Table.Cell>
@@ -202,6 +213,13 @@ function TableRow({ tile, liveTileMetrics, idx, isPinned }: TableRowProps) {
202213
);
203214
}
204215

216+
const priorityLabels: Record<Priority, string> = {
217+
floating: "Floating",
218+
startup: "Startup",
219+
normal: "Pinned",
220+
critical: "Critical",
221+
};
222+
205223
interface DataRowProps {
206224
alive: number | null | undefined;
207225
timers: number[];
@@ -239,6 +257,8 @@ function DataRow({
239257
liveTileMetrics.minflt[idx] ?? prevLiveTileMetricsIdx?.minflt[idx];
240258
const majflt =
241259
liveTileMetrics.majflt[idx] ?? prevLiveTileMetricsIdx?.majflt[idx];
260+
const priority =
261+
liveTileMetrics.priority?.[idx] ?? prevLiveTileMetricsIdx?.priority?.[idx];
242262

243263
const prevNivcsw = usePrevious(nivcsw);
244264
const prevNvcsw = usePrevious(nvcsw);
@@ -254,14 +274,26 @@ function DataRow({
254274
const workPct = timers[3] + timers[4] + timers[7];
255275

256276
return (
257-
<Table.Row className={styles.dataRow}>
277+
<Table.Row
278+
className={clsx(styles.dataRow, {
279+
[styles.floating]: priority === PriorityEnum.floating,
280+
})}
281+
>
258282
<Table.Cell align="right">{cpu}</Table.Cell>
259283
<Table.Cell
260284
className={clsx({ [styles.green]: alive, [styles.red]: !alive })}
261285
align="right"
262286
>
263287
{alive ? "Live" : "Dead"}
264288
</Table.Cell>
289+
<Table.Cell
290+
align="right"
291+
className={clsx({
292+
[styles.critical]: priority === PriorityEnum.critical,
293+
})}
294+
>
295+
{priority ? priorityLabels[priority] : "-"}
296+
</Table.Cell>
265297
<Table.Cell
266298
align="right"
267299
className={clsx({ [styles.red]: inBackpressure })}
@@ -434,3 +466,51 @@ const MUtilization = memo(function Utilization({ idx }: UtilizationProps) {
434466
</>
435467
);
436468
});
469+
470+
interface PriorityCountCellProps {
471+
priority: TileMetrics["priority"];
472+
alive: TileMetrics["alive"];
473+
}
474+
function PriorityCountCell({ priority, alive }: PriorityCountCellProps) {
475+
const counts = useMemo(() => {
476+
if (!priority) return null;
477+
let critical = 0;
478+
let pinned = 0;
479+
let floating = 0;
480+
for (let i = 0; i < priority.length; i++) {
481+
// A shutdown tile is not displayed in the table, so exclude it from the count
482+
const isShutdown = alive[i] === 2;
483+
if (isShutdown) continue;
484+
485+
switch (priority[i]) {
486+
case PriorityEnum.critical:
487+
critical++;
488+
break;
489+
case PriorityEnum.normal:
490+
case PriorityEnum.startup:
491+
pinned++;
492+
break;
493+
case PriorityEnum.floating:
494+
floating++;
495+
break;
496+
}
497+
}
498+
return { critical, pinned, floating };
499+
}, [alive, priority]);
500+
501+
if (!counts) return;
502+
503+
return (
504+
<Flex className={styles.priorityCount} gap="5px" justify="between">
505+
<Text>
506+
{counts.critical} <Text className={styles.critical}>C</Text>
507+
</Text>
508+
<Text>
509+
{counts.pinned} <Text className={styles.pinned}>P</Text>
510+
</Text>
511+
<Text>
512+
{counts.floating} <Text className={styles.floating}>F</Text>
513+
</Text>
514+
</Flex>
515+
);
516+
}

src/features/Overview/LiveTileMetrics/liveTileMetrics.module.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
table-layout: fixed;
1818

1919
.data-row {
20+
&.floating {
21+
filter: brightness(0.55);
22+
}
23+
2024
.green {
2125
color: var(--green-9);
2226
}
@@ -68,6 +72,10 @@
6872
color: var(--high-increment-text-color);
6973
}
7074
}
75+
76+
&.critical {
77+
color: var(--gold-10);
78+
}
7179
}
7280
}
7381

@@ -92,5 +100,17 @@
92100
th {
93101
box-shadow: none;
94102
}
103+
104+
.priority-count {
105+
.critical {
106+
color: var(--gold-10);
107+
}
108+
.pinned {
109+
color: var(--table-body-color);
110+
}
111+
.floating {
112+
color: var(--gray-7);
113+
}
114+
}
95115
}
96116
}

0 commit comments

Comments
 (0)