Skip to content

Commit d402226

Browse files
Merge pull request #15 from RedisGraph/query.ro
Enabled GRAPH.RO_QUERY command support. Updated Readme accordingly.
2 parents 5b809f5 + 362f043 commit d402226

File tree

6 files changed

+150
-88
lines changed

6 files changed

+150
-88
lines changed

README.md

Lines changed: 116 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -22,84 +22,129 @@ make
2222
## Usage of redisgraph-benchmark-go
2323

2424
```
25-
$ ./redisgraph-benchmark-go --help
26-
Usage of ./redisgraph-benchmark-go:
27-
-a string
28-
Password for Redis Auth.
29-
-c uint
30-
number of clients. (default 50)
31-
-debug int
32-
Client debug level.
33-
-graph-key string
34-
graph key. (default "graph")
35-
-h string
36-
Server hostname. (default "127.0.0.1")
37-
-l Loop. Run the tests forever.
38-
-n uint
39-
Total number of requests (default 1000000)
40-
-p int
41-
Server port. (default 6379)
42-
-rps int
43-
Max rps. If 0 no limit is applied and the DB is stressed up to maximum.
25+
$ $ ./redisgraph-benchmark-go --help
26+
Usage of ./redisgraph-benchmark-go:
27+
-a string
28+
Password for Redis Auth.
29+
-c uint
30+
number of clients. (default 50)
31+
-continue-on-error
32+
Continue benchmark in case of error replies.
33+
-debug int
34+
Client debug level.
35+
-enable-exporter-rps
36+
Push results to redistimeseries exporter in real-time. Time granularity is set via the -reporting-period parameter.
37+
-exporter-rts-auth string
38+
RedisTimeSeries Password for Redis Auth.
39+
-exporter-rts-host string
40+
RedisTimeSeries hostname. (default "127.0.0.1")
41+
-exporter-rts-port int
42+
RedisTimeSeries port. (default 6379)
43+
-exporter-run-name string
44+
Run name. (default "perf-run")
45+
-graph-key string
46+
graph key. (default "graph")
47+
-h string
48+
Server hostname. (default "127.0.0.1")
49+
-json-out-file string
50+
Name of json output file to output benchmark results. If not set, will not print to json. (default "benchmark-results.json")
51+
-n uint
52+
Total number of requests (default 1000000)
53+
-p int
54+
Server port. (default 6379)
55+
-query value
56+
Specify a RedisGraph query to send in quotes. Each command that you specify is run with its ratio. For example: -query="CREATE (n)" -query-ratio=1
57+
-query-ratio value
58+
The query ratio vs other queries used in the same benchmark. Each command that you specify is run with its ratio. For example: -query="CREATE (n)" -query-ratio=0.5 -query="MATCH (n) RETURN n" -query-ratio=0.5
59+
-query-ro value
60+
Specify a RedisGraph read-only query to send in quotes. You can run multiple commands (both read/write) on the same benchmark. Each command that you specify is run with its ratio. For example: -query="CREATE (n)" -query-ratio=0.5 -query-ro="MATCH (n) RETURN n" -query-ratio=0.5
61+
-random-int-max int
62+
__rand_int__ upper value limit. __rand_int__ distribution is uniform Random (default 1000000)
63+
-random-int-min int
64+
__rand_int__ lower value limit. __rand_int__ distribution is uniform Random (default 1)
65+
-random-seed int
66+
Random seed to use. (default 12345)
67+
-reporting-period duration
68+
Period to report stats. (default 10s)
69+
-rps int
70+
Max rps. If 0 no limit is applied and the DB is stressed up to maximum.
71+
-v Output version and exit
4472
```
4573

46-
## Sample output - 1M commands
74+
## Sample output - 100K write commands
4775

4876
```
49-
$ redisgraph-benchmark-go -graph-key graph "CREATE (u:User)"
50-
Debug level: 0.
51-
Total clients: 50. Commands per client: 20000 Total commands: 1000000
52-
Test time Total Commands Total Errors Command Rate Client p50 with RTT(ms) Graph Internal p50 with RTT(ms)
53-
53s [100.0%] 1000000 0 [0.0%] 8002.89 2.097 0.000
54-
################# RUNTIME STATS #################
55-
Total Duration 53.001 Seconds
56-
Total Commands issued 1000000
57-
Total Errors 0 ( 0.000 %)
58-
Throughput summary: 18868 requests per second
59-
Overall Client Latency summary (msec):
60-
p50 p95 p99
61-
2.097 5.347 9.063
62-
################## GRAPH STATS ##################
63-
Total Empty resultsets 1000000 ( 100.000 %)
64-
Total Nodes created 1000000
65-
Total Nodes deleted 0
66-
Total Labels added 0
67-
Total Properties set 0
68-
Total Relationships created 0
69-
Total Relationships deleted 0
70-
Overall RedisGraph Internal Execution time Latency summary (msec):
71-
p50 p95 p99
72-
0.000 0.000 0.000
77+
$ redisgraph-benchmark-go -n 100000 -graph-key graph -query "CREATE (u:User)"
78+
2021/07/12 11:44:13 redisgraph-benchmark-go (git_sha1:)
79+
2021/07/12 11:44:13 RTS export disabled.
80+
2021/07/12 11:44:13 Debug level: 0.
81+
2021/07/12 11:44:13 Using random seed: 12345.
82+
2021/07/12 11:44:13 Total clients: 50. Commands per client: 2000 Total commands: 100000
83+
2021/07/12 11:44:13 Trying to extract RedisGraph version info
84+
2021/07/12 11:44:13 Detected RedisGraph version 999999
85+
86+
Test time Total Commands Total Errors Command Rate Client p50 with RTT(ms) Graph Internal Time p50 (ms)
87+
10s [100.0%] 100000 0 [0.0%] 9997.46 2.698 (2.698) 2.589 (2.589)
88+
################# RUNTIME STATS #################
89+
Total Duration 10.004 Seconds
90+
Total Commands issued 100000
91+
Total Errors 0 ( 0.000 %)
92+
Throughput summary: 9996 requests per second
93+
## Overall RedisGraph resultset stats table
94+
| QUERY | NODES CREATED | NODES DELETED | LABELS ADDED | PROPERTIES SET | RELATIONSHIPS CREATED | RELATIONSHIPS DELETED |
95+
|-----------------|---------------|---------------|--------------|----------------|------------------------|------------------------|
96+
| CREATE (u:User) | 100000 | 0 | 0 | 0 | 0 | 0 |
97+
| Total | 100000 | 0 | 0 | 0 | 0 | 0 |
98+
## Overall RedisGraph Internal Execution Time summary table
99+
| QUERY | INTERNAL AVG LATENCY(MS) | INTERNAL P50 LATENCY(MS) | INTERNAL P95 LATENCY(MS) | INTERNAL P99 LATENCY(MS) |
100+
|-----------------|----------------------------|--------------------------|--------------------------|--------------------------|
101+
| CREATE (u:User) | 2.599 | 2.589 | 2.912 | 3.648 |
102+
| Total | 2.599 | 2.589 | 2.912 | 3.648 |
103+
## Overall Client Latency summary table
104+
| QUERY | OPS/SEC | TOTAL CALLS | TOTAL ERRORS | AVG LATENCY(MS) | P50 LATENCY(MS) | P95 LATENCY(MS) | P99 LATENCY(MS) |
105+
|-----------------|---------|-------------|--------------|------------------|-----------------|-----------------|-----------------|
106+
| CREATE (u:User) | 9996 | 100000 | 0 | 2.745 | 2.698 | 3.048 | 4.007 |
107+
| Total | 9996 | 100000 | 0 | 2.745 | 2.698 | 3.048 | 4.007 |
108+
2021/07/12 11:44:23 Saving JSON results file to benchmark-results.json
73109
```
74110

75111

76-
## Sample output - running in loop mode ( Ctrl+c to stop )
112+
## Sample output - running mixed read and writes benchmark
77113

78114
```
79-
$ redisgraph-benchmark-go -l -graph-key graph "CREATE (:Rider {name:'A'})-[:rides]->(:Team {name:'Z'})"
80-
Debug level: 0.
81-
Running in loop until you hit Ctrl+C
82-
Test time Total Commands Total Errors Command Rate Client p50 with RTT(ms) Graph Internal p50 with RTT(ms)
83-
^C 11s [----%] 136649 0 [0.0%] 7854.48 3.667 0.000
84-
received Ctrl-c - shutting down
85-
86-
################# RUNTIME STATS #################
87-
Total Duration 11.516 Seconds
88-
Total Commands issued 140704
89-
Total Errors 0 ( 0.000 %)
90-
Throughput summary: 12217 requests per second
91-
Overall Client Latency summary (msec):
92-
p50 p95 p99
93-
3.751 6.887 8.623
94-
################## GRAPH STATS ##################
95-
Total Empty resultsets 140705 ( 100.000 %)
96-
Total Nodes created 281410
97-
Total Nodes deleted 0
98-
Total Labels added 0
99-
Total Properties set 281410
100-
Total Relationships created 140705
101-
Total Relationships deleted 0
102-
Overall RedisGraph Internal Execution time Latency summary (msec):
103-
p50 p95 p99
104-
0.000 0.000 0.000
115+
$ redisgraph-benchmark-go -n 100000 -graph-key graph -query "CREATE (u:User)" -query-ratio 0.5 -query-ro "MATCH (n) return COUNT(n)" -query-ratio 0.5
116+
2021/07/12 11:45:38 redisgraph-benchmark-go (git_sha1:)
117+
2021/07/12 11:45:38 RTS export disabled.
118+
2021/07/12 11:45:38 Debug level: 0.
119+
2021/07/12 11:45:38 Using random seed: 12345.
120+
2021/07/12 11:45:38 Total clients: 50. Commands per client: 2000 Total commands: 100000
121+
2021/07/12 11:45:38 Trying to extract RedisGraph version info
122+
2021/07/12 11:45:38 Detected RedisGraph version 999999
123+
124+
Test time Total Commands Total Errors Command Rate Client p50 with RTT(ms) Graph Internal Time p50 (ms)
125+
10s [100.0%] 100000 0 [0.0%] 9996.09 1.179 (1.179) 0.155 (0.155)
126+
################# RUNTIME STATS #################
127+
Total Duration 10.004 Seconds
128+
Total Commands issued 100000
129+
Total Errors 0 ( 0.000 %)
130+
Throughput summary: 9996 requests per second
131+
## Overall RedisGraph resultset stats table
132+
| QUERY | NODES CREATED | NODES DELETED | LABELS ADDED | PROPERTIES SET | RELATIONSHIPS CREATED | RELATIONSHIPS DELETED |
133+
|---------------------------|---------------|---------------|--------------|----------------|------------------------|------------------------|
134+
| CREATE (u:User) | 49921 | 0 | 0 | 0 | 0 | 0 |
135+
| MATCH (n) return COUNT(n) | 0 | 0 | 0 | 0 | 0 | 0 |
136+
| Total | 49921 | 0 | 0 | 0 | 0 | 0 |
137+
## Overall RedisGraph Internal Execution Time summary table
138+
| QUERY | INTERNAL AVG LATENCY(MS) | INTERNAL P50 LATENCY(MS) | INTERNAL P95 LATENCY(MS) | INTERNAL P99 LATENCY(MS) |
139+
|---------------------------|----------------------------|--------------------------|--------------------------|--------------------------|
140+
| CREATE (u:User) | 3.825 | 3.913 | 4.639 | 5.249 |
141+
| MATCH (n) return COUNT(n) | 0.050 | 0.048 | 0.067 | 0.100 |
142+
| Total | 1.935 | 0.155 | 4.442 | 4.929 |
143+
## Overall Client Latency summary table
144+
| QUERY | OPS/SEC | TOTAL CALLS | TOTAL ERRORS | AVG LATENCY(MS) | P50 LATENCY(MS) | P95 LATENCY(MS) | P99 LATENCY(MS) |
145+
|---------------------------|---------|-------------|--------------|------------------|-----------------|-----------------|-----------------|
146+
| CREATE (u:User) | 4990 | 49921 | 0 | 4.041 | 4.061 | 4.843 | 5.930 |
147+
| MATCH (n) return COUNT(n) | 5006 | 50079 | 0 | 0.236 | 0.178 | 0.442 | 1.201 |
148+
| Total | 9996 | 100000 | 0 | 2.135 | 1.179 | 4.611 | 5.287 |
149+
2021/07/12 11:45:48 Saving JSON results file to benchmark-results.json
105150
```

globals.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ var clientSide_AllQueries_InstantLatencies *hdrhistogram.Histogram
4141
var serverSide_AllQueries_GraphInternalTime_InstantLatencies *hdrhistogram.Histogram
4242

4343
var benchmarkQueries arrayStringParameters
44+
var benchmarkQueriesRO arrayStringParameters
4445
var benchmarkQueryRates arrayStringParameters
4546

4647
const Inf = rate.Limit(math.MaxFloat64)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.13
44

55
require (
66
github.com/HdrHistogram/hdrhistogram-go v1.0.1
7-
github.com/RedisGraph/redisgraph-go v1.0.1-0.20210122150500-aa0feaa960ce
7+
github.com/RedisGraph/redisgraph-go v1.0.1-0.20210524170722-ddcecfd1bef5
88
github.com/RedisTimeSeries/redistimeseries-go v1.4.4
99
github.com/gomodule/redigo v2.0.0+incompatible
1010
github.com/google/go-cmp v0.5.4 // indirect

multi-query.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ func sample(cdf []float32) int {
1616
return bucket
1717
}
1818

19-
func prepareCommandsDistribution(cmds []string, cmdRates []float64) (int, []float32) {
19+
func prepareCommandsDistribution(queries arrayStringParameters, cmds []string, cmdRates []float64) (int, []float32) {
2020
var totalDifferentCommands = len(cmds)
2121
var totalRateSum = 0.0
2222
var err error
23-
for i, rawCmdString := range benchmarkQueries {
23+
for i, rawCmdString := range queries {
2424
cmds[i] = rawCmdString
2525
if i >= len(benchmarkQueryRates) {
2626
cmdRates[i] = 1
@@ -38,11 +38,11 @@ func prepareCommandsDistribution(cmds []string, cmdRates []float64) (int, []floa
3838
log.Fatalf("Total ratio should be 1.0 ( currently is %f )", totalRateSum)
3939
}
4040
// probability density function
41-
if len(benchmarkQueryRates) > 0 && (len(benchmarkQueryRates) != len(benchmarkQueries)) {
42-
log.Fatalf("When specifiying -query-rate parameter, you need to have the same number of -query and -query-rate parameters. Number of time -query ( %d ) != Number of times -query-params ( %d )", len(benchmarkQueries), len(benchmarkQueryRates))
41+
if len(benchmarkQueryRates) > 0 && (len(benchmarkQueryRates) != (len(benchmarkQueries) + len(benchmarkQueriesRO))) {
42+
log.Fatalf("When specifiying -query-rate parameter, you need to have the same number of -query/-query-ro and -query-rate parameters. Number of time -query ( %d ) != Number of times -query-params ( %d )", len(benchmarkQueries), (len(benchmarkQueryRates) + len(benchmarkQueriesRO)))
4343
}
44-
pdf := make([]float32, len(benchmarkQueries))
45-
cdf := make([]float32, len(benchmarkQueries))
44+
pdf := make([]float32, len(queries))
45+
cdf := make([]float32, len(queries))
4646
for i := 0; i < len(cmdRates); i++ {
4747
pdf[i] = float32(cmdRates[i])
4848
cdf[i] = 0

redisgraph-bechmark-go.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ func main() {
2828
randomIntMin := flag.Int64("random-int-min", 1, "__rand_int__ lower value limit. __rand_int__ distribution is uniform Random")
2929
randomIntMax := flag.Int64("random-int-max", 1000000, "__rand_int__ upper value limit. __rand_int__ distribution is uniform Random")
3030
graphKey := flag.String("graph-key", "graph", "graph key.")
31-
flag.Var(&benchmarkQueries, "query", "Specify a RedisGraph query to send in quotes. Each command that you specify is run with its ratio. For example: -query=\"CREATE (n)\" -query-ratio=2")
32-
flag.Var(&benchmarkQueryRates, "query-ratio", "The query ratio vs other queries used in the same benchmark. Each command that you specify is run with its ratio. For example: -query=\"CREATE (n)\" -query-ratio=10 -query=\"MATCH (n) RETURN n\" -query-ratio=1")
31+
flag.Var(&benchmarkQueries, "query", "Specify a RedisGraph query to send in quotes. Each command that you specify is run with its ratio. For example: -query=\"CREATE (n)\" -query-ratio=1")
32+
flag.Var(&benchmarkQueriesRO, "query-ro", "Specify a RedisGraph read-only query to send in quotes. You can run multiple commands (both read/write) on the same benchmark. Each command that you specify is run with its ratio. For example: -query=\"CREATE (n)\" -query-ratio=0.5 -query-ro=\"MATCH (n) RETURN n\" -query-ratio=0.5")
33+
flag.Var(&benchmarkQueryRates, "query-ratio", "The query ratio vs other queries used in the same benchmark. Each command that you specify is run with its ratio. For example: -query=\"CREATE (n)\" -query-ratio=0.5 -query=\"MATCH (n) RETURN n\" -query-ratio=0.5")
3334
jsonOutputFile := flag.String("json-out-file", "benchmark-results.json", "Name of json output file to output benchmark results. If not set, will not print to json.")
3435
cliUpdateTick := flag.Duration("reporting-period", time.Second*10, "Period to report stats.")
3536
// data sink
@@ -98,9 +99,20 @@ func main() {
9899
} else {
99100
log.Printf("Running in loop until you hit Ctrl+C\n")
100101
}
101-
queries := make([]string, len(benchmarkQueries))
102-
cmdRates := make([]float64, len(benchmarkQueries))
103-
totalDifferentCommands, cdf := prepareCommandsDistribution(queries, cmdRates)
102+
queries := make([]string, len(benchmarkQueries)+len(benchmarkQueriesRO))
103+
queryIsReadOnly := make([]bool, len(benchmarkQueries)+len(benchmarkQueriesRO))
104+
cmdRates := make([]float64, len(benchmarkQueries)+len(benchmarkQueriesRO))
105+
readAndWriteQueries := append(benchmarkQueries, benchmarkQueriesRO...)
106+
107+
for i := 0; i < len(queries); i++ {
108+
queryIsReadOnly[i] = false
109+
// read-only queries are located after the read/write ones in queries
110+
// so we start on len(benchmarkQueries) to tag them
111+
if i >= len(benchmarkQueries) {
112+
queryIsReadOnly[i] = true
113+
}
114+
}
115+
totalDifferentCommands, cdf := prepareCommandsDistribution(readAndWriteQueries, queries, cmdRates)
104116

105117
createRequiredGlobalStructs(totalDifferentCommands)
106118

@@ -144,7 +156,7 @@ func main() {
144156
if uint64(client_id) == (*clients - uint64(1)) {
145157
clientTotalCmds = samplesPerClientRemainder + samplesPerClient
146158
}
147-
go ingestionRoutine(&rgs[client_id], *continueOnError, queries, cdf, *randomIntMin, randLimit, clientTotalCmds, *loop, *debug, &wg, useRateLimiter, rateLimiter, graphDatapointsChann)
159+
go ingestionRoutine(&rgs[client_id], *continueOnError, queries, queryIsReadOnly, cdf, *randomIntMin, randLimit, clientTotalCmds, *loop, *debug, &wg, useRateLimiter, rateLimiter, graphDatapointsChann)
148160
}
149161

150162
// enter the update loopupdateCLIupdateCLI

workers.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import (
1111
"time"
1212
)
1313

14-
func ingestionRoutine(rg *redisgraph.Graph, continueOnError bool, cmdS []string, commandsCDF []float32, randomIntPadding, randomIntMax int64, number_samples uint64, loop bool, debug_level int, wg *sync.WaitGroup, useLimiter bool, rateLimiter *rate.Limiter, statsChannel chan GraphQueryDatapoint) {
14+
func ingestionRoutine(rg *redisgraph.Graph, continueOnError bool, cmdS []string, commandIsRO []bool, commandsCDF []float32, randomIntPadding, randomIntMax int64, number_samples uint64, loop bool, debug_level int, wg *sync.WaitGroup, useLimiter bool, rateLimiter *rate.Limiter, statsChannel chan GraphQueryDatapoint) {
1515
defer wg.Done()
1616
for i := 0; uint64(i) < number_samples || loop; i++ {
1717
cmdPos := sample(commandsCDF)
18-
sendCmdLogic(rg, cmdS[cmdPos], randomIntPadding, randomIntMax, cmdPos, continueOnError, debug_level, useLimiter, rateLimiter, statsChannel)
18+
sendCmdLogic(rg, cmdS[cmdPos], commandIsRO[cmdPos], randomIntPadding, randomIntMax, cmdPos, continueOnError, debug_level, useLimiter, rateLimiter, statsChannel)
1919
}
2020
}
2121

22-
func sendCmdLogic(rg *redisgraph.Graph, query string, randomIntPadding, randomIntMax int64, cmdPos int, continueOnError bool, debug_level int, useRateLimiter bool, rateLimiter *rate.Limiter, statsChannel chan GraphQueryDatapoint) {
22+
func sendCmdLogic(rg *redisgraph.Graph, query string, readOnly bool, randomIntPadding, randomIntMax int64, cmdPos int, continueOnError bool, debug_level int, useRateLimiter bool, rateLimiter *rate.Limiter, statsChannel chan GraphQueryDatapoint) {
2323
if useRateLimiter {
2424
r := rateLimiter.ReserveN(time.Now(), int(1))
2525
time.Sleep(r.Delay())
@@ -28,7 +28,11 @@ func sendCmdLogic(rg *redisgraph.Graph, query string, randomIntPadding, randomIn
2828
var queryResult *redisgraph.QueryResult
2929
processedQuery := processQuery(query, randomIntPadding, randomIntMax)
3030
startT := time.Now()
31-
queryResult, err = rg.Query(processedQuery)
31+
if readOnly {
32+
queryResult, err = rg.ROQuery(processedQuery)
33+
} else {
34+
queryResult, err = rg.Query(processedQuery)
35+
}
3236
endT := time.Now()
3337

3438
duration := endT.Sub(startT)

0 commit comments

Comments
 (0)