Skip to content

Commit

Permalink
Auxiliary changes for java client benchmarking. (#630)
Browse files Browse the repository at this point in the history
* Auxiliary changes for java client benchmarking.

Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand authored Dec 6, 2023
1 parent b5fc593 commit 825595c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 14 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ jobs:
distribution: "temurin"
java-version: ${{ matrix.java }}

- name: Install and run protoc (protobuf)
- name: Install protoc (protobuf)
run: |
sudo apt update
sudo apt install -y protobuf-compiler
mkdir -p java/client/src/main/java/org/babushka/javababushka/generated
protoc -Iprotobuf=babushka-core/src/protobuf/ --java_out=java/client/src/main/java/org/babushka/javababushka/generated babushka-core/src/protobuf/*.proto
- name: Build rust part
working-directory: java
run: cargo build
run: cargo build --release

- name: Start Redis
run: docker run -p 6379:6379 -p 8001:8001 -d redis/redis-stack
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ int num_of_concurrent_tasks
{"num_of_tasks", num_of_concurrent_tasks},
{"data_size", data_size},
{"tps", tps},
{"clientCount", clients.Length},
{"client_count", clients.Length},
{"is_cluster", "false"}
};
result = result
Expand Down
37 changes: 34 additions & 3 deletions benchmarks/install_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ runAllBenchmarks=1
runPython=0
runNode=0
runCsharp=0
runJava=0
runRust=0
concurrentTasks="1 10 100 1000"
dataSize="100 4000"
clientCount="1"
chosenClients="all"
host="localhost"
port=6379
tlsFlag="--tls"
javaTlsFlag="-tls"

function runPythonBenchmark(){
# generate protobuf files
Expand Down Expand Up @@ -68,6 +71,11 @@ function runCSharpBenchmark(){
dotnet run --configuration Release --resultsFile=../$1 --dataSize $2 --concurrentTasks $concurrentTasks --clients $chosenClients --host $host --clientCount $clientCount $tlsFlag $portFlag
}

function runJavaBenchmark(){
cd ${BENCH_FOLDER}/../java
./gradlew run --args="-resultsFile \"${BENCH_FOLDER}/$1\" -dataSize \"$2\" -concurrentTasks \"$concurrentTasks\" -clients \"$chosenClients\" -host $host $javaPortFlag -clientCount \"$clientCount\" $javaTlsFlag $javaClusterFlag"
}

function runRustBenchmark(){
rustConcurrentTasks=
for value in $concurrentTasks
Expand Down Expand Up @@ -109,7 +117,7 @@ function resultFileName() {

function Help() {
echo Running the script without any arguments runs all benchmarks.
echo Pass -node, -csharp, -python as arguments in order to run the node, csharp, or python benchmarks accordingly.
echo Pass -node, -csharp, -python, -java as arguments in order to run the node, csharp, python, or java benchmarks accordingly.
echo Multiple such flags can be passed.
echo Pass -no-csv to skip analysis of the results.
echo
Expand Down Expand Up @@ -185,6 +193,21 @@ do
runAllBenchmarks=0
runNode=1
;;
-java)
runAllBenchmarks=0
runJava=1
chosenClients="Babushka"
;;
-lettuce)
runAllBenchmarks=0
runJava=1
chosenClients="lettuce_async"
;;
-jedis)
runAllBenchmarks=0
runJava=1
chosenClients="Jedis"
;;
-csharp)
runAllBenchmarks=0
runCsharp=1
Expand All @@ -205,12 +228,15 @@ do
-no-csv) writeResultsCSV=0 ;;
-no-tls)
tlsFlag=
javaTlsFlag=
;;
-is-cluster)
clusterFlag="--clusterModeEnabled"
javaClusterFlag="-clusterModeEnabled"
;;
-port)
portFlag="--port "$2
javaPortFlag="-port "$2
shift
;;
esac
Expand Down Expand Up @@ -242,6 +268,13 @@ do
runCSharpBenchmark $csharpResults $currentDataSize
fi

if [ $runAllBenchmarks == 1 ] || [ $runJava == 1 ];
then
javaResults=$(resultFileName java $currentDataSize)
resultFiles+=$javaResults" "
runJavaBenchmark $javaResults $currentDataSize
fi

if [ $runAllBenchmarks == 1 ] || [ $runRust == 1 ];
then
rustResults=$(resultFileName rust $currentDataSize)
Expand All @@ -250,8 +283,6 @@ do
fi
done



flushDB

if [ $writeResultsCSV == 1 ];
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/node/node_benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ async function run_clients(
num_of_tasks: num_of_concurrent_tasks,
data_size,
tps,
clientCount: clients.length,
client_count: clients.length,
is_cluster,
...set_latency_results,
...get_existing_latency_results,
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/python/python_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ async def run_clients(
"num_of_tasks": num_of_concurrent_tasks,
"data_size": data_size,
"tps": tps,
"clientCount": len(clients),
"client_count": len(clients),
"is_cluster": is_cluster,
},
**get_existing_latency_results,
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async fn perform_benchmark(args: Args) {
Value::Number((number_of_operations as i64 * 1000 / stopwatch.elapsed_ms()).into()),
);
results_json.insert(
"clientCount".to_string(),
"client_count".to_string(),
Value::Number(args.client_count.into()),
);
results_json.insert(
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/utilities/csv_exporter.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/python3

import csv
import json
import os
Expand All @@ -12,7 +14,7 @@
"is_cluster",
"num_of_tasks",
"data_size",
"clientCount",
"client_count",
"tps",
"get_non_existing_p50_latency",
"get_non_existing_p90_latency",
Expand All @@ -39,7 +41,7 @@

json_file_name = os.path.basename(json_file_full_path)

languages = ["csharp", "node", "python", "rust"]
languages = ["csharp", "node", "python", "rust", "java"]
language = next(
(language for language in languages if language in json_file_name), None
)
Expand Down
1 change: 0 additions & 1 deletion java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@ spotless {
}
}
// End of Spotless section

Empty file modified java/gradlew.bat
100644 → 100755
Empty file.

0 comments on commit 825595c

Please sign in to comment.