Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pschork committed Jun 5, 2024
1 parent 5c21b8e commit e3f9c51
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions tools/batchgen/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,40 @@ 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) {
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))

Check failure on line 56 in tools/batchgen/cmd/main.go

View workflow job for this annotation

GitHub Actions / Linter

loopclosure: loop variable i captured by func literal (govet)
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
Expand Down

0 comments on commit e3f9c51

Please sign in to comment.