From 099567b4409e709b66683e9653ac271b99bf9cb0 Mon Sep 17 00:00:00 2001 From: Max Hoffman Date: Wed, 1 May 2024 12:57:29 -0700 Subject: [PATCH 1/5] [no-release-notes] redo how to set tpc-c testing statistics --- go/performance/utils/benchmark_runner/tpcc.go | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/go/performance/utils/benchmark_runner/tpcc.go b/go/performance/utils/benchmark_runner/tpcc.go index be265e6b568..7e2d23971a7 100644 --- a/go/performance/utils/benchmark_runner/tpcc.go +++ b/go/performance/utils/benchmark_runner/tpcc.go @@ -17,9 +17,11 @@ package benchmark_runner import ( "context" "fmt" + "github.com/jmoiron/sqlx" "os" "os/exec" "path/filepath" + "time" ) type tpccTesterImpl struct { @@ -51,6 +53,75 @@ func (t *tpccTesterImpl) outputToResult(output []byte) (*Result, error) { return OutputToResult(output, t.serverConfig.GetServerType(), t.serverConfig.GetVersion(), t.test.GetName(), t.test.GetId(), t.suiteId, t.config.GetRuntimeOs(), t.config.GetRuntimeGoArch(), t.serverParams, t.test.GetParamsToSlice(), nil, false) } +func (t *tpccTesterImpl) collectStats(ctx context.Context) error { + db, err := sqlx.Open("mysql", "root:@/sbt") + if err != nil { + return err + } + c, err := db.Connx(ctx) + if err != nil { + return err + } + + { + // configuration, restart, and check needs to be in the same session + tx, err := c.BeginTxx(ctx, nil) + if err != nil { + return err + } + + if _, err := tx.Exec("set @@GLOBAL.dolt_stats_auto_refresh_enabled = 1;"); err != nil { + return err + } + if _, err := tx.Exec("set @@GLOBAL.dolt_stats_auto_refresh_interval = 0;"); err != nil { + return err + } + if _, err := tx.Exec("set @@PERSIST.dolt_stats_auto_refresh_interval = 0;"); err != nil { + return err + } + if _, err := tx.Exec("set @@PERSIST.dolt_stats_auto_refresh_enabled = 1;"); err != nil { + return err + } + if _, err := tx.Exec("use sbt;"); err != nil { + return err + } + if _, err := tx.Exec("call dolt_stats_restart();"); err != nil { + return err + } + + rows := map[string]interface{}{"cnt": 0} + tick := time.NewTicker(5 * time.Second) + for { + if rows["cnt"] != 0 { + fmt.Printf("collected %d histogram buckets\n", rows["cnt"]) + break + } + select { + case <-tick.C: + res, err := tx.Queryx("select count(*) as cnt from dolt_statistics;") + if err != nil { + return err + } + if !res.Next() { + return fmt.Errorf("failed to set statistics") + } + if err := res.MapScan(rows); err != nil { + return err + } + if err := res.Close(); err != nil { + return err + } + } + } + } + + if _, err := c.QueryContext(ctx, "call dolt_stats_stop();"); err != nil { + return err + } + + return nil +} + func (t *tpccTesterImpl) prepare(ctx context.Context) error { args := t.test.GetPrepareArgs(t.serverConfig) cmd := exec.CommandContext(ctx, t.tpccCommand, args...) @@ -105,6 +176,10 @@ func (t *tpccTesterImpl) Test(ctx context.Context) (*Result, error) { return nil, err } + if err := t.collectStats(ctx); err != nil { + return nil, err + } + fmt.Println("Running test", t.test.GetName()) rs, err := t.run(ctx) From 8687ff9f0045416f59ec155b16dd8adccacae654 Mon Sep 17 00:00:00 2001 From: max-hoffman Date: Wed, 1 May 2024 20:05:16 +0000 Subject: [PATCH 2/5] [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh --- go/performance/utils/benchmark_runner/tpcc.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/go/performance/utils/benchmark_runner/tpcc.go b/go/performance/utils/benchmark_runner/tpcc.go index 7e2d23971a7..e57869b263b 100644 --- a/go/performance/utils/benchmark_runner/tpcc.go +++ b/go/performance/utils/benchmark_runner/tpcc.go @@ -17,11 +17,12 @@ package benchmark_runner import ( "context" "fmt" - "github.com/jmoiron/sqlx" "os" "os/exec" "path/filepath" "time" + + "github.com/jmoiron/sqlx" ) type tpccTesterImpl struct { From ec0240001781107ba578aa8f7187925320165d7f Mon Sep 17 00:00:00 2001 From: Max Hoffman Date: Wed, 1 May 2024 13:37:31 -0700 Subject: [PATCH 3/5] Remove old code --- .../utils/benchmark_runner/dolt_tpcc.go | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/go/performance/utils/benchmark_runner/dolt_tpcc.go b/go/performance/utils/benchmark_runner/dolt_tpcc.go index 0b976dbb960..e8b57c9ed95 100644 --- a/go/performance/utils/benchmark_runner/dolt_tpcc.go +++ b/go/performance/utils/benchmark_runner/dolt_tpcc.go @@ -71,10 +71,6 @@ func (b *doltTpccBenchmarkerImpl) Benchmark(ctx context.Context) (Results, error } defer os.RemoveAll(testRepo) - if err := configureStats(ctx, b.serverConfig.GetServerExec(), testRepo); err != nil { - return nil, err - } - serverParams, err := b.serverConfig.GetServerArgs() if err != nil { return nil, err @@ -118,21 +114,3 @@ func GetTpccTests(config TpccConfig) []Test { } return tests } - -func configureStats(ctx context.Context, doltPath, dbPath string) error { - queries := []string{ - "set @@PERSIST.dolt_stats_auto_refresh_enabled = 1;", - "set @@PERSIST.dolt_stats_auto_refresh_interval = 0", - "set @@PERSIST.dolt_stats_auto_refresh_threshold = 1.0;", - "select sleep(1)", - "set @@PERSIST.dolt_stats_auto_refresh_enabled = 0;", - } - for _, q := range queries { - q := ExecCommand(ctx, doltPath, "sql", "-q", q) - q.Dir = dbPath - if err := q.Run(); err != nil { - return err - } - } - return nil -} From 6afaa09c365d050a2adf1f9b00806a8a19f1ef36 Mon Sep 17 00:00:00 2001 From: Max Hoffman Date: Thu, 2 May 2024 10:36:00 -0700 Subject: [PATCH 4/5] don't collect stats for mysql --- go/performance/utils/benchmark_runner/tpcc.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/go/performance/utils/benchmark_runner/tpcc.go b/go/performance/utils/benchmark_runner/tpcc.go index e57869b263b..f37f7eb4dfd 100644 --- a/go/performance/utils/benchmark_runner/tpcc.go +++ b/go/performance/utils/benchmark_runner/tpcc.go @@ -20,6 +20,7 @@ import ( "os" "os/exec" "path/filepath" + "strings" "time" "github.com/jmoiron/sqlx" @@ -55,6 +56,9 @@ func (t *tpccTesterImpl) outputToResult(output []byte) (*Result, error) { } func (t *tpccTesterImpl) collectStats(ctx context.Context) error { + if !strings.Contains(t.serverConfig.GetServerExec(), "dolt") { + return nil + } db, err := sqlx.Open("mysql", "root:@/sbt") if err != nil { return err From ce68ea94d35ca57a8a8c8a9aa2a52e3d75e4acb3 Mon Sep 17 00:00:00 2001 From: Max Hoffman Date: Thu, 2 May 2024 19:05:23 -0700 Subject: [PATCH 5/5] tpcc uses non-standard port --- go/performance/utils/benchmark_runner/tpcc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/performance/utils/benchmark_runner/tpcc.go b/go/performance/utils/benchmark_runner/tpcc.go index f37f7eb4dfd..4ef585dc044 100644 --- a/go/performance/utils/benchmark_runner/tpcc.go +++ b/go/performance/utils/benchmark_runner/tpcc.go @@ -59,7 +59,7 @@ func (t *tpccTesterImpl) collectStats(ctx context.Context) error { if !strings.Contains(t.serverConfig.GetServerExec(), "dolt") { return nil } - db, err := sqlx.Open("mysql", "root:@/sbt") + db, err := sqlx.Open("mysql", fmt.Sprintf("root:@tcp(%s:%d)/sbt", t.serverConfig.GetHost(), t.serverConfig.GetPort())) if err != nil { return err }