From 92968f75c6136d3bc9875e4e4ccd817138bdfd41 Mon Sep 17 00:00:00 2001 From: Patrick Schork <354473+pschork@users.noreply.github.com> Date: Wed, 5 Jun 2024 02:10:49 -0700 Subject: [PATCH] wip --- tools/batchgen/cmd/main.go | 51 ++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/tools/batchgen/cmd/main.go b/tools/batchgen/cmd/main.go index 4428faa810..01aff0c055 100644 --- a/tools/batchgen/cmd/main.go +++ b/tools/batchgen/cmd/main.go @@ -28,32 +28,41 @@ func main() { log.Println("failed to convert factor to int:", err) return } - req, _, _, _, _ := makeStoreChunksRequest(100, 10, factor) - hosts := os.Args[2:] // assuming multiple hosts are passed as command line arguments + threads, err := strconv.Atoi(os.Args[2]) + if err != nil { + log.Println("failed to convert threads to int:", err) + return + } + hosts := os.Args[3:] // assuming multiple hosts are passed as command line arguments results := make(chan *pb.StoreChunksReply, len(hosts)) // channel to collect results errors := make(chan error, len(hosts)) // channel to collect errors + req, _, _, _, _ := makeStoreChunksRequest(100, 10, factor) + for _, host := range hosts { - go func(host string) { - conn, err := grpc.Dial(host, grpc.WithTransportCredentials(insecure.NewCredentials())) - if err != nil { - errors <- err - return - } - defer conn.Close() - - client := pb.NewDispersalClient(conn) - opt := grpc.MaxCallSendMsgSize(60 * 1024 * 1024 * 1024) - - log.Println("sending chunks to operator", host, "request message size", proto.Size(req)) - reply, err := client.StoreChunks(context.Background(), req, opt) - if err != nil { - errors <- err - } else { - results <- reply - } - }(host) + for i := 0; i < threads; i++ { + go func(host string, i int) { + conn, err := grpc.Dial(host, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + errors <- err + return + } + defer conn.Close() + + client := pb.NewDispersalClient(conn) + opt := grpc.MaxCallSendMsgSize(60 * 1024 * 1024 * 1024) + + sizeInMB := float64(proto.Size(req)) / 1024.0 / 1024.0 + log.Println("host", host, "thread", i, "size", sizeInMB, "MB") + reply, err := client.StoreChunks(context.Background(), req, opt) + if err != nil { + errors <- err + } else { + results <- reply + } + }(host, i) + } } // Wait for all goroutines to finish and collect results