Skip to content

Commit

Permalink
chore: benchmark disk usage
Browse files Browse the repository at this point in the history
  • Loading branch information
hasethuraman committed Jun 25, 2024
1 parent fc3d8ca commit d39d2a1
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 28 deletions.
69 changes: 44 additions & 25 deletions tools/benchmark/cmd/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ func generateRandomStringWith0s1s(length int) string {
return result
}

func populate_kvs() {
clusterid := "/openebs.io/mayastor/apis/v0/clusters/" + uuid.New().String()
println("Cluster ID : ", clusterid)

func populate_kvs(clusterid string) {
cn := uint(0)

kvs := []kv{}
Expand Down Expand Up @@ -209,22 +206,11 @@ func populate_kvs() {
replid, replid, volid,
)

k3 := clusterid + "/namespaces/default/NexusSpec/" + nexid
v3 := fmt.Sprintf(
"{\"uuid\":\"%s\",\"name\":\"%s\",\"node\":\"%s\",\"children\":[{\"Replica\":{\"uuid\":\"%s\",\"share_uri\":\"bdev:///%s?uuid=%s\"}}],\"size\":2147483648,\"spec_status\":{\"Created\":\"Online\"},\"share\":\"nvmf\",\"managed\":true,\"owner\":\"%s\",\"operation\":null}",
nexid, volid, agentpoold, replid, replid, replid, volid,
)

kv2 := kv{}
kv2.key = k2
kv2.value = v2

kv3 := kv{}
kv3.key = k3
kv3.value = v3

kvs = append(kvs, kv2)
kvs = append(kvs, kv3)
}

if rebuild_count > 0 {
Expand All @@ -233,20 +219,33 @@ func populate_kvs() {
if rebuild_count == 0 {
rebuild_map_str = ""
}
k3 := clusterid + "/namespaces/default/NexusSpec/" + nexid
k4 := clusterid + "/namespaces/default/volume/" + volid + "/nexus/" + nexid + "/info"
n_child_str := ""
child_str := ""
l_rebuild_str := rebuild_map_str
for _, replid := range replids {
child_str = child_str + fmt.Sprintf("{\"healthy\":true,\"uuid\":\"%s\",\"rebuild_map\":%s},", replid, rebuild_map_str)
n_child_str = n_child_str + fmt.Sprintf("{\"Replica\":{\"uuid\":\"%s\",\"share_uri\":\"nvmf://10.1.0.5:8420/nqn.2019-05.io.openebs:/xfs-disk-pool/loopxyz2023070702/%s?uuid=%s\"}},", replid, replid, replid)
child_str = child_str + fmt.Sprintf("{\"healthy\":true,\"uuid\":\"%s\",\"rebuild_map\":%s},", replid, l_rebuild_str)
l_rebuild_str = ""
}
v3 := fmt.Sprintf(
"{\"uuid\":\"%s\",\"name\":\"%s\",\"node\":\"%s\",\"children\":[%s],\"size\":2147483648,\"spec_status\":{\"Created\":\"Online\"},\"share\":\"nvmf\",\"managed\":true,\"owner\":\"%s\",\"operation\":null}",
nexid, volid, agentpoold, n_child_str, volid,
)
v4 := fmt.Sprintf(
"{\"children\":[%s],\"clean_shutdown\":false}",
child_str,
)
kv3 := kv{}
kv3.key = k3
kv3.value = v3

kv4 := kv{}
kv4.key = k4
kv4.value = v4

kvs = append(kvs, kv3)
kvs = append(kvs, kv4)

if snap_count == 0 {
Expand Down Expand Up @@ -284,7 +283,6 @@ func populate_kvs() {
kv6.key = k6
kv6.value = v6
kvs = append(kvs, kv6)
q <- kvs
}
}

Expand All @@ -300,6 +298,8 @@ func populate_kvs() {
}

func putFunc(cmd *cobra.Command, args []string) {
clusterid := "/openebs.io/mayastor/apis/v0/clusters/" + uuid.New().String()

if keySpaceSize <= 0 {
fmt.Fprintf(os.Stderr, "expected positive --key-space-size, got (%v)", keySpaceSize)
os.Exit(1)
Expand All @@ -315,15 +315,10 @@ func putFunc(cmd *cobra.Command, args []string) {

kt := putTotal
if mayastor {
if mssnaps > 0 {
kt = msnodes + msdisks + (putTotal * 4) + (putTotal * (1 + mssnaps))
} else {
kt = msnodes + msdisks + (putTotal * 4)
}
kt = msnodes + msdisks + (putTotal * 3) + (putTotal * noofrepls) + mssnaps + (noofsnaps * mssnaps)

go populate_kvs()
time.Sleep(1 * time.Second)
fmt.Printf("KVs ready : %d\n", len(q))
go populate_kvs(clusterid)
time.Sleep(2 * time.Second)
}

bar = pb.New(kt)
Expand Down Expand Up @@ -357,10 +352,27 @@ func putFunc(cmd *cobra.Command, args []string) {
defer fn.Close()
fmt.Print("Writer configured\n")
}
print_once := true
printed_data := ""
total_keys := 0

if mayastor {
go func() {
third_kv := 3
for kvs := range q {
third_kv = third_kv - 1
if print_once {
if third_kv == 0 {
print_once = false
printed_data = printed_data + fmt.Sprintln("KVs :")
printed_data = printed_data + fmt.Sprintln("---")
for _, kv := range kvs {
printed_data = printed_data + fmt.Sprintf("Key: %s, \nValue: (%d) \n---\n", kv.key, len(kv.value))
}
printed_data = printed_data + fmt.Sprintln("---")
}
}
total_keys = total_keys + len(kvs)
for _, kv := range kvs {
if kv.key == "END" {
close(requests)
Expand Down Expand Up @@ -421,6 +433,13 @@ func putFunc(cmd *cobra.Command, args []string) {
if checkHashkv {
hashKV(cmd, clients)
}

fmt.Printf("Cluster ID : %s\n", clusterid)
fmt.Printf("Sample data: %s\n", printed_data)
fmt.Printf(
"Total keys: %d, calculated: %d {msnodes: %d, msdisks: %d, puttotal: %d, mssnaps: %d}\n",
total_keys, kt, msnodes, msdisks, putTotal, mssnaps,
)
}

func compactKV(clients []*v3.Client) {
Expand Down
5 changes: 5 additions & 0 deletions tools/benchmark/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ var (
dialTimeout time.Duration

targetLeader bool

maxCallSendMsgSize int
maxCallRxMsgSize int
)

func init() {
Expand All @@ -71,4 +74,6 @@ func init() {
RootCmd.PersistentFlags().DurationVar(&dialTimeout, "dial-timeout", 0, "dial timeout for client connections")

RootCmd.PersistentFlags().BoolVar(&targetLeader, "target-leader", false, "connect only to the leader node")
RootCmd.PersistentFlags().IntVar(&maxCallSendMsgSize, "maxCallSendMsgSize", 3145728, "maximum size of the message that can be sent")
RootCmd.PersistentFlags().IntVar(&maxCallRxMsgSize, "maxCallRxMsgSize", 3145728, "maximum size of the message that can be received")
}
8 changes: 5 additions & 3 deletions tools/benchmark/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"

"github.com/bgentry/speakeasy"
"go.etcd.io/etcd/client/v3"
clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/pkg/v3/report"
"google.golang.org/grpc/grpclog"
)
Expand Down Expand Up @@ -93,8 +93,10 @@ func mustCreateConn() *clientv3.Client {
dialTotal++
}
cfg := clientv3.Config{
Endpoints: connEndpoints,
DialTimeout: dialTimeout,
Endpoints: connEndpoints,
DialTimeout: dialTimeout,
MaxCallSendMsgSize: maxCallSendMsgSize,
MaxCallRecvMsgSize: maxCallRxMsgSize,
}
if !tls.Empty() || tls.TrustedCAFile != "" {
cfgtls, err := tls.ClientConfig()
Expand Down
11 changes: 11 additions & 0 deletions tools/benchmark/pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Pod
metadata:
name: mc0
spec:
restartPolicy: Never
containers:
- name: 1st
image: ubuntu:22.04
command: ["sleep", "infinity"]
imagePullPolicy: IfNotPresent
Empty file added tools/benchmark/test1.txt
Empty file.
Binary file added tools/etcd-dump-db/boltcli
Binary file not shown.
Binary file added tools/etcd-dump-db/etcd-dump-db
Binary file not shown.

0 comments on commit d39d2a1

Please sign in to comment.