From e57c1ffb6efa9a3f8361f53c337561bd417cce1b Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Mon, 25 Sep 2023 17:25:41 -0700 Subject: [PATCH] Add dataSize option to java benchmark. (#11) * Add Jedis and Lettuce benchmarks * Start ignoring .gradle files * Update gitignore and remove generated files from git Signed-off-by: acarbonetto * Update gitignore and remove generated files from git Signed-off-by: acarbonetto * Update gitignore and remove generated files from git Signed-off-by: acarbonetto * Add benchmarks for GET non-existing * Revert "Update gitignore and remove generated files from git" This reverts commit d9b26a6664c6bd4426e7fa417d43e70e124338fa. * fix redis-rs submodules Signed-off-by: acarbonetto * Randomize commands in Java benchmarks * rename chooseAction to randomAction * Add a Java benchmarking app (#7) * Add a java app to run benchmarks --------- Signed-off-by: acarbonetto * Add Readme and update install_and_test script to runJava Signed-off-by: acarbonetto * Add Readme and update install_and_test script to runJava Signed-off-by: acarbonetto * Combine java pipeline and java benchmarks (#8) * Merge Pull Request #5 - Add java pipeline. Also changed: * Merged two projects. * Updated CI. * Fixed tests and updated `junit` version. * Spotless. * Add new gradle tasks. Signed-off-by: Yury-Fridlyand * Add sync and async clients both to tests. (#12) * Add sync and async clients both to tests. Signed-off-by: Yury-Fridlyand * Minor fixes. Signed-off-by: Yury-Fridlyand --------- Signed-off-by: Yury-Fridlyand * Add dataSize option to java benchmark. Signed-off-by: Yury-Fridlyand --------- Signed-off-by: acarbonetto Signed-off-by: Yury-Fridlyand Co-authored-by: Jonathan Louie Co-authored-by: acarbonetto Co-authored-by: jonathanl-bq <72158117+jonathanl-bq@users.noreply.github.com> --- benchmarks/install_and_test.sh | 25 +++++++++++++++++-- java/jabushka/benchmarks/build.gradle | 1 + .../javabushka/client/BenchmarkingApp.java | 7 ++++++ .../javabushka/client/utils/Benchmarking.java | 3 ++- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/benchmarks/install_and_test.sh b/benchmarks/install_and_test.sh index 60b4c218ad..86953ad5fb 100755 --- a/benchmarks/install_and_test.sh +++ b/benchmarks/install_and_test.sh @@ -78,6 +78,14 @@ function runJavaBenchmark(){ cd ${BENCH_FOLDER}/java } +function runJavaBenchmark(){ + cd ${BENCH_FOLDER}/../java + echo "./gradlew run --args=\"--resultsFile=${BENCH_FOLDER}/$1 --clients $chosenClients --host $host --port $port\"" +# ./gradlew run --args="--resultsFile=../$1 --dataSize $2 --concurrentTasks $concurrentTasks --clients $chosenClients --host $host --port $port --clientCount $clientCount $tlsFlag" + ./gradlew run --args="--resultsFile=${BENCH_FOLDER}/$1 --clients $chosenClients --host $host --port $port" + cd ${BENCH_FOLDER}/java +} + function runRustBenchmark(){ rustConcurrentTasks= for value in $concurrentTasks @@ -210,6 +218,21 @@ do runJava=1 chosenClients="Jedis" ;; + -java) + runAllBenchmarks=0 + runJava=1 + chosenClients="Babushka" + ;; + -lettuce) + runAllBenchmarks=0 + runJava=1 + chosenClients="Lettuce" + ;; + -lettuce) + runAllBenchmarks=0 + runJava=1 + chosenClients="Jedis" + ;; -csharp) runAllBenchmarks=0 runCsharp=1 @@ -282,8 +305,6 @@ do fi done - - flushDB if [ $writeResultsCSV == 1 ]; diff --git a/java/jabushka/benchmarks/build.gradle b/java/jabushka/benchmarks/build.gradle index 5e21fe3ea6..b6c89b2695 100644 --- a/java/jabushka/benchmarks/build.gradle +++ b/java/jabushka/benchmarks/build.gradle @@ -17,6 +17,7 @@ dependencies { implementation 'redis.clients:jedis:4.4.3' implementation 'io.lettuce:lettuce-core:6.2.6.RELEASE' implementation 'commons-cli:commons-cli:1.5.0' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0' } // Apply a specific Java toolchain to ease working on different environments. diff --git a/java/jabushka/benchmarks/src/main/java/javabushka/client/BenchmarkingApp.java b/java/jabushka/benchmarks/src/main/java/javabushka/client/BenchmarkingApp.java index 36fc5df715..6f8f23f1f9 100644 --- a/java/jabushka/benchmarks/src/main/java/javabushka/client/BenchmarkingApp.java +++ b/java/jabushka/benchmarks/src/main/java/javabushka/client/BenchmarkingApp.java @@ -88,6 +88,7 @@ private static Options getOptions() { options.addOption("c", "configuration", true, "Configuration flag [Release]"); options.addOption("f", "resultsFile", true, "Result filepath []"); + options.addOption("d", "dataSize", true, "Data block size [20]"); options.addOption("C", "concurrentTasks", true, "Number of concurrent tasks [1 10 100]"); options.addOption("l", "clients", true, "one of: all|jedis|lettuce|babushka [all]"); options.addOption("h", "host", true, "host url [localhost]"); @@ -118,6 +119,10 @@ private static RunConfiguration verifyOptions(CommandLine line) throws ParseExce } } + if (line.hasOption("dataSize")) { + runConfiguration.dataSize = Integer.parseInt(line.getOptionValue("dataSize")); + } + if (line.hasOption("concurrentTasks")) { String concurrentTasks = line.getOptionValue("concurrentTasks"); @@ -200,6 +205,7 @@ public boolean isEqual(String other) { public static class RunConfiguration { public String configuration; public Optional resultsFile; + public int dataSize; public List concurrentTasks; public ClientName[] clients; public String host; @@ -210,6 +216,7 @@ public static class RunConfiguration { public RunConfiguration() { configuration = "Release"; resultsFile = Optional.empty(); + dataSize = 20; concurrentTasks = List.of(1, 10, 100); clients = new ClientName[] {ClientName.ALL}; host = "localhost"; diff --git a/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Benchmarking.java b/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Benchmarking.java index 9f8744720e..9555bba2cc 100644 --- a/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Benchmarking.java +++ b/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Benchmarking.java @@ -12,6 +12,7 @@ import javabushka.client.BenchmarkingApp; import javabushka.client.Client; import javabushka.client.SyncClient; +import org.apache.commons.lang3.RandomStringUtils; public class Benchmarking { static final double PROB_GET = 0.8; @@ -154,7 +155,7 @@ public static Map measurePerformance( client.connectToRedis(new ConnectionSettings(config.host, config.port, config.tls)); int iterations = 10000; - String value = "my-value"; + String value = RandomStringUtils.randomAlphanumeric(config.dataSize); if (config.resultsFile.isPresent()) { try {