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 dfea119
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions tools/batchgen/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
sizeInMB := float64(proto.Size(req)) / 1024.0 / 1024.0

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)

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
Expand All @@ -65,6 +74,8 @@ func main() {
log.Println("error", err)
}
}
totalSizeInMB := sizeInMB * float64(threads) * float64(len(hosts))
log.Println("total data sent", totalSizeInMB, "MB")
}

func makeStoreChunksRequest(quorumThreshold, adversaryThreshold uint8, factor int) (*pb.StoreChunksRequest, [32]byte, [32]byte, []*core.BlobHeader, []*pb.BlobHeader) {
Expand Down

0 comments on commit dfea119

Please sign in to comment.