Skip to content

Commit b4472bd

Browse files
authored
Add target MarkArea for time series chart when user change the lcommit and rcommit (#7283)
# Overview Add target MarkArea for time series chart when user change the lcommit and rcommit ## Query list commit change: Query: compilers_benchmark_api_commit_query Details: Instead of use distinct, we use GROUP BY to find unique branch, commit, workflowId combo along with a hourly granularity timestamp. This allow us to target right time range when targeting the MapArea in time series chart and sync with the timeseries data's timestamp ## Add MapArea when lcommit and rcommit change, a mapArea in time series chart willl also change. THis helps users to identify where the datapoint they are targeting, reduce confusion. # Preview https://torchci-git-addmarkarea-fbopensource.vercel.app/benchmark/compilers_regression # Demo ![Oct-02-2025 19-08-37](https://github.com/user-attachments/assets/0b61f2b5-d327-46a2-98ea-0e597e35c9da)
1 parent 7e392e3 commit b4472bd

File tree

6 files changed

+78
-24
lines changed

6 files changed

+78
-24
lines changed
Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,33 @@
1-
SELECT DISTINCT
1+
SELECT
22
replaceOne(head_branch, 'refs/heads/', '') AS branch,
33
head_sha AS commit,
44
workflow_id,
5-
toDate(fromUnixTimestamp(timestamp), 'UTC') AS date
5+
toStartOfHour(min(fromUnixTimestamp(timestamp))) AS date
66
FROM benchmark.oss_ci_benchmark_torchinductor
77
PREWHERE
88
timestamp >= toUnixTimestamp({startTime: DateTime64(3)})
99
AND timestamp < toUnixTimestamp({stopTime: DateTime64(3)})
1010
WHERE
11-
-- optional branches
1211
(
1312
has(
1413
{branches: Array(String)},
1514
replaceOne(head_branch, 'refs/heads/', '')
1615
)
1716
OR empty({branches: Array(String)})
1817
)
19-
-- optional suites
2018
AND (
2119
has({suites: Array(String)}, suite)
2220
OR empty({suites: Array(String)})
2321
)
24-
-- optional dtype
25-
AND (
26-
benchmark_dtype = {dtype: String}
27-
OR empty({dtype: String})
28-
)
29-
-- optional mode
30-
AND (
31-
benchmark_mode = {mode: String}
32-
OR empty({mode: String})
33-
)
34-
-- optional device
35-
AND (
36-
device = {device: String}
37-
OR empty({device: String})
38-
)
39-
-- optional arch (array param); if empty array, skip filter
22+
AND (benchmark_dtype = {dtype: String} OR empty({dtype: String}))
23+
AND (benchmark_mode = {mode: String} OR empty({mode: String}))
24+
AND (device = {device: String} OR empty({device: String}))
4025
AND (
4126
multiSearchAnyCaseInsensitive(arch, {arch: Array(String)})
4227
OR empty({arch: Array(String)})
4328
)
44-
ORDER BY branch, timestamp
29+
GROUP BY
30+
branch, commit, workflow_id
31+
ORDER BY
32+
branch, date
4533
SETTINGS session_timezone = 'UTC';

torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/BenchmarkChartSection.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export default function BenchmarkChartSection({
2828
data = [],
2929
chartSectionConfig,
3030
onSelect,
31+
lcommit,
32+
rcommit,
3133
}: {
3234
data?: BenchmarkTimeSeriesInput[];
3335
chartSectionConfig: BenchmarkChartSectionConfig;
@@ -96,6 +98,8 @@ export default function BenchmarkChartSection({
9698
onSelect={(payload: any) => {
9799
onSelect?.(payload);
98100
}}
101+
lcommit={lcommit}
102+
rcommit={rcommit}
99103
/>
100104
</Paper>
101105
</Box>

torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/components/BenchmarkTimeSeriesChart/BenchmarkTimeSeriesChart.tsx

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,25 @@ type Props = {
3232
customizedConfirmDialog?: { type: string; id?: string };
3333
renderOptions?: BenchmarkTimeSeriesCharRenderOpiton;
3434
defaultSelectMode?: boolean;
35+
markArea?: {
36+
start?: string;
37+
end?: string;
38+
singleGap?: number;
39+
};
3540
/** Called when user clicks Confirm with L/R selected for a single series. */
3641
onSelect?: (sel: ConfirmPayload) => void;
3742
};
3843

3944
const DEFAULT_HEIGHT = 200;
4045

46+
// we want to show the mark area as a single point, default gap is 1 hour
47+
const DEFAULT_MARK_AREA_SINGLE_GAP = 60 * 60 * 1000;
48+
4149
const BenchmarkTimeSeriesChart: React.FC<Props> = ({
4250
timeseries,
4351
renderOptions,
4452
customizedConfirmDialog,
53+
markArea,
4554
defaultSelectMode = false,
4655
onSelect = () => {},
4756
}) => {
@@ -132,7 +141,41 @@ const BenchmarkTimeSeriesChart: React.FC<Props> = ({
132141

133142
// Build line series first (indices 0..N-1 map to logical timeseries)
134143
const lineSeries: echarts.SeriesOption[] = useMemo(() => {
135-
return seriesDatas.map((data, idx) => {
144+
let ma: any = [];
145+
if (markArea?.start && markArea?.end) {
146+
const a = dayjs(markArea.start).valueOf();
147+
const b = dayjs(markArea.end).valueOf();
148+
const [l, r] = a <= b ? [a, b] : [b, a];
149+
// when left === right, we want to show the mark area as a single point
150+
const gap = markArea?.singleGap ?? DEFAULT_MARK_AREA_SINGLE_GAP;
151+
const adjustedEnd = l === r ? r + gap : r;
152+
ma = [
153+
[
154+
{
155+
xAxis: l,
156+
},
157+
{
158+
xAxis: adjustedEnd,
159+
},
160+
],
161+
];
162+
}
163+
const markAreaLine = {
164+
type: "line",
165+
name: "__markarea__",
166+
data: [],
167+
lineStyle: { opacity: 0 },
168+
itemStyle: { opacity: 0 },
169+
showSymbol: false,
170+
tooltip: { show: false },
171+
markArea: {
172+
silent: true,
173+
itemStyle: { color: "rgba(0, 150, 136, 0.06)" },
174+
data: ma,
175+
},
176+
} as echarts.SeriesOption;
177+
178+
const lines = seriesDatas.map((data, idx) => {
136179
const isSelected = selectedSeriesIdx === idx;
137180
const mlData: any[] = [];
138181

@@ -172,7 +215,16 @@ const BenchmarkTimeSeriesChart: React.FC<Props> = ({
172215
: {}),
173216
} as echarts.SeriesOption;
174217
});
175-
}, [seriesDatas, timeseries, selectedSeriesIdx, leftIdx, rightIdx]);
218+
return [...lines, markAreaLine];
219+
}, [
220+
seriesDatas,
221+
timeseries,
222+
selectedSeriesIdx,
223+
leftIdx,
224+
rightIdx,
225+
markArea?.start,
226+
markArea?.end,
227+
]);
176228

177229
// Highlight overlays appended after all lines
178230
const overlaySeries: echarts.SeriesOption[] = useMemo(() => {

torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/components/BenchmarkTimeSeriesChart/RenderingOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const echartRenderingOptions: echarts.EChartsOption = {
3535
xAxis: {
3636
type: "time",
3737
axisLabel: {
38-
formatter: (v: number) => dayjs.utc(v).format("MM-DD"),
38+
formatter: (v: number) => dayjs.utc(v).format("MM-DD HH:mm"),
3939
},
4040
},
4141
yAxis: {

torchci/components/benchmark/v3/components/dataRender/components/benchmarkTimeSeries/components/BenchmarkTimeSeriesChartGroup.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Grid, Typography } from "@mui/material";
22
import { Box } from "@mui/system";
3+
import { BenchmarkCommitMeta } from "lib/benchmark/store/benchmark_regression_store";
34
import { useMemo } from "react";
45
import {
56
BenchmarkTimeSeriesInput,
@@ -14,6 +15,8 @@ type Props = {
1415
data: any[];
1516
chartGroup: ChartGroupConfig;
1617
defaultSelectMode?: boolean;
18+
lcommit?: BenchmarkCommitMeta;
19+
rcommit?: BenchmarkCommitMeta;
1720
onSelect?: (payload: any) => void;
1821
};
1922

@@ -22,6 +25,8 @@ export default function BenchmarkTimeSeriesChartGroup({
2225
data,
2326
chartGroup,
2427
defaultSelectMode = false,
28+
lcommit,
29+
rcommit,
2530
onSelect = () => {},
2631
}: Props) {
2732
const filtered = useMemo(
@@ -93,6 +98,10 @@ export default function BenchmarkTimeSeriesChartGroup({
9398
customizedConfirmDialog={
9499
chartGroup?.chart?.customizedConfirmDialog
95100
}
101+
markArea={{
102+
start: lcommit?.date ?? undefined,
103+
end: rcommit?.date ?? undefined,
104+
}}
96105
renderOptions={chartGroup?.chart?.renderOptions}
97106
defaultSelectMode={defaultSelectMode}
98107
onSelect={onSelect}

torchci/components/benchmark/v3/components/dataRender/fanout/FanoutComponents.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function FanoutBenchmarkTimeSeriesComparisonTableSection({
3939
data={data}
4040
lcommit={lcommit ?? undefined}
4141
rcommit={rcommit ?? undefined}
42+
onChange={onChange}
4243
/>
4344
</>
4445
);

0 commit comments

Comments
 (0)