From 2798fe8c0822e171dd234c9a6b9b4c03d79395e2 Mon Sep 17 00:00:00 2001 From: Shachar Langbeheim Date: Mon, 18 Sep 2023 14:02:50 +0000 Subject: [PATCH] Allow choosing port in benchmark. This will allow us to test vs. local clusters that aren't promised to use port 6379. --- benchmarks/install_and_test.sh | 22 +-------------- benchmarks/node/node_benchmark.ts | 46 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/benchmarks/install_and_test.sh b/benchmarks/install_and_test.sh index 2c9857d20c..a6db3c0e51 100755 --- a/benchmarks/install_and_test.sh +++ b/benchmarks/install_and_test.sh @@ -78,22 +78,6 @@ 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 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 @@ -247,11 +231,7 @@ do ;; -is-cluster) clusterFlag="--clusterModeEnabled" - ;; - -port) - portFlag="--port "$2 - shift - ;; + ;; esac shift done diff --git a/benchmarks/node/node_benchmark.ts b/benchmarks/node/node_benchmark.ts index 401680967e..6167793903 100644 --- a/benchmarks/node/node_benchmark.ts +++ b/benchmarks/node/node_benchmark.ts @@ -1,4 +1,8 @@ import { Logger, RedisClient, RedisClusterClient } from "babushka-rs"; +<<<<<<< HEAD +======= +import commandLineArgs from "command-line-args"; +>>>>>>> 6c1e8fa (Allow choosing port in benchmark.) import { writeFileSync } from "fs"; import percentile from "percentile"; import { RedisClientType, createClient, createCluster } from "redis"; @@ -22,6 +26,28 @@ enum ChosenAction { // Demo - Setting the internal logger to log every log that has a level of info and above, and save the logs to the first.log file. Logger.setLoggerConfig("info", "first.log"); +<<<<<<< HEAD +======= +const PORT = 6379; +function getAddress(host: string, port: number): string { + return `${host}:${port}`; +} + +function getAddressWithProtocol( + host: string, + useTLS: boolean, + port: number +): string { + const protocol = useTLS ? "rediss" : "redis"; + return `${protocol}://${getAddress(host, port)}`; +} + +const PROB_GET = 0.8; +const PROB_GET_EXISTING_KEY = 0.8; +const SIZE_GET_KEYSPACE = 3750000; // 3.75 million +const SIZE_SET_KEYSPACE = 3000000; // 3 million + +>>>>>>> 6c1e8fa (Allow choosing port in benchmark.) let started_tasks_counter = 0; const running_tasks: Promise[] = []; const bench_json_results: object[] = []; @@ -232,7 +258,11 @@ async function main( if (clients_to_run == "all") { const clients = await createClients(clientCount, async () => { const node = { +<<<<<<< HEAD url: getAddress(host, useTLS, port), +======= + url: getAddressWithProtocol(host, useTLS, port), +>>>>>>> 6c1e8fa (Allow choosing port in benchmark.) }; const node_redis_client = clusterModeEnabled ? createCluster({ @@ -264,6 +294,22 @@ async function main( } } +<<<<<<< HEAD +======= +const optionDefinitions = [ + { name: "resultsFile", type: String }, + { name: "dataSize", type: String }, + { name: "concurrentTasks", type: String, multiple: true }, + { name: "clients", type: String }, + { name: "host", type: String }, + { name: "clientCount", type: String, multiple: true }, + { name: "tls", type: Boolean, defaultValue: false }, + { name: "clusterModeEnabled", type: Boolean, defaultValue: false }, + { name: "port", type: Number, defaultValue: PORT }, +]; +const receivedOptions = commandLineArgs(optionDefinitions); + +>>>>>>> 6c1e8fa (Allow choosing port in benchmark.) const number_of_iterations = (num_of_concurrent_tasks: number) => Math.min(Math.max(100000, num_of_concurrent_tasks * 10000), 10000000);