Skip to content

Commit 8bab009

Browse files
Merge branch 'main' into lint_workflow
Signed-off-by: Dhairya Majmudar <[email protected]>
2 parents b25ff8f + e964b37 commit 8bab009

File tree

10 files changed

+136
-71
lines changed

10 files changed

+136
-71
lines changed

go/tools/macrobench/results.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func Compare(client storage.SQLClient, old, new string, workloads []string, plan
218218
return
219219
}
220220

221-
if len(oldResult.Results) == 0 && len(newResult.Results) == 0 {
221+
if len(oldResult.Results) == 0 || len(newResult.Results) == 0 {
222222
mu.Lock()
223223
defer mu.Unlock()
224224
results[workload] = StatisticalCompareResults{
@@ -230,6 +230,7 @@ func Compare(client storage.SQLClient, old, new string, workloads []string, plan
230230
"vtgate": {},
231231
"vttablet": {},
232232
},
233+
MissingResults: true,
233234
}
234235
return
235236
}
@@ -259,7 +260,7 @@ func CompareFKs(client storage.SQLClient, oldWorkload, newWorkload string, sha s
259260
return StatisticalCompareResults{}, err
260261
}
261262

262-
if len(oldResult.Results) == 0 && len(newResult.Results) == 0 {
263+
if len(oldResult.Results) == 0 || len(newResult.Results) == 0 {
263264
return StatisticalCompareResults{
264265
ComponentsCPUTime: map[string]StatisticalResult{
265266
"vtgate": {},
@@ -269,6 +270,7 @@ func CompareFKs(client storage.SQLClient, oldWorkload, newWorkload string, sha s
269270
"vtgate": {},
270271
"vttablet": {},
271272
},
273+
MissingResults: true,
272274
}, nil
273275
}
274276

go/tools/macrobench/stats.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type (
8787

8888
TotalComponentsMemStatsAllocBytes StatisticalResult `json:"total_components_mem_stats_alloc_bytes"`
8989
ComponentsMemStatsAllocBytes map[string]StatisticalResult `json:"components_mem_stats_alloc_bytes"`
90+
MissingResults bool `json:"missing_results"`
9091
}
9192
)
9293

website/src/common/CompareActions.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
import { Button } from "@/components/ui/button";
1818
import { cn } from "@/library/utils";
1919
import { VitessRefs } from "@/types";
20-
import React from "react";
20+
import React, { useEffect } from "react";
2121
import VitessRefsCommand from "./VitessRefsCommand";
2222

2323
export type CompareActionsProps = {
@@ -47,6 +47,19 @@ export default function CompareAction(props: CompareActionsProps) {
4747
} = props;
4848
const isButtonDisabled = !oldGitRef || !newGitRef;
4949

50+
useEffect(() => {
51+
const handleKeyDown = (event: KeyboardEvent) => {
52+
if (event.key === "Enter" && !isButtonDisabled) {
53+
compareClicked();
54+
}
55+
};
56+
57+
document.addEventListener("keydown", handleKeyDown);
58+
return () => {
59+
document.removeEventListener("keydown", handleKeyDown);
60+
};
61+
}, [compareClicked, isButtonDisabled]);
62+
5063
return (
5164
<div className={cn("flex flex-col md:flex-row gap-4", className)}>
5265
<div className="flex flex-col">

website/src/common/MacroBenchmarkTable.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ import {
2929
TooltipProvider,
3030
TooltipTrigger,
3131
} from "@/components/ui/tooltip";
32-
import { MacroBenchmarkTableData, Range } from "@/types";
32+
import { MacroBenchmarkTableData, Range, VitessRefs } from "@/types";
3333
import {
3434
fixed,
3535
formatByte,
36-
formatGitRef,
36+
getRefName,
3737
secondToMicrosecond,
3838
} from "@/utils/Utils";
3939
import { Link } from "react-router-dom";
@@ -43,6 +43,7 @@ export type MacroBenchmarkTableProps = {
4343
old: string;
4444
new: string;
4545
isGitRef?: boolean;
46+
vitessRefs: VitessRefs | null;
4647
};
4748

4849
const getDeltaBadgeVariant = (key: string, delta: number, p: number) => {
@@ -92,9 +93,10 @@ const getValue = <T, K extends keyof T>(obj: T, key: K): T[K] => obj[key];
9293

9394
export default function MacroBenchmarkTable({
9495
data,
95-
new: newColumn,
96+
new: newGitRef,
9697
old,
9798
isGitRef = true,
99+
vitessRefs,
98100
}: MacroBenchmarkTableProps) {
99101
if (!data) {
100102
return null;
@@ -126,27 +128,27 @@ export default function MacroBenchmarkTable({
126128
<TableRow className="hover:bg-background border-b">
127129
<TableHead className="w-[200px]"></TableHead>
128130
<TableHead className="text-center text-primary font-semibold min-w-[150px]">
129-
{isGitRef ? (
131+
{isGitRef && vitessRefs ? (
130132
<Link
131133
to={`https://github.com/vitessio/vitess/commit/${old}`}
132134
target="__blank"
133135
>
134-
{formatGitRef(old) || "N/A"}
136+
{getRefName(old, vitessRefs) || "N/A"}
135137
</Link>
136138
) : (
137139
<>{old}</>
138140
)}
139141
</TableHead>
140142
<TableHead className="text-center text-primary font-semibold min-w-[150px]">
141-
{isGitRef ? (
143+
{isGitRef && vitessRefs ? (
142144
<Link
143-
to={`https://github.com/vitessio/vitess/commit/${newColumn}`}
145+
to={`https://github.com/vitessio/vitess/commit/${newGitRef}`}
144146
target="__blank"
145147
>
146-
{formatGitRef(newColumn) || "N/A"}
148+
{getRefName(newGitRef, vitessRefs) || "N/A"}
147149
</Link>
148150
) : (
149-
<>{newColumn}</>
151+
<>{newGitRef}</>
150152
)}
151153
</TableHead>
152154
<TableHead className="lg:w-[150px] text-center font-semibold">

website/src/pages/ComparePage/ComparePage.tsx

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,50 @@ import MacroBenchmarkTable from "@/common/MacroBenchmarkTable";
1818
import { Button } from "@/components/ui/button";
1919
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
2020
import { Skeleton } from "@/components/ui/skeleton";
21-
import { CompareData, MacroBenchmarkTableData } from "@/types";
21+
import { CompareData, MacroBenchmarkTableData, VitessRefs } from "@/types";
2222
import useApiCall from "@/utils/Hook";
23-
import { formatCompareData } from "@/utils/Utils";
23+
import { formatCompareData, getRefName } from "@/utils/Utils";
2424
import { PlusCircledIcon } from "@radix-ui/react-icons";
2525
import { useEffect, useState } from "react";
2626
import { Link, useNavigate } from "react-router-dom";
2727
import CompareHero from "./components/CompareHero";
2828

2929
export default function Compare() {
30+
const navigate = useNavigate();
3031
const urlParams = new URLSearchParams(window.location.search);
3132

3233
const [gitRef, setGitRef] = useState({
3334
old: urlParams.get("old") || "",
3435
new: urlParams.get("new") || "",
3536
});
3637

37-
const navigate = useNavigate();
38-
39-
useEffect(() => {
40-
navigate(`?old=${gitRef.old}&new=${gitRef.new}`);
41-
}, [gitRef.old, gitRef.new]);
42-
4338
const {
4439
data: data,
4540
isLoading: isMacrobenchLoading,
4641
error: macrobenchError,
4742
} = useApiCall<CompareData[]>(
48-
`${import.meta.env.VITE_API_URL}macrobench/compare?new=${gitRef.new}&old=${
49-
gitRef.old
50-
}`,
43+
gitRef.old && gitRef.new
44+
? `${import.meta.env.VITE_API_URL}macrobench/compare?new=${
45+
gitRef.new
46+
}&old=${gitRef.old}`
47+
: ``
5148
);
5249

50+
const { data: vitessRefs } = useApiCall<VitessRefs>(
51+
`${import.meta.env.VITE_API_URL}vitess/refs`
52+
);
53+
54+
useEffect(() => {
55+
let oldRefName = gitRef.old;
56+
let newRefName = gitRef.new;
57+
if (vitessRefs) {
58+
oldRefName = getRefName(gitRef.old, vitessRefs);
59+
newRefName = getRefName(gitRef.new, vitessRefs);
60+
}
61+
62+
navigate(`?old=${oldRefName}&new=${newRefName}`);
63+
}, [gitRef.old, gitRef.new, vitessRefs]);
64+
5365
let formattedData: MacroBenchmarkTableData[] = [];
5466

5567
if (data !== null && data.length > 0) {
@@ -58,7 +70,11 @@ export default function Compare() {
5870

5971
return (
6072
<>
61-
<CompareHero gitRef={gitRef} setGitRef={setGitRef} />
73+
<CompareHero
74+
gitRef={gitRef}
75+
setGitRef={setGitRef}
76+
vitessRefs={vitessRefs}
77+
/>
6278
{macrobenchError && (
6379
<div className="text-red-500 text-center my-2">{macrobenchError}</div>
6480
)}
@@ -75,6 +91,11 @@ export default function Compare() {
7591
})}
7692
</>
7793
)}
94+
{!isMacrobenchLoading && data === null && (
95+
<div className="md:text-xl text-primary">
96+
Chose two commits to compare
97+
</div>
98+
)}
7899
{!isMacrobenchLoading && data !== null && data.length > 0 && (
79100
<>
80101
{data.map((macro, index) => {
@@ -89,6 +110,7 @@ export default function Compare() {
89110
variant="outline"
90111
size="sm"
91112
className="h-8 w-fit border-dashed mt-4 md:mt-0"
113+
disabled={macro.result.missing_results}
92114
>
93115
<PlusCircledIcon className="mr-2 h-4 w-4 text-primary" />
94116
<Link
@@ -99,11 +121,18 @@ export default function Compare() {
99121
</Button>
100122
</CardHeader>
101123
<CardContent className="w-full p-0">
102-
<MacroBenchmarkTable
103-
data={formattedData[index]}
104-
new={gitRef.new}
105-
old={gitRef.old}
106-
/>
124+
{macro.result.missing_results ? (
125+
<div className="text-center md:text-xl text-destructive pb-12">
126+
Missing results for this workload
127+
</div>
128+
) : (
129+
<MacroBenchmarkTable
130+
data={formattedData[index]}
131+
new={gitRef.new}
132+
old={gitRef.old}
133+
vitessRefs={vitessRefs}
134+
/>
135+
)}
107136
</CardContent>
108137
</Card>
109138
</div>

website/src/pages/ComparePage/components/CompareHero.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,18 @@ export type CompareHeroProps = {
3232
new: string;
3333
}>
3434
>;
35+
vitessRefs: VitessRefs | null;
3536
};
3637

3738
export default function CompareHero(props: CompareHeroProps) {
38-
const { gitRef, setGitRef } = props;
39+
const { gitRef, setGitRef, vitessRefs } = props;
3940
const [oldGitRef, setOldGitRef] = useState(gitRef.old);
4041
const [newGitRef, setNewGitRef] = useState(gitRef.new);
4142

42-
const { data: vitessRefs } = useApiCall<VitessRefs>(
43-
`${import.meta.env.VITE_API_URL}vitess/refs`,
44-
);
45-
4643
const compareClicked = () => {
4744
setGitRef({ old: oldGitRef, new: newGitRef });
4845
};
4946

50-
useEffect(() => {}, [vitessRefs]);
51-
5247
useEffect(() => {
5348
setOldGitRef(gitRef.old);
5449
setNewGitRef(gitRef.new);

website/src/pages/ForeignKeysPage/ForeignKeysPage.tsx

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,10 @@ import { Button } from "@/components/ui/button";
2323
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
2424
import { Skeleton } from "@/components/ui/skeleton";
2525
import useApiCall from "@/utils/Hook";
26-
import { errorApi, formatCompareResult, formatGitRef } from "@/utils/Utils";
26+
import { formatCompareResult, getRefName } from "@/utils/Utils";
2727
import { PlusCircledIcon } from "@radix-ui/react-icons";
2828
import ForeignKeysHero from "./components/ForeignKeysHero";
2929

30-
export const formatTitle = (gitRef: string, vitessRefs: VitessRefs): string => {
31-
let title = formatGitRef(gitRef);
32-
vitessRefs.branches.forEach((branch) => {
33-
if (branch.commit_hash.match(gitRef)) {
34-
title = branch.name;
35-
}
36-
});
37-
vitessRefs.tags.forEach((branch) => {
38-
if (branch.commit_hash.match(gitRef)) {
39-
title = branch.name;
40-
}
41-
});
42-
return title;
43-
};
44-
4530
export default function ForeignKeys() {
4631
const urlParams = new URLSearchParams(window.location.search);
4732

@@ -60,9 +45,11 @@ export default function ForeignKeys() {
6045
isLoading: isMacrobenchLoading,
6146
error: macrobenchError,
6247
} = useApiCall<CompareResult>(
63-
`${import.meta.env.VITE_API_URL}fk/compare?sha=${gitRef}&newWorkload=${
64-
workload.new
65-
}&oldWorkload=${workload.old}`,
48+
gitRef && workload.old && workload.new
49+
? `${import.meta.env.VITE_API_URL}fk/compare?sha=${gitRef}&newWorkload=${
50+
workload.new
51+
}&oldWorkload=${workload.old}`
52+
: ""
6653
);
6754

6855
let formattedData = data !== null ? formatCompareResult(data) : null;
@@ -87,15 +74,17 @@ export default function ForeignKeys() {
8774
/>
8875
)}
8976

90-
{macrobenchError && (
91-
<div className="text-red-500 text-center my-2">{macrobenchError}</div>
92-
)}
77+
<section className="flex flex-col items-center">
78+
{macrobenchError && (
79+
<div className="text-destructive">{macrobenchError}</div>
80+
)}
9381

94-
{(formattedData === null || data === null) && !isMacrobenchLoading && (
95-
<div className="text-red-500 text-center my-2">{errorApi}</div>
96-
)}
82+
{!isMacrobenchLoading && data === null && (
83+
<div className="md:text-xl text-primary">
84+
Chose two commits to compare
85+
</div>
86+
)}
9787

98-
<section className="flex flex-col items-center">
9988
{isMacrobenchLoading && (
10089
<>
10190
{[...Array(8)].map((_, index) => {
@@ -123,7 +112,7 @@ export default function ForeignKeys() {
123112
to={`https://github.com/vitessio/vitess/commit/${gitRef}`}
124113
target="__blank"
125114
>
126-
{formatTitle(gitRef, vitessRefs)}
115+
{getRefName(gitRef, vitessRefs)}
127116
</Link>
128117
)}
129118
</CardTitle>
@@ -141,12 +130,19 @@ export default function ForeignKeys() {
141130
</Button>
142131
</CardHeader>
143132
<CardContent className="w-full p-0">
144-
<MacroBenchmarkTable
145-
data={formattedData}
146-
new={workload.new}
147-
old={workload.old}
148-
isGitRef={false}
149-
/>
133+
{data.missing_results ? (
134+
<div className="text-center md:text-xl text-destructive pb-12">
135+
Missing results for this workloads
136+
</div>
137+
) : (
138+
<MacroBenchmarkTable
139+
data={formattedData}
140+
new={workload.new}
141+
old={workload.old}
142+
isGitRef={false}
143+
vitessRefs={null}
144+
/>
145+
)}
150146
</CardContent>
151147
</Card>
152148
</div>

website/src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export interface CompareResult {
111111
vtgate: ComparedValue;
112112
vttablet: ComparedValue;
113113
};
114+
missing_results: boolean;
114115
}
115116

116117
export interface CompareData {

0 commit comments

Comments
 (0)