Skip to content

Commit

Permalink
/go/performance/utils/sysbench_runner: wip, tests working, runner and…
Browse files Browse the repository at this point in the history
… profile working, need tpcc now, then unmarshal stuff
  • Loading branch information
coffeegoddd committed Feb 14, 2024
1 parent 8049429 commit aabdce4
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 3 deletions.
10 changes: 9 additions & 1 deletion go/performance/utils/sysbench_runner/mysql_server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type mysqlServerConfigImpl struct {
Socket string
}

var _ ServerConfig = &mysqlServerConfigImpl{}
var _ ProtocolServerConfig = &mysqlServerConfigImpl{}

func NewMysqlServerConfig(version, serverExec, serverUser, host, resultsFormat, protocol, socket string, port int, serverArgs []string, skipBinLog bool) *mysqlServerConfigImpl {
return &mysqlServerConfigImpl{
Expand Down Expand Up @@ -86,6 +86,14 @@ func (sc *mysqlServerConfigImpl) GetResultsFormat() string {
return sc.ResultsFormat
}

func (sc *mysqlServerConfigImpl) GetConnectionProtocol() string {
return sc.ConnectionProtocol
}

func (sc *mysqlServerConfigImpl) GetSocket() string {
return sc.Socket
}

func (sc *mysqlServerConfigImpl) GetServerArgs() ([]string, error) {
params := make([]string, 0)
if sc.ServerUser != "" {
Expand Down
148 changes: 148 additions & 0 deletions go/performance/utils/sysbench_runner/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ package sysbench_runner

import (
"context"
"errors"
"fmt"
"log"
"os"
"path/filepath"
"testing"
)

Expand Down Expand Up @@ -65,3 +68,148 @@ func selectTests(names ...string) []TestConfig {
}
return tests
}

func TestDoltMysqlSysbenchRunner(t *testing.T) {
t.Skip()
dir := t.TempDir()
log.Println(dir)
err := os.Chdir(dir)
if err != nil {
log.Fatal(err)
}

conf := &sysbenchRunnerConfigImpl{
Tests: []TestConfig{
NewTestConfig("oltp_read_write", nil, false),
NewTestConfig("oltp_update_index", nil, false),
NewTestConfig("oltp_delete_insert", nil, true),
},
Servers: []ServerConfig{
&doltServerConfigImpl{
Id: "test-dolt",
Version: "1.33.0",
ResultsFormat: CsvFormat,
ServerExec: "/Users/dustin/go/bin/dolt",
},
&mysqlServerConfigImpl{
Id: "test-mysql",
Host: "127.0.0.1",
Port: 3606,
Version: "8.0.35",
ResultsFormat: CsvFormat,
ServerExec: "/opt/homebrew/bin/mysqld",
ServerUser: "root",
SkipLogBin: true,
ConnectionProtocol: "tcp",
},
},
ScriptDir: "/Users/dustin/src/sysbench-lua-scripts",
TestOptions: []string{
"--rand-seed=1",
"--table-size=10000",
"--rand-type=uniform",
"--time=120",
"--percentile=50",
},
InitBigRepo: true,
}

err = Run(context.Background(), conf)
if err != nil {
log.Fatal(err)
}
}

func TestDoltgresPostgresSysbenchRunner(t *testing.T) {
t.Skip()
dir := t.TempDir()
log.Println(dir)
err := os.Chdir(dir)
if err != nil {
log.Fatal(err)
}

conf := &sysbenchRunnerConfigImpl{
Tests: []TestConfig{
NewTestConfig("oltp_read_write", nil, false),
NewTestConfig("oltp_update_index", nil, false),
},
Servers: []ServerConfig{
&postgresServerConfigImpl{
Id: "test-postgres",
Host: "127.0.0.1",
Version: "15.5",
ResultsFormat: CsvFormat,
ServerExec: "/opt/homebrew/opt/postgresql@15/bin/postgres",
InitExec: "/opt/homebrew/opt/postgresql@15/bin/initdb",
ServerUser: "root",
},
&doltgresServerConfigImpl{
Id: "test-doltgres",
Port: 4433,
Host: "127.0.0.1",
Version: "b139dfb",
ResultsFormat: CsvFormat,
ServerExec: "/Users/dustin/go/bin/doltgres",
},
},
ScriptDir: "/Users/dustin/src/sysbench-lua-scripts",
TestOptions: []string{
"--rand-seed=1",
"--table-size=10000",
"--rand-type=uniform",
"--time=120",
"--percentile=50",
},
InitBigRepo: true,
}

err = Run(context.Background(), conf)
if err != nil {
log.Fatal(err)
}
}

func TestDoltProfiler(t *testing.T) {
t.Skip()
dir := t.TempDir()
log.Println(dir)
err := os.Chdir(dir)
if err != nil {
log.Fatal(err)
}

id := "test-dolt-profile"
conf := &sysbenchRunnerConfigImpl{
Tests: []TestConfig{
NewTestConfig("oltp_read_write", nil, false),
},
Servers: []ServerConfig{
&doltServerConfigImpl{
Id: id,
Version: "1.33.0",
ResultsFormat: CsvFormat,
ServerExec: "/Users/dustin/go/bin/dolt",
ServerProfile: CpuServerProfile,
ProfilePath: dir,
},
},
TestOptions: []string{
"--rand-seed=1",
"--table-size=10000",
"--rand-type=uniform",
"--time=30",
"--percentile=50",
},
}

err = Run(context.Background(), conf)
if err != nil {
log.Fatal(err)
}

expectedProfile := filepath.Join(dir, fmt.Sprintf("%s_%s", id, cpuProfileFilename))
if _, err := os.Stat(expectedProfile); errors.Is(err, os.ErrNotExist) {
log.Fatal("failed to create dolt cpu profile")
}
}
4 changes: 2 additions & 2 deletions go/performance/utils/sysbench_runner/tpcc_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type tpccConfigImpl struct {

var _ TpccConfig = &tpccConfigImpl{}

func NewTpccConfig() *tpccConfigImpl {
func NewTpccRunnerConfig() *tpccConfigImpl {
return &tpccConfigImpl{
Servers: make([]ServerConfig, 0),
ScaleFactors: make([]int, 0),
Expand Down Expand Up @@ -153,7 +153,7 @@ func FromFileTpccConfig(configPath string) (TpccConfig, error) {
return nil, err
}

config := NewTpccConfig()
config := NewTpccRunnerConfig()
err = json.Unmarshal(data, config)
if err != nil {
return nil, err
Expand Down

0 comments on commit aabdce4

Please sign in to comment.