Skip to content

Commit

Permalink
Merge pull request #498 from vitessio/add-tcpc-compare-page
Browse files Browse the repository at this point in the history
Compare FK benchmarks
  • Loading branch information
frouioui authored Jan 15, 2024
2 parents 231b3e4 + b6baf92 commit ef4465a
Show file tree
Hide file tree
Showing 13 changed files with 417 additions and 80 deletions.
2 changes: 1 addition & 1 deletion config/dev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ web-pr-label-trigger: '"Benchmark me"'
web-pr-label-trigger-planner-v3: '"Benchmark me (V3)"'
web-vitess-path: /tmp
web-mode: "development"
web-cron-schedule: "*/1 * * * *"
web-cron-schedule: "1 1 1 1 1"
web-cron-schedule-pull-requests: "1 1 1 1 1"
web-cron-schedule-tags: "1 1 1 1 1"

Expand Down
19 changes: 18 additions & 1 deletion go/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ func (s *Server) requestRun(c *gin.Context) {
}
currVersion := git.Version{Major: version}


configs := s.getConfigFiles()
cfg, ok := configs[strings.ToLower(benchmarkType)]
if !ok {
Expand Down Expand Up @@ -451,3 +450,21 @@ func (s *Server) deleteRun(c *gin.Context) {
c.JSON(http.StatusOK, "deleted")
}

func (s *Server) compareBenchmarkFKs(c *gin.Context) {
sha := c.Query("sha")

var mtypes []string
for _, benchmarkType := range s.benchmarkTypes {
if strings.Contains(benchmarkType, "TPCC") {
mtypes = append(mtypes, benchmarkType)
}
}

allBenchmarkResults, err := macrobench.GetDetailsFromAllTypes(sha, macrobench.Gen4Planner, s.dbClient, mtypes)
if err != nil {
c.JSON(http.StatusInternalServerError, &ErrorAPI{Error: err.Error()})
slog.Error(err)
return
}
c.JSON(http.StatusOK, allBenchmarkResults)
}
1 change: 1 addition & 0 deletions go/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ func (s *Server) Run() error {
s.router.GET("/api/recent", s.getRecentExecutions)
s.router.GET("/api/queue", s.getExecutionsQueue)
s.router.GET("/api/vitess/refs", s.getLatestVitessGitRef)
s.router.GET("/api/fk/compare", s.compareBenchmarkFKs)
s.router.GET("/api/macrobench/compare", s.compareMacrobenchmarks)
s.router.GET("/api/microbench/compare", s.compareMicrobenchmarks)
s.router.GET("/api/search", s.searchBenchmarck)
Expand Down
54 changes: 15 additions & 39 deletions go/tools/macrobench/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

"github.com/vitessio/arewefastyet/go/storage"

"github.com/dustin/go-humanize"
"github.com/vitessio/arewefastyet/go/exec/metrics"
"github.com/vitessio/arewefastyet/go/storage/mysql"
awftmath "github.com/vitessio/arewefastyet/go/tools/math"
Expand Down Expand Up @@ -231,44 +230,21 @@ func (mabd DetailsArray) ReduceSimpleMedian() (reduceMabd DetailsArray) {
return reduceMabd
}

func (mbr Result) TPSStr() string {
return humanize.FormatFloat("#,###.#", mbr.TPS)
}

func (mbr Result) LatencyStr() string {
return humanize.FormatFloat("#,###.#", mbr.Latency)
}

func (mbr Result) ErrorsStr() string {
return humanize.FormatFloat("#,###.#", mbr.Errors)
}

func (mbr Result) ReconnectsStr() string {
return humanize.FormatFloat("#,###.#", mbr.Reconnects)
}

func (mbr Result) TimeStr() string {
return humanize.Comma(int64(mbr.Time))
}

func (mbr Result) ThreadsStr() string {
return humanize.FormatFloat("#,###.#", mbr.Threads)
}

func (qps QPS) TotalStr() string {
return humanize.FormatFloat("#,###.#", qps.Total)
}

func (qps QPS) ReadsStr() string {
return humanize.FormatFloat("#,###.#", qps.Reads)
}

func (qps QPS) WritesStr() string {
return humanize.FormatFloat("#,###.#", qps.Writes)
}

func (qps QPS) OtherStr() string {
return humanize.FormatFloat("#,###.#", qps.Other)
func GetDetailsFromAllTypes(sha string, planner PlannerVersion, dbclient storage.SQLClient, types []string) (map[string]Details, error) {
details, err := GetDetailsArraysFromAllTypes(sha, planner, dbclient, types)
if err != nil {
return nil, err
}
result := make(map[string]Details, len(details))
for s, array := range details {
var d Details
d.Metrics = metrics.NewExecMetrics()
if len(array) == 1 {
d = array[0]
}
result[s] = d
}
return result, nil
}

// GetDetailsArraysFromAllTypes returns a slice of Details based on the given git ref and Types.
Expand Down
28 changes: 0 additions & 28 deletions go/tools/macrobench/results_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,34 +118,6 @@ func BenchmarkReduceSimpleMedian(b *testing.B) {
}
}

func TestHumanReadableStrings(t *testing.T) {
c := qt.New(t)
r := Result{
QPS: QPS{
Total: 72029.0,
Reads: 45018.1,
Writes: 18007.2,
Other: 9003.6,
},
TPS: 4501.8,
Latency: 189848.3,
Errors: 8999.6,
Reconnects: 7984.3,
Time: 11064,
Threads: 1107794.12,
}
c.Assert(r.QPS.TotalStr(), qt.Equals, "72,029.0")
c.Assert(r.QPS.ReadsStr(), qt.Equals, "45,018.1")
c.Assert(r.QPS.WritesStr(), qt.Equals, "18,007.2")
c.Assert(r.QPS.OtherStr(), qt.Equals, "9,003.6")
c.Assert(r.TPSStr(), qt.Equals, "4,501.8")
c.Assert(r.LatencyStr(), qt.Equals, "189,848.3")
c.Assert(r.ErrorsStr(), qt.Equals, "8,999.6")
c.Assert(r.ReconnectsStr(), qt.Equals, "7,984.3")
c.Assert(r.TimeStr(), qt.Equals, "11,064")
c.Assert(r.ThreadsStr(), qt.Equals, "1,107,794.1")
}

func TestCompareDetailsArrays(t *testing.T) {
type args struct {
references DetailsArray
Expand Down
2 changes: 1 addition & 1 deletion website/src/common/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const navItems = [
{ to: "/daily", title: "Daily" },
{ to: "/compare", title: "Compare" },
{ to: "/search", title: "Search" },
// { to: "/micro", title: "Micro" },
{ to: "/macro", title: "Macro" },
{ to: "/fk", title: "Foreign Keys" },
{ to: "/pr", title: "PR" },
];

Expand Down
110 changes: 110 additions & 0 deletions website/src/pages/ForeignKeysPage/ForeignKeysPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
Copyright 2024 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import React, { useState, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import RingLoader from "react-spinners/RingLoader";


import { errorApi } from "../../utils/Utils";
import Hero from "./components/Hero";
import FK from "./components/FK";

const ForeignKeys = () => {
const urlParams = new URLSearchParams(window.location.search);

const [gitRef, setGitRef] = useState({
tag: urlParams.get("tag") || "",
});

const [dataRefs, setDataRefs] = useState();
const [dataFKs, setDataFKs] = useState([]);
const [error, setError] = useState(null);
const [loading, setLoading] = useState(true);

async function loadRefs() {
try {
const responseRefs = await fetch(
`${import.meta.env.VITE_API_URL}vitess/refs`
);
const jsonDataRefs = await responseRefs.json();
setDataRefs(jsonDataRefs);
} catch (error) {
setError(errorApi);
}
}

async function loadData() {
const commits = {
tag: dataRefs.filter((r) => r.Name === gitRef.tag)[0].CommitHash,
};

setLoading(true);
try {
const responseFK = await fetch(
`${import.meta.env.VITE_API_URL}fk/compare?sha=${
commits.tag
}`
);
const jsonDataFKs = await responseFK.json();
setDataFKs(jsonDataFKs);
} catch (error) {
console.error("Error while retrieving data from the API", error);
setError(errorApi);
} finally {
setLoading(false);
}
}

useEffect(() => {
loadRefs();
}, []);

const navigate = useNavigate();
useEffect(() => {
navigate(`?tag=${gitRef.tag}`);

dataRefs && loadData();
}, [gitRef.tag, dataRefs]);

return (
<>
<Hero refs={dataRefs} gitRef={gitRef} setGitRef={setGitRef} />

<div className="p-page">
<div className="border border-front" />
</div>

<div className="flex flex-col items-center py-20">
{error && (
<div className="text-sm w-1/2 text-red-500 text-center">{error}</div>
)}

{loading && <RingLoader loading={loading} color="#E77002" size={300} />}

{!loading && dataFKs && (
<div className="flex flex-col gap-y-20 ">
<FK
data={dataFKs}
/>
</div>
)}
</div>
</>
);
};

export default ForeignKeys;
Loading

0 comments on commit ef4465a

Please sign in to comment.