Skip to content

Commit 452258e

Browse files
authored
Add vector db benchmark (#277)
* Add basic vector_db_benchmark test, add method to create benchmark running command * Add new builder yaml to build redisearch.so * Set autoremove to tru * Add loading vector-db-benchmark results into vdb_results variable * Keep results in results_dict * Reformat files * Reformat self_contained_coordinator.py * Use redis-test engine * Checkout runner.py from main * Fix prepare_vector_db method * Remove debug prints * Remove debug prints from builder
1 parent f2c0f34 commit 452258e

File tree

8 files changed

+262
-77
lines changed

8 files changed

+262
-77
lines changed

redis_benchmarks_specification/__builder__/builder.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ def builder_process_stream(
381381
# build_vars_str,
382382
# )
383383
build_command = "sh -c 'make -j'"
384+
if "build_command" in build_config:
385+
build_command = build_config["build_command"]
384386
if b"build_command" in testDetails:
385387
build_command = testDetails[b"build_command"].decode()
386388
server_name = "redis"
@@ -649,7 +651,13 @@ def generate_benchmark_stream_request(
649651
prefix = f"github_org={github_org}/github_repo={github_repo}/git_branch={str(git_branch)}/git_version={str(git_version)}/git_hash={str(git_hash)}"
650652
for artifact in build_artifacts:
651653
bin_key = f"zipped:artifacts:{prefix}:{id}:{artifact}.zip"
652-
bin_artifact = open(f"{redis_temporary_dir}src/{artifact}", "rb").read()
654+
if artifact == "redisearch.so":
655+
bin_artifact = open(
656+
f"{redis_temporary_dir}modules/redisearch/src/bin/linux-x64-release/search-community/{artifact}",
657+
"rb",
658+
).read()
659+
else:
660+
bin_artifact = open(f"{redis_temporary_dir}src/{artifact}", "rb").read()
653661
bin_artifact_len = len(bytes(bin_artifact))
654662
assert bin_artifact_len > 0
655663
conn.set(bin_key, bytes(bin_artifact), ex=REDIS_BINS_EXPIRE_SECS)

redis_benchmarks_specification/__self_contained_coordinator__/clients.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,27 @@ def prepare_memtier_benchmark_parameters(
2222
benchmark_command_str = benchmark_command_str + " " + clientconfig["arguments"]
2323

2424
return None, benchmark_command_str
25+
26+
27+
def prepare_vector_db_benchmark_parameters(
28+
clientconfig, full_benchmark_path, port, server, password, client_mnt_point
29+
):
30+
benchmark_command = []
31+
# if port is not None:
32+
# benchmark_command.extend(["REDIS_PORT={}".format(port)])
33+
# if password is not None:
34+
# benchmark_command.extend(["REDIS_AUTH={}".format(password)])
35+
benchmark_command.extend(
36+
[
37+
full_benchmark_path,
38+
"--host",
39+
f"{server}",
40+
]
41+
)
42+
benchmark_command.extend(["--engines", clientconfig.get("engines", "redis-test")])
43+
benchmark_command.extend(
44+
["--datasets", clientconfig.get("datasets", "glove-100-angular")]
45+
)
46+
benchmark_command_str = " ".join(benchmark_command)
47+
benchmark_command_str = f"bash -c 'ITERATIONS=1 {benchmark_command_str} && mv /code/results {client_mnt_point}.'"
48+
return None, benchmark_command_str
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
import json
3+
4+
5+
def post_process_vector_db(temporary_dir):
6+
results_dir = os.path.join(temporary_dir, "results")
7+
results = {}
8+
for file in os.listdir(results_dir):
9+
if "upload" in file:
10+
with open(os.path.join(results_dir, file), "r") as f:
11+
upload_results = json.load(f)
12+
results["upload_time"] = upload_results["results"]["upload_time"]
13+
else:
14+
with open(os.path.join(results_dir, file), "r") as f:
15+
query_results = json.load(f)
16+
results["rps"] = query_results["results"]["rps"]
17+
results["precision"] = query_results["results"]["mean_precisions"]
18+
results["total_time"] = query_results["results"]["total_time"]
19+
return results

redis_benchmarks_specification/__self_contained_coordinator__/runners.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
)
5757
from redis_benchmarks_specification.__self_contained_coordinator__.clients import (
5858
prepare_memtier_benchmark_parameters,
59+
prepare_vector_db_benchmark_parameters,
5960
)
6061
from redis_benchmarks_specification.__self_contained_coordinator__.cpuset import (
6162
extract_db_cpu_limit,
@@ -347,9 +348,12 @@ def process_self_contained_coordinator_stream(
347348
# backwards compatible
348349
if benchmark_tool is None:
349350
benchmark_tool = "redis-benchmark"
350-
full_benchmark_path = "/usr/local/bin/{}".format(
351-
benchmark_tool
352-
)
351+
if benchmark_tool == "vector_db_benchmark":
352+
full_benchmark_path = "python /code/run.py"
353+
else:
354+
full_benchmark_path = "/usr/local/bin/{}".format(
355+
benchmark_tool
356+
)
353357

354358
# setup the benchmark
355359
(
@@ -370,32 +374,42 @@ def process_self_contained_coordinator_stream(
370374
local_benchmark_output_filename
371375
)
372376
)
373-
if "memtier_benchmark" not in benchmark_tool:
374-
# prepare the benchmark command
377+
if "memtier_benchmark" in benchmark_tool:
375378
(
376-
benchmark_command,
379+
_,
377380
benchmark_command_str,
378-
) = prepare_benchmark_parameters(
379-
benchmark_config,
381+
) = prepare_memtier_benchmark_parameters(
382+
benchmark_config["clientconfig"],
380383
full_benchmark_path,
381384
redis_proc_start_port,
382385
"localhost",
383386
local_benchmark_output_filename,
384-
False,
385387
benchmark_tool_workdir,
386-
False,
387388
)
388-
else:
389+
elif "vector_db_benchmark" in benchmark_tool:
389390
(
390391
_,
391392
benchmark_command_str,
392-
) = prepare_memtier_benchmark_parameters(
393+
) = prepare_vector_db_benchmark_parameters(
393394
benchmark_config["clientconfig"],
394395
full_benchmark_path,
395396
redis_proc_start_port,
396397
"localhost",
398+
)
399+
else:
400+
# prepare the benchmark command
401+
(
402+
benchmark_command,
403+
benchmark_command_str,
404+
) = prepare_benchmark_parameters(
405+
benchmark_config,
406+
full_benchmark_path,
407+
redis_proc_start_port,
408+
"localhost",
397409
local_benchmark_output_filename,
410+
False,
398411
benchmark_tool_workdir,
412+
False,
399413
)
400414

401415
client_container_image = extract_client_container_image(

0 commit comments

Comments
 (0)