3
votes

i'm currently using a Graph Database using Redis for a Julia project.

Sometimes Redis requests are taking 300 ms to execute and i don't understand why. I run a simple request 10.000 times (the code of the request is below) and it took me :

using Redis, BenchmarkTools

conn = RedisConnection(port=6382) Redis.execute_command(conn,["FLUSHDB"])

q = string("CREATE (:Type {nature :'Test',val:'test'})") BenchmarkTools.DEFAULT_PARAMETERS.seconds = 1000 BenchmarkTools.DEFAULT_PARAMETERS.samples = 10000

stats = @benchmark Redis.execute_command(conn,[ "GRAPH.QUERY", "GraphDetection", q])

And got this results :

BenchmarkTools.Trial: memory estimate: 3.09 KiB allocs estimate: 68

minimum time: 1.114 ms (0.00% GC)

median time: 1.249 ms (0.00% GC)

mean time: 18.623 ms (0.00% GC)

maximum time: 303.269 ms (0.00% GC)

samples: 10000 evals/sample: 1

The Huge difference between median time and mean time came from the problem i'm talking about (the request take either [1-3] ms or [300-310] ms )

1
You are creating the same command string and input array over and over, and including it in the timing. Doing that can trigger the garbage collector occasionally. Could you pull it out of the loop to reduce measurement noise? Furthermore, there is no need to convert a string to a string with the string function. Also, Dates.now() is quite heavyweight, use the time or time_ns functions from Base instead. Best would probably be to use the @benchmark macro from BenchmarkTools to calculate performance statistics for you.DNF
Have you disabled snapshotting? I mean commenting out all save commands in your Redis config file and restarting it?Mark Setchell

1 Answers

1
votes

I'm not familiar with Julia but please note RedisGraph report its internal execution time, I'll suggest using this report for measurement,

In addition it would be helpful to understand when (on which sample) did RedisGraph took over 100ms to process the query, usually it is the first query which causes RedisGraph to do some extra work.