Skip to content

Commit 83064c4

Browse files
authored
Maxoutissue (#6229)
# Add customized highlight option for BranchAndCommitPicker Add customized highlight option for commit select #6175 # Details - add filename as part of the query for Commit - filter and highlight commits based on the selected key word. - add info icon present highlight section's details # Other Options (can be future) define a dropdown to filter multiple keys to highlight ![image](https://github.com/user-attachments/assets/452211aa-df0b-420d-9847-ac80526ec887) ## Demo Tooltip to indicate the highlight reason: ![image](https://github.com/user-attachments/assets/683d035c-cadf-4ca4-bc49-e0a78d69815a) Gif for the action ![Jan-28-2025 14-33-14](https://github.com/user-attachments/assets/bdded1e1-7545-4a77-ac05-bb61b385946e)
1 parent b1bdc33 commit 83064c4

File tree

6 files changed

+176
-4
lines changed

6 files changed

+176
-4
lines changed

torchci/clickhouse_queries/compilers_benchmark_performance_branches/query.sql

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ SELECT
44
DISTINCT w.head_branch AS head_branch,
55
w.head_sha,
66
w.id,
7+
p.filename,
78
toStartOfDay(fromUnixTimestamp64Milli(p.timestamp)) AS event_time
89
FROM
910
benchmark.inductor_torch_dynamo_perf_stats p

torchci/components/benchmark/BranchAndCommitPicker.tsx

+48-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1+
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
12
import {
23
FormControl,
34
InputLabel,
45
MenuItem,
56
Select,
67
SelectChangeEvent,
78
Skeleton,
9+
Tooltip,
810
} from "@mui/material";
911
import { MAIN_BRANCH, SHA_DISPLAY_LENGTH } from "components/benchmark/common";
1012
import dayjs from "dayjs";
1113
import { fetcher } from "lib/GeneralUtils";
1214
import { useEffect } from "react";
1315
import useSWR from "swr";
16+
import {
17+
DEFAULT_HIGHLIGHT_MENU_ITEM_COLOR,
18+
getMatchedFilters,
19+
HighlightMenuItem,
20+
isCommitHighlight,
21+
isCommitStringHighlight,
22+
} from "./HighlightMenu";
1423

1524
// Keep the mapping from workflow ID to commit, so that we can use it to
1625
// zoom in and out of the graph. NB: this is to avoid sending commit sha
@@ -20,16 +29,28 @@ import useSWR from "swr";
2029
export const COMMIT_TO_WORKFLOW_ID: { [k: string]: number } = {};
2130
export const WORKFLOW_ID_TO_COMMIT: { [k: number]: string } = {};
2231

32+
interface HighlightConfig {
33+
keys?: string[];
34+
highlightColor?: string;
35+
}
36+
2337
function groupCommitByBranch(data: any) {
2438
const dedups: { [k: string]: Set<string> } = {};
2539
const branches: { [k: string]: any[] } = {};
40+
2641
data.forEach((r: any) => {
2742
const b = r.head_branch;
2843
if (!(b in branches)) {
2944
branches[b] = [];
3045
dedups[b] = new Set<string>();
3146
}
47+
3248
if (dedups[b].has(r.head_sha)) {
49+
if (r.filename) {
50+
branches[b]
51+
?.find((c: any) => c.head_sha === r.head_sha)
52+
.filenames.push(r.filename);
53+
}
3354
return;
3455
}
3556

@@ -38,10 +59,12 @@ function groupCommitByBranch(data: any) {
3859
event_time: r.event_time,
3960
// This is used to sort the list of branches to show the main branch first
4061
display_priority: r.head_branch === MAIN_BRANCH ? 99 : 1,
62+
// store list of config files for the commit, this is used to highlight
63+
filenames: r.filename ? [r.filename] : [],
64+
id: r.id,
4165
});
4266
dedups[b].add(r.head_sha);
4367
});
44-
4568
return branches;
4669
}
4770

@@ -55,6 +78,7 @@ export function BranchAndCommitPicker({
5578
titlePrefix,
5679
fallbackIndex,
5780
timeRange,
81+
highlightConfig,
5882
}: {
5983
queryName: string;
6084
queryParams: { [k: string]: any };
@@ -65,6 +89,7 @@ export function BranchAndCommitPicker({
6589
titlePrefix: string;
6690
fallbackIndex: number;
6791
timeRange: any;
92+
highlightConfig?: HighlightConfig;
6893
}) {
6994
const url = `/api/clickhouse/${queryName}?parameters=${encodeURIComponent(
7095
JSON.stringify(queryParams)
@@ -160,7 +185,6 @@ export function BranchAndCommitPicker({
160185
))}
161186
</Select>
162187
</FormControl>
163-
164188
<FormControl>
165189
<InputLabel id={`commit-picker-input-label-${commit}`}>
166190
{titlePrefix} Commit
@@ -171,12 +195,32 @@ export function BranchAndCommitPicker({
171195
labelId={`commit-picker-select-label-${commit}`}
172196
onChange={handleCommitChange}
173197
id={`commit-picker-select-${commit}`}
198+
sx={{
199+
...(isCommitStringHighlight(
200+
commit,
201+
branches[branch],
202+
highlightConfig?.keys
203+
) && { backgroundColor: DEFAULT_HIGHLIGHT_MENU_ITEM_COLOR }),
204+
}}
174205
>
175206
{branches[branch].map((r: any) => (
176-
<MenuItem key={r.head_sha} value={r.head_sha}>
207+
<HighlightMenuItem
208+
key={r.head_sha}
209+
value={r.head_sha}
210+
condition={isCommitHighlight(highlightConfig?.keys, r)}
211+
customColor={highlightConfig?.highlightColor}
212+
>
177213
{r.head_sha.substring(0, SHA_DISPLAY_LENGTH)} (
178214
{dayjs(r.event_time).format("YYYY/MM/DD")})
179-
</MenuItem>
215+
{isCommitHighlight(highlightConfig?.keys, r) && (
216+
<Tooltip
217+
id="button-report"
218+
title={getMatchedFilters(highlightConfig?.keys, r).join(",")}
219+
>
220+
<InfoOutlinedIcon />
221+
</Tooltip>
222+
)}
223+
</HighlightMenuItem>
180224
))}
181225
</Select>
182226
</FormControl>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { MenuItem } from "@mui/material";
2+
3+
interface HighlightMenuItemProps extends React.ComponentProps<typeof MenuItem> {
4+
condition: boolean;
5+
customColor?: string;
6+
}
7+
8+
export const DEFAULT_HIGHLIGHT_MENU_ITEM_COLOR = "yellow";
9+
10+
export const HighlightMenuItem = ({
11+
condition,
12+
children,
13+
customColor = DEFAULT_HIGHLIGHT_MENU_ITEM_COLOR,
14+
...props
15+
}: HighlightMenuItemProps) => {
16+
const highlightStyle = {
17+
backgroundColor: customColor
18+
? customColor
19+
: DEFAULT_HIGHLIGHT_MENU_ITEM_COLOR,
20+
};
21+
return (
22+
<MenuItem
23+
{...props}
24+
sx={{
25+
...(condition && highlightStyle),
26+
}}
27+
>
28+
{children}
29+
</MenuItem>
30+
);
31+
};
32+
33+
export function isCommitStringHighlight(
34+
commit: string,
35+
commits: any[],
36+
filenameFilterList: string[] | undefined
37+
) {
38+
const matchedCommit = commits.find((c: any) => c.head_sha === commit);
39+
if (!matchedCommit) {
40+
return false;
41+
}
42+
return isCommitHighlight(filenameFilterList, matchedCommit);
43+
}
44+
45+
/**
46+
* isCommitHighlight returns true if the commit's filenames list contains all filter names from filenameFilterList.
47+
* @param filenameFilterList
48+
* @param commit
49+
* @returns
50+
*/
51+
export function isCommitHighlight(
52+
filenameFilterList: string[] | undefined,
53+
commit: any
54+
) {
55+
if (filenameFilterList === undefined || filenameFilterList.length == 0) {
56+
return false;
57+
}
58+
59+
if (!commit || !commit.filenames) {
60+
return false;
61+
}
62+
return isStringMatchedAll(filenameFilterList, commit.filenames.join(","));
63+
}
64+
65+
/**
66+
* getMatchedFilters return all matched filtername in commit.filename list.
67+
* @param filenameFilterList
68+
* @param commit
69+
* @returns
70+
*/
71+
export function getMatchedFilters(
72+
filenameFilterList: string[] | undefined,
73+
commit: any
74+
) {
75+
if (filenameFilterList === undefined || filenameFilterList.length == 0) {
76+
return [];
77+
}
78+
79+
if (!commit || !commit.filenames) {
80+
return [];
81+
}
82+
return getMatchedList(commit.filenames.join(","), filenameFilterList);
83+
}
84+
85+
function getMatchedList(text: string, substrings: string[]): string[] {
86+
let matched = [];
87+
for (const substring of substrings) {
88+
if (text.includes(substring)) {
89+
matched.push(substring);
90+
}
91+
}
92+
return matched;
93+
}
94+
95+
function isStringMatchedAll(substrings: string[], text: string) {
96+
return substrings.every((substring) => text.includes(substring));
97+
}

torchci/components/benchmark/compilers/common.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,9 @@ export const DISPLAY_NAMES_TO_WORKFLOW_NAMES: { [k: string]: string } = {
7676
rocm: "inductor-perf-nightly-rocm",
7777
mps: "inductor-perf-nightly-macos",
7878
};
79+
80+
export const DEFAULT_HIGHLIGHT_KEY = "none";
81+
export const DISPLAY_KEYS_TO_HIGHLIGHT: { [k: string]: string } = {
82+
None: DEFAULT_HIGHLIGHT_KEY,
83+
Max_autotune: "max_autotune",
84+
};

torchci/lib/clickhouse.ts

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function getClickhouseClient() {
1717
password: process.env.CLICKHOUSE_HUD_USER_PASSWORD ?? "",
1818
});
1919
}
20+
//
2021

2122
export function getClickhouseClientWritable() {
2223
return createClient({

torchci/pages/benchmark/compilers.tsx

+23
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
import { BenchmarkLogs } from "components/benchmark/compilers/BenchmarkLogs";
1010
import {
1111
DEFAULT_DEVICE_NAME,
12+
DEFAULT_HIGHLIGHT_KEY,
13+
DISPLAY_KEYS_TO_HIGHLIGHT,
1214
DISPLAY_NAMES_TO_DEVICE_NAMES,
1315
DISPLAY_NAMES_TO_WORKFLOW_NAMES,
1416
DTYPES,
@@ -34,6 +36,10 @@ import { useEffect, useState } from "react";
3436
import useSWR from "swr";
3537
import { COMPILER_SUITES_MAP } from "../../lib/benchmark/compliers/CompilerSuites";
3638
import { TimeRangePicker } from "../metrics";
39+
const HardCodedHightlightConfig = {
40+
keys: ["max_autotune"],
41+
highlightColor: "yellow",
42+
};
3743

3844
function Report({
3945
queryParams,
@@ -172,6 +178,9 @@ export default function Page() {
172178
const [rCommit, setRCommit] = useState<string>("");
173179
const [baseUrl, setBaseUrl] = useState<string>("");
174180
const [deviceName, setDeviceName] = useState<string>(DEFAULT_DEVICE_NAME);
181+
const [highlightKey, setHighlightKey] = useState<string>(
182+
DEFAULT_HIGHLIGHT_KEY
183+
);
175184

176185
// Set the dropdown value what is in the param
177186
useEffect(() => {
@@ -274,6 +283,12 @@ export default function Page() {
274283
/>
275284
</Stack>
276285
<Stack direction="row" spacing={2} sx={{ mb: 2 }}>
286+
<DTypePicker
287+
dtype={highlightKey}
288+
setDType={setHighlightKey}
289+
dtypes={Object.values(DISPLAY_KEYS_TO_HIGHLIGHT)}
290+
label={"Highlight"}
291+
></DTypePicker>
277292
<TimeRangePicker
278293
startTime={startTime}
279294
setStartTime={setStartTime}
@@ -310,6 +325,10 @@ export default function Page() {
310325
titlePrefix={"Base"}
311326
fallbackIndex={-1} // Default to the next to latest in the window
312327
timeRange={timeRange}
328+
highlightConfig={{
329+
keys: highlightKey === DEFAULT_HIGHLIGHT_KEY ? [] : [highlightKey],
330+
highlightColor: "yellow",
331+
}}
313332
/>
314333
<Divider orientation="vertical" flexItem>
315334
&mdash;Diff→
@@ -324,6 +343,10 @@ export default function Page() {
324343
titlePrefix={"New"}
325344
fallbackIndex={0} // Default to the latest commit
326345
timeRange={timeRange}
346+
highlightConfig={{
347+
keys: highlightKey === DEFAULT_HIGHLIGHT_KEY ? [] : [highlightKey],
348+
highlightColor: "yellow",
349+
}}
327350
/>
328351
</Stack>
329352
<Report

0 commit comments

Comments
 (0)