Skip to content

Commit f94dfec

Browse files
authored
Memtier without docker (#192)
* adding support to run memtier_benchmark locally without docker * fixed formatting * adding taskset when running memtier_benchmark outside of docker
1 parent 5fd5958 commit f94dfec

File tree

2 files changed

+87
-44
lines changed

2 files changed

+87
-44
lines changed

redis_benchmarks_specification/__runner__/args.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ def create_client_runner_args(project_name):
184184
type=int,
185185
help="override memtier test-time for each benchmark. By default will preserve test time specified in test spec",
186186
)
187+
parser.add_argument(
188+
"--benchmark_local_install",
189+
default=False,
190+
action="store_true",
191+
help="Assume benchmarking tool (e.g. memtier benchmark) is installed locally and execute it without using a docker container.",
192+
)
187193
parser.add_argument(
188194
"--override-test-runs",
189195
default=1,

redis_benchmarks_specification/__runner__/runner.py

Lines changed: 81 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ def process_self_contained_coordinator_stream(
552552
test_tls_key,
553553
test_tls_cacert,
554554
resp_version,
555+
args.benchmark_local_install,
555556
password,
556557
oss_cluster_api_enabled,
557558
)
@@ -652,32 +653,49 @@ def process_self_contained_coordinator_stream(
652653
profiler_frequency,
653654
profiler_call_graph_mode,
654655
)
655-
logging.info(
656-
"Using docker image {} as benchmark client image (cpuset={}) with the following args: {}".format(
657-
client_container_image,
658-
client_cpuset_cpus,
659-
benchmark_command_str,
660-
)
661-
)
656+
662657
# run the benchmark
663658
benchmark_start_time = datetime.datetime.now()
664659

665-
client_container_stdout = docker_client.containers.run(
666-
image=client_container_image,
667-
volumes={
668-
temporary_dir_client: {
669-
"bind": client_mnt_point,
670-
"mode": "rw",
660+
if args.benchmark_local_install:
661+
logging.info("Running memtier benchmark outside of docker")
662+
benchmark_command_str = "taskset -c " + client_cpuset_cpus + " " + benchmark_command_str
663+
logging.info(
664+
"Running memtier benchmark command {}".format(
665+
benchmark_command_str
666+
)
667+
)
668+
stream = os.popen(benchmark_command_str)
669+
client_container_stdout = stream.read()
670+
move_command = "mv {} {}".format(
671+
local_benchmark_output_filename, temporary_dir_client
672+
)
673+
os.system(move_command)
674+
else:
675+
logging.info(
676+
"Using docker image {} as benchmark client image (cpuset={}) with the following args: {}".format(
677+
client_container_image,
678+
client_cpuset_cpus,
679+
benchmark_command_str,
680+
)
681+
)
682+
683+
client_container_stdout = docker_client.containers.run(
684+
image=client_container_image,
685+
volumes={
686+
temporary_dir_client: {
687+
"bind": client_mnt_point,
688+
"mode": "rw",
689+
},
671690
},
672-
},
673-
auto_remove=True,
674-
privileged=True,
675-
working_dir=benchmark_tool_workdir,
676-
command=benchmark_command_str,
677-
network_mode="host",
678-
detach=False,
679-
cpuset_cpus=client_cpuset_cpus,
680-
)
691+
auto_remove=True,
692+
privileged=True,
693+
working_dir=benchmark_tool_workdir,
694+
command=benchmark_command_str,
695+
network_mode="host",
696+
detach=False,
697+
cpuset_cpus=client_cpuset_cpus,
698+
)
681699

682700
benchmark_end_time = datetime.datetime.now()
683701
benchmark_duration_seconds = (
@@ -971,6 +989,7 @@ def data_prepopulation_step(
971989
tls_key=None,
972990
tls_cacert=None,
973991
resp_version=None,
992+
benchmark_local_install=False,
974993
password=None,
975994
oss_cluster_api_enabled=False,
976995
):
@@ -1012,32 +1031,50 @@ def data_prepopulation_step(
10121031
override_memtier_test_time_preload,
10131032
)
10141033

1015-
logging.info(
1016-
"Using docker image {} as benchmark PRELOAD image (cpuset={}) with the following args: {}".format(
1017-
preload_image,
1018-
client_cpuset_cpus,
1019-
preload_command_str,
1020-
)
1021-
)
10221034
# run the benchmark
10231035
preload_start_time = datetime.datetime.now()
10241036

1025-
client_container_stdout = docker_client.containers.run(
1026-
image=preload_image,
1027-
volumes={
1028-
temporary_dir: {
1029-
"bind": client_mnt_point,
1030-
"mode": "rw",
1037+
if benchmark_local_install:
1038+
logging.info("Running memtier benchmark outside of docker")
1039+
1040+
preload_command_str = "taskset -c " + client_cpuset_cpus + " " + preload_command_str
1041+
logging.info(
1042+
"Pre-loading using memtier benchmark command {}".format(
1043+
preload_command_str
1044+
)
1045+
)
1046+
stream = os.popen(preload_command_str)
1047+
client_container_stdout = stream.read()
1048+
1049+
move_command = "mv {} {}".format(
1050+
local_benchmark_output_filename, temporary_dir
1051+
)
1052+
os.system(move_command)
1053+
1054+
else:
1055+
logging.info(
1056+
"Using docker image {} as benchmark PRELOAD image (cpuset={}) with the following args: {}".format(
1057+
preload_image,
1058+
client_cpuset_cpus,
1059+
preload_command_str,
1060+
)
1061+
)
1062+
client_container_stdout = docker_client.containers.run(
1063+
image=preload_image,
1064+
volumes={
1065+
temporary_dir: {
1066+
"bind": client_mnt_point,
1067+
"mode": "rw",
1068+
},
10311069
},
1032-
},
1033-
auto_remove=True,
1034-
privileged=True,
1035-
working_dir=benchmark_tool_workdir,
1036-
command=preload_command_str,
1037-
network_mode="host",
1038-
detach=False,
1039-
cpuset_cpus=client_cpuset_cpus,
1040-
)
1070+
auto_remove=True,
1071+
privileged=True,
1072+
working_dir=benchmark_tool_workdir,
1073+
command=preload_command_str,
1074+
network_mode="host",
1075+
detach=False,
1076+
cpuset_cpus=client_cpuset_cpus,
1077+
)
10411078

10421079
preload_end_time = datetime.datetime.now()
10431080
preload_duration_seconds = calculate_client_tool_duration_and_check(

0 commit comments

Comments
 (0)