Skip to content

Commit d39f686

Browse files
committed
console: name every worker at its core's limit in the Workers finding
A skew or pegged finding named only the busiest worker, so a second worker at its limit, and the object busying it, went unmentioned, and the bars marked one worker. - When several workers are at their limit short of skew, the finding is about all of them: "3 of 4 workers are at their core's limit", the least busy worker, and the objects taking the most of their time, instead of the busiest worker's lead by a tie-break. - An overloaded worker's finding names the other workers at their limit, with any object busying them other than the finding's. - The bars mark every worker at its limit. - A pegged worker's object gets the skew EXPLAIN, like the skew cause, only when the object leans on it.
1 parent 4972719 commit d39f686

7 files changed

Lines changed: 235 additions & 68 deletions

File tree

‎console/src/platform/clusters/ClusterPage/WorkerCpu/WorkerBars.test.tsx‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const renderBars = (props: Partial<WorkerBarsProps> = {}) =>
5656
width={800}
5757
measurement={SKEWED}
5858
picked={undefined}
59-
hotWorker={undefined}
59+
hotWorkers={undefined}
6060
selectedWorkerId={0}
6161
onSelectWorker={() => {}}
6262
replica={REPLICA}
@@ -162,14 +162,26 @@ describe("WorkerBars", () => {
162162

163163
it("colors the called-out worker apart from the others, under the verdict's name for it", async () => {
164164
await renderBars({
165-
hotWorker: { workerId: 0, label: "Worker at its core's limit" },
165+
hotWorkers: { workerIds: [0], label: "Worker at its core's limit" },
166166
});
167167

168168
expect(fills(barRects(0))).not.toEqual(fills(barRects(1)));
169169
expect(screen.getByText("Worker at its core's limit")).toBeInTheDocument();
170170
expect(screen.queryByText("Overloaded worker")).not.toBeInTheDocument();
171171
});
172172

173+
it("colors every called-out worker alike, apart from the rest", async () => {
174+
await renderBars({
175+
hotWorkers: { workerIds: [0, 2], label: "Workers at their core's limit" },
176+
});
177+
178+
expect(fills(barRects(2))).toEqual(fills(barRects(0)));
179+
expect(fills(barRects(2))).not.toEqual(fills(barRects(1)));
180+
expect(
181+
screen.getByText("Workers at their core's limit"),
182+
).toBeInTheDocument();
183+
});
184+
173185
it("colors every worker alike without an overloaded one", async () => {
174186
await renderBars();
175187

‎console/src/platform/clusters/ClusterPage/WorkerCpu/WorkerBars.tsx‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export interface WorkerBarsProps {
5454
measurement: Measurement;
5555
/** The object whose part of each worker's time is drawn darker. */
5656
picked: { name: string; perWorkerNs: number[] } | undefined;
57-
/** The worker to call out, with its legend label, from `markedWorker`. */
58-
hotWorker: { workerId: number; label: string } | undefined;
57+
/** The workers to call out, with their legend label, from `markedWorkers`. */
58+
hotWorkers: { workerIds: number[]; label: string } | undefined;
5959
/** The worker whose time the objects table breaks down. */
6060
selectedWorkerId: number;
6161
onSelectWorker: (workerId: number) => void;
@@ -78,7 +78,7 @@ interface BarsProps {
7878
busy: number[];
7979
/** Each worker's busy share that went to the picked object. */
8080
pickedBusy: number[];
81-
hotWorkerId: number | undefined;
81+
hotWorkerIds: Set<number>;
8282
labeled: Set<number>;
8383
othersAverage: number | undefined;
8484
}
@@ -92,7 +92,7 @@ const BarMarks = React.memo(
9292
slots,
9393
busy,
9494
pickedBusy,
95-
hotWorkerId,
95+
hotWorkerIds,
9696
labeled,
9797
othersAverage,
9898
}: BarsProps) => {
@@ -103,7 +103,7 @@ const BarMarks = React.memo(
103103
<g pointerEvents="none">
104104
<PercentAxis layout={layout} yScale={yScale} ticks={PERCENT_TICKS} />
105105
{busy.map((fraction, workerId) => {
106-
const isHot = workerId === hotWorkerId;
106+
const isHot = hotWorkerIds.has(workerId);
107107
const x = slots.x(workerId) + (slots.slot - slots.barWidth) / 2;
108108
const top = yScale(fraction * 100);
109109
const pickedTop = yScale(pickedBusy[workerId] * 100);
@@ -166,13 +166,19 @@ export const WorkerBars = ({
166166
width,
167167
measurement,
168168
picked,
169-
hotWorker,
169+
hotWorkers,
170170
selectedWorkerId,
171171
onSelectWorker,
172172
replica,
173173
}: WorkerBarsProps) => {
174174
const { colors, fonts } = useTheme<MaterializeTheme>();
175-
const hotWorkerId = hotWorker?.workerId;
175+
// Keyed by the ids, since the caller builds `hotWorkers` on every render.
176+
const hotWorkerIdsKey = hotWorkers?.workerIds.join(",") ?? "";
177+
const hotWorkerIds = React.useMemo(
178+
() =>
179+
new Set(hotWorkerIdsKey ? hotWorkerIdsKey.split(",").map(Number) : []),
180+
[hotWorkerIdsKey],
181+
);
176182
const {
177183
tooltipData: hoveredWorkerId,
178184
tooltipLeft,
@@ -251,11 +257,9 @@ export const WorkerBars = ({
251257
}, [workerCount, plotLeft, plotRight, processCount, perProcess]);
252258

253259
// These always get a label, and the spaced labels near them give way.
254-
const labeledAlways = [
255-
busiest?.workerId,
256-
hotWorkerId,
257-
selectedWorkerId,
258-
].filter((workerId): workerId is number => workerId !== undefined);
260+
const labeledAlways = [busiest?.workerId, selectedWorkerId].filter(
261+
(workerId): workerId is number => workerId !== undefined,
262+
);
259263
const labeledAlwaysKey = labeledAlways.join(",");
260264
const valueLabeled = React.useMemo(
261265
() => new Set(labeledAlwaysKey.split(",").map(Number)),
@@ -324,10 +328,10 @@ export const WorkerBars = ({
324328
color: barColors.rest,
325329
variant: "square",
326330
},
327-
...(hotWorker
331+
...(hotWorkers
328332
? [
329333
{
330-
label: hotWorker.label,
334+
label: hotWorkers.label,
331335
color: barColors.hotPicked,
332336
variant: "square" as const,
333337
},
@@ -378,7 +382,7 @@ export const WorkerBars = ({
378382
slots={slots}
379383
busy={busy}
380384
pickedBusy={pickedBusy}
381-
hotWorkerId={hotWorkerId}
385+
hotWorkerIds={hotWorkerIds}
382386
labeled={valueLabeled}
383387
othersAverage={othersAverage}
384388
/>
@@ -419,7 +423,7 @@ export const WorkerBars = ({
419423
(labeled) => Math.abs(labeled - workerId) >= labelEvery,
420424
));
421425
if (!show) return null;
422-
const isHot = workerId === hotWorkerId;
426+
const isHot = hotWorkerIds.has(workerId);
423427
const isSelected = workerId === selectedWorkerId;
424428
return (
425429
<text

‎console/src/platform/clusters/ClusterPage/WorkerCpu/WorkerCpuPanel.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import {
5353
cpuVerdict,
5454
isPooledRow,
5555
isSkewVerdict,
56-
markedWorker,
56+
markedWorkers,
5757
Measurement,
5858
MEASUREMENT_MS,
5959
objectCpuRows,
@@ -526,7 +526,7 @@ export const WorkerCpuPanel = ({
526526
width={bars.width}
527527
measurement={measurement}
528528
picked={picked}
529-
hotWorker={markedWorker(verdict)}
529+
hotWorkers={markedWorkers(verdict)}
530530
selectedWorkerId={selectedWorkerId}
531531
onSelectWorker={onSelectWorker}
532532
replica={replica}

‎console/src/platform/clusters/ClusterPage/WorkerCpu/WorkerCpuVerdict.test.tsx‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,60 @@ describe("Verdict", () => {
839839
expect(screen.queryByText(/spread evenly/)).not.toBeInTheDocument();
840840
});
841841

842+
it("leads with the workers at their limit, and the objects busying them, when none leads by SKEW_RATIO", async () => {
843+
await renderVerdict({
844+
measurement: buildMeasurement([1, 1, 0.3, 0.3], {
845+
u5: [50, 2, 5, 5],
846+
u6: [2, 50, 5, 5],
847+
}),
848+
});
849+
850+
expect(heading("2 of 4 workers are at their core's limit")).toBeVisible();
851+
expect(
852+
screen.getByText(
853+
"w0 and w1 are at their core's limit, and the least busy, w3, is at 30%. orders_idx and payments_mv take the most of their time. Work routed to them waits, though none leads the others by the 2× that counts as skew.",
854+
),
855+
).toBeVisible();
856+
expect(screen.queryByText(/their work\./)).not.toBeInTheDocument();
857+
});
858+
859+
it("names the object that busies every worker at its limit, without a skew EXPLAIN for evenly spread work", async () => {
860+
await renderVerdict({
861+
measurement: buildMeasurement([1, 1, 1, 0.3], {
862+
u5: [50, 50, 50, 15],
863+
}),
864+
});
865+
866+
expect(
867+
heading(
868+
"3 of 4 workers are at their core's limit, and most of their time goes to orders_idx",
869+
),
870+
).toBeVisible();
871+
expect(
872+
screen.getByText(
873+
"w0, w1, and w2 are at their core's limit, and the least busy, w3, is at 30%. Work routed to them waits, though none leads the others by the 2× that counts as skew.",
874+
),
875+
).toBeVisible();
876+
expect(screen.queryByText(/EXPLAIN ANALYZE/)).not.toBeInTheDocument();
877+
expect(screen.queryByText(/hot key|cross join/)).not.toBeInTheDocument();
878+
});
879+
880+
it("names another overloaded worker beside the one the finding is about", async () => {
881+
await renderVerdict({
882+
measurement: buildMeasurement([1, 1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2], {
883+
u5: [50, 2, 10, 10, 10, 10, 10, 10],
884+
u6: [2, 50, 1, 1, 1, 1, 1, 1],
885+
}),
886+
});
887+
888+
expect(heading(/^w0 is overloaded/)).toBeVisible();
889+
expect(
890+
screen.getByText(
891+
/w1 is also at its core's limit, and payments_mv takes the most of its time\./,
892+
),
893+
).toBeVisible();
894+
});
895+
842896
it("says a pegged worker at 1.9× and at 2.1× is at its limit, without the story flipping to even", async () => {
843897
await renderVerdict({
844898
measurement: buildMeasurement([0.95, 0.5, 0.5, 0.5]),

0 commit comments

Comments
 (0)