Skip to content

Commit

Permalink
Allow choosing port in benchmark.
Browse files Browse the repository at this point in the history
This will allow us to test vs. local clusters that aren't promised to
use port 6379.
  • Loading branch information
shachlanAmazon authored and acarbonetto committed Sep 26, 2023
1 parent 3fea471 commit 2798fe8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 21 deletions.
22 changes: 1 addition & 21 deletions benchmarks/install_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -247,11 +231,7 @@ do
;;
-is-cluster)
clusterFlag="--clusterModeEnabled"
;;
-port)
portFlag="--port "$2
shift
;;
;;
esac
shift
done
Expand Down
46 changes: 46 additions & 0 deletions benchmarks/node/node_benchmark.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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<void>[] = [];
const bench_json_results: object[] = [];
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 2798fe8

Please sign in to comment.