sysbench_runner

package
v0.40.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

README

Sysbench runner is a tool for running sysbench tests against sql servers. Custom sysbench lua scripts used for benchmarking Dolt are here.

The tool requires a json config file to run:

$ sysbench_runner --config=config.json

Configuration:

{
  "Runs": 1,
  "DebugMode": false,
  "Servers": "[{...}]",
  "TestOptions": [""],
  "Tests": "[{...}]"
}

Runs number of times to run all tests per server, default 1 (Optional)

DebugMode logs more output from various commands. (Optional)

Servers list of servers to test against. See Server definitions below. (Required)

TestOptions list of sysbench test options to supply to all tests (Optional)

Tests the sysbench tests to run. See Test definitions below. (Optional)

If no tests are provided, the following default tests will be run:

oltp_read_only
oltp_insert
oltp_point_select
select_random_points
select_random_ranges
oltp_delete
oltp_write_only
oltp_read_write
oltp_update_index
oltp_update_non_index

Server is a server to test against.

{
  "Host": "",
  "Port": 0,
  "Server": "",
  "Version": "",
  "ResultsFormat": "",
  "ServerExec": "",
  "ServerArgs": [""],
  "ConnectionProtocol": "",
  "Socket": ""
}

Host is the server host. (Required)

Port is the server port. Defaults to 3306 for dolt and mysql Servers. (Optional)

Server is the server. Only dolt and mysql are supported. (Required)

Version is the server version. (Required)

ResultsFormat is the format the results should be written in. Only json and csv are supported. (Required)

ServerExec is the path to a server binary (Required)

ServerArgs are the args used to start the server. Will be appended to command dolt sql-server for dolt server or mysqld --user=mysql for mysql server. (Optional)

ConnectionProtocol is the protocol for connecting to mysql, either "unix" or "tcp" (Required for mysql)

Socket is the path to the mysql socket (Required for mysql with unix protocol)

Test is a sysbench test or lua script.

{
  "Name": "",
  "N": 1,
  "FromScript": false,
  "Options": [""]
}

Name is the test name or lua script. (Required)

N number of times to repeat this test, default is 1 (Optional)

FromScript indicates if this test is from a lua script, defaults to false (Optional)

Options are additional sysbench test options. These will be provided to sysbench in the form:

sysbench [options]... [testname] [command]

Note: Be sure that all mysql processes are off when running this locally.

Documentation

Index

Constants

View Source
const (
	Dolt  ServerType = "dolt"
	MySql ServerType = "mysql"

	CsvFormat  = "csv"
	JsonFormat = "json"

	CsvExt  = ".csv"
	JsonExt = ".json"
)
View Source
const (
	SqlStatsPrefix = "SQL statistics:"
)

Variables

View Source
var (
	ErrTestNameNotDefined            = errors.New("test name not defined")
	ErrNoServersDefined              = errors.New("servers not defined")
	ErrUnsupportedConnectionProtocol = errors.New("unsupported connection protocol")
)
View Source
var (
	ResultFileTemplate = "%s_%s_%s_sysbench_performance%s"

	ErrUnableToParseOutput    = errors.New("unable to parse output")
	ErrUnsupportedHeaderField = errors.New("unsupported header field")
)
View Source
var Debug bool

Functions

func CheckExec

func CheckExec(serverConfig *ServerConfig) error

CheckExec verifies the binary exists

func CheckProtocol

func CheckProtocol(protocol string) error

CheckProtocol ensures the given protocol is supported

func CheckUpdatePortMap

func CheckUpdatePortMap(serverConfig *ServerConfig, portMap map[int]ServerType) (map[int]ServerType, error)

CheckUpdatePortMap returns an error if multiple servers have specified the same port

func ExecCommand

func ExecCommand(ctx context.Context, name string, arg ...string) *exec.Cmd

func FromHeaderResultColumnValue

func FromHeaderResultColumnValue(h string, r *Result) (string, error)

FromHeaderResultColumnValue returns the value from the Result for the given header field

func FromHeaderResultFieldValue

func FromHeaderResultFieldValue(field string, val string, r *Result) error

FromHeaderResultFieldValue sets the value to the corresponding Result field for the given header field

func FromResultCsvHeaders

func FromResultCsvHeaders() []string

FromResultCsvHeaders returns supported csv headers for a Result

func FromValWithParens

func FromValWithParens(val string) (string, string, error)

FromValWithParens takes a string containing parens and returns the value outside the parens first, and the value inside the parens second

func Run

func Run(config *Config) error

Run runs sysbench runner

func SetupDB

func SetupDB(ctx context.Context, serverConfig *ServerConfig, databaseName string) (err error)

func UpdateDoltConfig

func UpdateDoltConfig(ctx context.Context, config *ServerConfig) error

UpdateDoltConfig updates the dolt config if necessary

func UpdateResult

func UpdateResult(result *Result, line string) error

UpdateResult extracts the key and value from the given line and updates the given Result

func ValidateRequiredFields

func ValidateRequiredFields(server, version, format string) error

func WriteResults

func WriteResults(serverConfig *ServerConfig, results Results) error

func WriteResultsCsv

func WriteResultsCsv(filename string, results Results) (err error)

WriteResultsCsv writes Results to a csv

func WriteResultsJson

func WriteResultsJson(filename string, results Results) (err error)

WriteResultsJson writes Results to a json file

Types

type Config

type Config struct {
	// Runs is the number of times to run all tests
	Runs int
	// RuntimeOS is the platform the benchmarks ran on
	RuntimeOS string
	// RuntimeGoArch is the runtime architecture
	RuntimeGoArch string
	// Servers are the servers to benchmark
	Servers []*ServerConfig
	// Tests are the tests to run. If no tests are provided,
	// the default tests will be used
	Tests []*ConfigTest
	// TestOptions a list of sysbench test options to apply to all tests
	TestOptions []string
	// ScriptDir is a path to a directory of lua scripts
	ScriptDir string
	// DirtyClone downloads a database with existing chunks and commits
	InitBigRepo bool
}

Config is the configuration for a benchmarking run

func FromFileConfig

func FromFileConfig(configPath string) (*Config, error)

FromFileConfig returns a validated Config based on the config file at the configPath

func NewConfig

func NewConfig() *Config

NewConfig returns a new Config

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the config for the required fields and sets defaults where necessary

type ConfigTest

type ConfigTest struct {
	// Name is the test name
	Name string

	// N is the number of times a test should run
	N int

	// Options are additional sysbench test options a user can supply to run with this test
	Options []string

	// FromScript is a boolean indicating that this test is from a lua script
	FromScript bool
}

ConfigTest provides users a way to define a test for multiple tablesizes

func NewConfigTest

func NewConfigTest(name string, opts []string, fromScript bool) *ConfigTest

NewConfigTest returns a ConfigTest containing the supplied args

func (*ConfigTest) GetTests

func (ct *ConfigTest) GetTests(serverConfig *ServerConfig, testIdFunc func() string) ([]*Test, error)

GetTests returns a slice of Tests

type Result

type Result struct {
	// Id is the uuid of this result row
	Id string `json:"id"`

	//  SuiteId is the test suite id this test result is associated with
	SuiteId string `json:"suite_id"`

	// TestId is the unique id for this test
	TestId string `json:"test_id"`

	// RuntimeOS is the runtime platform
	RuntimeOS string `json:"runtime_os"`

	// RuntimeGoArch is the runtime architecture
	RuntimeGoArch string `json:"runtime_goarch"`

	// ServerName is the name of the server used for the benchmark
	ServerName string `json:"server_name"`

	// ServerVersion is the server's version
	ServerVersion string `json:"server_version"`

	// ServerParams are the params used to run the server
	ServerParams string `json:"server_params"`

	// TestName is the name of the test
	TestName string `json:"test_name"`

	// TestParams are the params used to run the test
	TestParams string `json:"test_params"`

	// CreatedAt is the time the result was created UTC
	CreatedAt string `json:"created_at"`

	// SqlReadQueries is the number of read queries performed
	SqlReadQueries int64 `json:"sql_read_queries"`

	// SqlWriteQueries is the number of write queries performed
	SqlWriteQueries int64 `json:"sql_write_queries"`

	// SqlOtherQueries is the number of other queries performed
	SqlOtherQueries int64 `json:"sql_other_queries"`

	// SqlTotalQueries is the number of total queries performed
	SqlTotalQueries int64 `json:"sql_total_queries"`

	// SqlTotalQueriesPerSecond is the number of queries per second
	SqlTotalQueriesPerSecond float64 `json:"sql_total_queries_per_second"`

	// TransactionsTotal is the number of transactions performed
	TransactionsTotal int64 `json:"sql_transactions_total"`

	// TransactionsPerSecond is the number of transactions per second
	TransactionsPerSecond float64 `json:"sql_transactions_per_second"`

	// IgnoredErrorsTotal is the number of errors ignored
	IgnoredErrorsTotal int64 `json:"sql_ignored_errors_total"`

	// IgnoredErrorsPerSecond is the number of errors ignored per second
	IgnoredErrorsPerSecond float64 `json:"sql_ignored_errors_per_second"`

	// ReconnectsTotal is the number of reconnects performed
	ReconnectsTotal int64 `json:"sql_reconnects_total"`

	// ReconnectsPerSecond is the number of reconnects per second
	ReconnectsPerSecond float64 `json:"sql_reconnects_per_second"`

	// TotalTimeSeconds is the total time elapsed for this test
	TotalTimeSeconds float64 `json:"total_time_seconds"`

	// TotalNumberOfEvents is the total number of events
	TotalNumberOfEvents int64 `json:"total_number_of_events"`

	// LatencyMinMS is the minimum latency in milliseconds
	LatencyMinMS float64 `json:"latency_minimum_ms"`

	// LatencyAvgMS is the average latency in milliseconds
	LatencyAvgMS float64 `json:"latency_average_ms"`

	// LatencyMaxMS is the maximum latency in milliseconds
	LatencyMaxMS float64 `json:"latency_maximum_ms"`

	// LatencyPercentile is the latency of the 95th percentile
	LatencyPercentile float64 `json:"latency_percentile"`

	// LatencySumMS is the latency sum in milliseconds
	LatencySumMS float64 `json:"latency_sum_ms"`
}

Result stores the output from a sysbench test run

func FromConfigsNewResult

func FromConfigsNewResult(config *Config, serverConfig *ServerConfig, t *Test, suiteId string, idFunc func() string) (*Result, error)

FromConfigsNewResult returns a new result with some fields set based on the provided configs

func FromOutputResult

func FromOutputResult(output []byte, config *Config, serverConfig *ServerConfig, test *Test, suiteId string, idFunc func() string) (*Result, error)

FromOutputResult accepts raw sysbench run output and returns the Result

func (*Result) Stamp

func (r *Result) Stamp(stampFunc func() string)

Stamp timestamps the result using the provided stamp function

type Results

type Results []*Result

Results is a slice of Result

func BenchmarkDolt

func BenchmarkDolt(ctx context.Context, config *Config, serverConfig *ServerConfig) (Results, error)

BenchmarkDolt benchmarks dolt based on the provided configurations

func BenchmarkMysql

func BenchmarkMysql(ctx context.Context, config *Config, serverConfig *ServerConfig) (Results, error)

BenchmarkMysql benchmarks mysql based on the provided configurations

func ReadResultsCsv

func ReadResultsCsv(filename string) (Results, error)

ReadResultsCsv reads a csv into Results

func ReadResultsJson

func ReadResultsJson(filename string) (Results, error)

ReadResultsJson reads a json file into Results

type ServerConfig

type ServerConfig struct {
	// Id is a unique id for this servers benchmarking
	Id string

	// Host is the server host
	Host string

	// Port is the server port
	Port int

	// Server is the type of server
	Server ServerType

	// Version is the server version
	Version string

	// ResultsFormat is the format the results should be written in
	ResultsFormat string

	// ServerExec is the path to a server executable
	ServerExec string

	// ServerArgs are the args used to start a server
	ServerArgs []string

	// ConnectionProtocol defines the protocol for connecting to the server
	ConnectionProtocol string

	// Socket is the path to the server socket
	Socket string
}

ServerConfig is the configuration for a server to test against

func (*ServerConfig) GetId

func (sc *ServerConfig) GetId() string

func (*ServerConfig) GetServerArgs

func (sc *ServerConfig) GetServerArgs() []string

GetServerArgs returns the args used to start a server

type ServerType

type ServerType string

type Test

type Test struct {

	// Name is the test name
	Name string

	// Params are the parameters passed to sysbench
	Params []string

	// FromScript indicates if this test is from a lua script
	FromScript bool
	// contains filtered or unexported fields
}

Test is a single sysbench test

func GetTests

func GetTests(config *Config, serverConfig *ServerConfig, testIdFunc func() string) ([]*Test, error)

GetTests returns a slice of Tests created from the defined ServerConfig.Tests

func (*Test) Cleanup

func (t *Test) Cleanup() []string

Cleanup returns a test's args for sysbench's cleanup step

func (*Test) Prepare

func (t *Test) Prepare() []string

Prepare returns a test's args for sysbench's prepare step

func (*Test) Run

func (t *Test) Run() []string

Run returns a test's args for sysbench's run step

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL