Created
April 2, 2021 15:50
-
-
Save spmallette/9326ed206dd7bd749104220d82fc620e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
host = "localhost" | |
requests = 10000 | |
cluster = Cluster.open() | |
g = traversal().withRemote(DriverRemoteConnection.using(cluster)) | |
println("vertices at start: " + g.V().count().next()) | |
println("edges at start: " + g.E().count().next()) | |
start = System.currentTimeMillis() | |
(0..<50000).each{ | |
def tx = g.tx() | |
def gtx = tx.begin() | |
def v1 = gtx.addV('person').property('pid', it + 'a').next() | |
def v2 = gtx.addV('person').property('pid', it + 'b').next() | |
gtx.addE('knows').from(v1).to(v2).iterate() | |
gtx.close() | |
if ((it + 1) % 1000 == 0) | |
println("committed: " + (it + 1)) | |
} | |
loadingTime = System.currentTimeMillis() - start | |
cluster.close() | |
rand = new java.util.Random() | |
executor = java.util.concurrent.Executors.newFixedThreadPool(16) | |
cluster = Cluster.open() | |
sessionless = cluster.connect() | |
g = traversal().withRemote(DriverRemoteConnection.using(cluster)) | |
workList = [ | |
wrk0 = { c, s, g -> | |
return { s.submit("Thread.sleep(t)", [t: rand.nextInt(60000)]).all().get() } | |
}, | |
wrk1 = { c, s, g -> | |
return { s.submit("g.V().has('pid',pid).elementMap()", [pid: rand.nextInt(50000) + 'a']).all().get() } | |
}, | |
wrk2 = { c, s, g -> | |
return { s.submit("g.V().has('pid',pid).outE('knows').elementMap()", [pid: rand.nextInt(50000) + 'a']).all().get() } | |
}, | |
wrk3 = { c, s, g -> | |
return { s.submit("g.V().has('pid',pid).out('knows').elementMap()", [pid: rand.nextInt(50000) + 'a']).all().get() } | |
}, | |
wrk4 = { c, s, g -> | |
return { g.V().has('pid',rand.nextInt(50000) + 'a').elementMap().next() } | |
}, | |
wrk5 = { c, s, g -> | |
return { g.V().has('pid',rand.nextInt(50000) + 'a').outE('knows').elementMap().next() } | |
}, | |
wrk6 = { c, s, g -> | |
return { g.V().has('pid',rand.nextInt(50000) + 'a').out('knows').elementMap().next() } | |
}, | |
wrk7 = { c, s, g -> | |
return { | |
def tx = g.tx() | |
def gtx = tx.begin() | |
gtx.V().has('pid',within(rand.nextInt(50000) + 'a', rand.nextInt(50000) + 'b', rand.nextInt(50000) + 'a', rand.nextInt(50000) + 'b')).groupCount().by().by(elementMap()).toList() | |
gtx.V().has('pid',within(rand.nextInt(50000) + 'a', rand.nextInt(50000) + 'b', rand.nextInt(50000) + 'a', rand.nextInt(50000) + 'b')).groupCount().by().by(elementMap()).toList() | |
gtx.V().has('pid',within(rand.nextInt(50000) + 'a', rand.nextInt(50000) + 'b', rand.nextInt(50000) + 'a', rand.nextInt(50000) + 'b')).groupCount().by().by(elementMap()).toList() | |
gtx.V().has('pid',within(rand.nextInt(50000) + 'a', rand.nextInt(50000) + 'b', rand.nextInt(50000) + 'a', rand.nextInt(50000) + 'b')).groupCount().by().by(elementMap()).toList() | |
gtx.V().has('pid',within(rand.nextInt(50000) + 'a', rand.nextInt(50000) + 'b', rand.nextInt(50000) + 'a', rand.nextInt(50000) + 'b')).groupCount().by().by(elementMap()).toList() | |
gtx.close() | |
} | |
}, | |
wrk8 = { c, s, g -> | |
return { | |
def sess = c.connect(java.util.UUID.randomUUID().toString()) | |
sess.submitAsync("g.V().has('pid',pid).out('knows').elementMap()", [pid: rand.nextInt(50000) + 'a']).get() | |
sess.submitAsync("Thread.sleep(t)", [t: rand.nextInt(10000)]).get() | |
sess.submit("g.V().has('pid',pid).outE('knows').elementMap()", [pid: rand.nextInt(50000) + 'a']).all().get() | |
sess.close() | |
} | |
}, | |
wrk9 = { c, s, g -> | |
return { s.submit("g.V().limit(n).order().by('pid').elementMap()", [n: rand.nextInt(1000) + 'a']).all().get() } | |
} | |
] | |
println("started mixed workload") | |
start = System.currentTimeMillis() | |
(0..<requests).each{ | |
def wrk = rand.nextInt(10) | |
// limit the Thread.sleep() requests | |
if (wrk == 0 && rand.nextInt(100) < 90) | |
wrk = wrk + rand.nextInt(9) | |
executor.submit(workList[wrk](cluster, sessionless, g)) | |
// pause sometimes in submitting requests | |
if (rand.nextInt(100) < 10) | |
Thread.sleep(rand.nextInt(1000)) | |
if ((it + 1) % 1000 == 0) | |
println("requests: " + (it + 1)) | |
} | |
executor.shutdown() | |
executor.awaitTermination(1, java.util.concurrent.TimeUnit.DAYS) | |
println("loading time: " + loadingTime) | |
println("vertices at end: " + g.V().count().next()) | |
println("edges at end: " + g.E().count().next()) | |
println("mixed load running time: " + (System.currentTimeMillis() - start)) | |
cluster.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment