From 10f5fb35b1a60a2451c5d7863d855071a786c9ed 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 | 43 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/tools/batchgen/cmd/main.go b/tools/batchgen/cmd/main.go index 4428faa810..a734d99303 100644 --- a/tools/batchgen/cmd/main.go +++ b/tools/batchgen/cmd/main.go @@ -30,30 +30,33 @@ func main() { } req, _, _, _, _ := makeStoreChunksRequest(100, 10, factor) - hosts := os.Args[2:] // assuming multiple hosts are passed as command line arguments + threads := os.Args[2] // assuming multiple hosts are passed as command line arguments + 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 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 < len(threads); i++ { + 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("host", host, "thread", i, "size", proto.Size(req)) + reply, err := client.StoreChunks(context.Background(), req, opt) + if err != nil { + errors <- err + } else { + results <- reply + } + }(host) + } } // Wait for all goroutines to finish and collect results