From 73ae4ebc51b8d22a6d5cfe29233b66992a445aff Mon Sep 17 00:00:00 2001 From: filipecosta90 Date: Thu, 6 May 2021 11:31:44 +0100 Subject: [PATCH 1/2] [fix] Fixed uneven distribution of commands per clients (total commands % clients != 0 ) --- redisgraph-bechmark-go.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/redisgraph-bechmark-go.go b/redisgraph-bechmark-go.go index fe8faa5..477d5f9 100644 --- a/redisgraph-bechmark-go.go +++ b/redisgraph-bechmark-go.go @@ -54,6 +54,7 @@ func main() { var rateLimiter = rate.NewLimiter(requestRate, requestBurst) samplesPerClient := *numberRequests / *clients + samplesPerClientRemainder := *numberRequests % *clients client_update_tick := 1 connectionStr := fmt.Sprintf("%s:%d", *host, *port) @@ -61,6 +62,9 @@ func main() { wg := sync.WaitGroup{} if !*loop { log.Printf("Total clients: %d. Commands per client: %d Total commands: %d\n", *clients, samplesPerClient, *numberRequests) + if samplesPerClientRemainder != 0 { + log.Printf("Last client will issue: %d commands.\n", samplesPerClientRemainder+samplesPerClient) + } } else { log.Printf("Running in loop until you hit Ctrl+C\n") } @@ -98,12 +102,15 @@ func main() { dataPointProcessingWg.Add(1) go processGraphDatapointsChannel(graphDatapointsChann, c1, *numberRequests, &dataPointProcessingWg, &instantHistogramsResetMutex) - + clientTotalCmds := samplesPerClient startTime := time.Now() for client_id := 0; uint64(client_id) < *clients; client_id++ { wg.Add(1) rgs[client_id], conns[client_id] = getStandaloneConn(*graphKey, "tcp", connectionStr, *password) - go ingestionRoutine(&rgs[client_id], true, queries, cdf, samplesPerClient, *loop, *debug, &wg, useRateLimiter, rateLimiter, graphDatapointsChann) + if uint64(client_id) == (*clients - uint64(1)) { + clientTotalCmds = samplesPerClientRemainder + samplesPerClient + } + go ingestionRoutine(&rgs[client_id], true, queries, cdf, clientTotalCmds, *loop, *debug, &wg, useRateLimiter, rateLimiter, graphDatapointsChann) } // enter the update loop From 98f2079052c70b9d0768cbacd135becf7c9849a2 Mon Sep 17 00:00:00 2001 From: filipecosta90 Date: Thu, 6 May 2021 11:40:34 +0100 Subject: [PATCH 2/2] [fix] Fixes per PR review: added comments to explain the usage of clientTotalCmds --- redisgraph-bechmark-go.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/redisgraph-bechmark-go.go b/redisgraph-bechmark-go.go index 477d5f9..4740cc3 100644 --- a/redisgraph-bechmark-go.go +++ b/redisgraph-bechmark-go.go @@ -102,11 +102,15 @@ func main() { dataPointProcessingWg.Add(1) go processGraphDatapointsChannel(graphDatapointsChann, c1, *numberRequests, &dataPointProcessingWg, &instantHistogramsResetMutex) + // Total commands to be issue per client. Equal for all clients with exception of the last one ( see comment bellow ) clientTotalCmds := samplesPerClient startTime := time.Now() for client_id := 0; uint64(client_id) < *clients; client_id++ { wg.Add(1) rgs[client_id], conns[client_id] = getStandaloneConn(*graphKey, "tcp", connectionStr, *password) + // Given the total commands might not be divisible by the #clients + // the last client will send the remainder commands to match the desired request count. + // It's OK to alter clientTotalCmds given this is the last time we use it's value if uint64(client_id) == (*clients - uint64(1)) { clientTotalCmds = samplesPerClientRemainder + samplesPerClient }