Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
Signed-off-by: Brendan Dougherty <[email protected]>
  • Loading branch information
brendar committed Jun 28, 2024
1 parent 8aeb274 commit 0aa87a2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions examples/common/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ if [[ -n ${BASH} ]]; then
shopt -s expand_aliases
fi

export GOMAXPROCS=4
1 change: 1 addition & 0 deletions examples/common/scripts/vtgate-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ vtgate \
--pid_file $VTDATAROOT/tmp/vtgate.pid \
--enable_buffer \
--mysql_auth_server_impl none \
--pprof-http \
> $VTDATAROOT/tmp/vtgate.out 2>&1 &

# Block waiting for vtgate to be listening
Expand Down
1 change: 1 addition & 0 deletions examples/common/scripts/vttablet-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ vttablet \
--service_map 'grpc-queryservice,grpc-tabletmanager,grpc-updatestream' \
--pid_file $VTDATAROOT/$tablet_dir/vttablet.pid \
--heartbeat_on_demand_duration=5s \
--pprof-http \
> $VTDATAROOT/$tablet_dir/vttablet.out 2>&1 &

# Block waiting for the tablet to be listening
Expand Down
13 changes: 13 additions & 0 deletions examples/local/bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

source ../common/env.sh

vtbench \
--config-file-not-found-handling ignore \
--protocol mysql \
--host 127.0.0.1 \
--port 15306 \
--db commerce@primary \
--sql "select * from customer where customer_id = :random_int" \
--threads 10 \
--count 100000
21 changes: 10 additions & 11 deletions go/cmd/vtbench/cli/vtbench.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/spf13/cobra"

"vitess.io/vitess/go/acl"
"vitess.io/vitess/go/vt/dbconfigs"
"vitess.io/vitess/go/vt/grpccommon"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/servenv"
Expand Down Expand Up @@ -191,23 +190,23 @@ func run(cmd *cobra.Command, args []string) error {
return errors.New("vtbench requires either host/port or unix_socket")
}

var password string
if clientProto == vtbench.MySQL {
var err error
_, password, err = dbconfigs.GetCredentialsServer().GetUserAndPassword(user)
if err != nil {
return fmt.Errorf("error reading password for user %v from file: %w", user, err)
}
}
//var password string
//if clientProto == vtbench.MySQL {
// var err error
// _, password, err = dbconfigs.GetCredentialsServer().GetUserAndPassword(user)
// if err != nil {
// return fmt.Errorf("error reading password for user %v from file: %w", user, err)
// }
//}

connParams := vtbench.ConnParams{
Hosts: strings.Split(host, ","),
Port: port,
UnixSocket: unixSocket,
Protocol: clientProto,
DB: db,
Username: user,
Password: password,
//Username: user,
//Password: password,
}

b := vtbench.NewBench(threads, count, connParams, sql)
Expand Down
2 changes: 2 additions & 0 deletions go/vtbench/vtbench.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package vtbench
import (
"context"
"fmt"
"math/rand/v2"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -180,6 +181,7 @@ func (b *Bench) createConns(ctx context.Context) error {

func (b *Bench) getQuery(i int) (string, map[string]*querypb.BindVariable) {
query := strings.Replace(b.Query, ":thread", fmt.Sprintf("%d", i), -1)
query = strings.Replace(query, ":random_int", fmt.Sprintf("%d", rand.Int()), -1)
bindVars := make(map[string]*querypb.BindVariable)
return query, bindVars
}
Expand Down

0 comments on commit 0aa87a2

Please sign in to comment.