Skip to content

Commit 8d7b451

Browse files
slice4eMartin Dimitrovfilipecosta90
authored
Allows the standalone runner to collect perf profiles (#111)
* change the auto-remove to True, so that we dont accumulate un-used containers * Enable profilers in the standalone runner Co-authored-by: Martin Dimitrov <[email protected]> Co-authored-by: filipe oliveira <[email protected]>
1 parent bd5d615 commit 8d7b451

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed

redis_benchmarks_specification/__runner__/args.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
DATASINK_RTS_USER,
99
DATASINK_RTS_PUSH,
1010
MACHINE_NAME,
11+
PROFILERS_ENABLED,
12+
PROFILERS,
13+
PROFILERS_DEFAULT,
14+
ALLOWED_PROFILERS,
1115
)
1216

1317

@@ -64,6 +68,17 @@ def create_client_runner_args(project_name):
6468
action="store_true",
6569
help="uploads the results to RedisTimeSeries. Proper credentials are required",
6670
)
71+
parser.add_argument("--profilers", type=str, default=PROFILERS)
72+
parser.add_argument(
73+
"--enable-profilers",
74+
default=PROFILERS_ENABLED,
75+
action="store_true",
76+
help="Enable Identifying On-CPU and Off-CPU Time using perf/ebpf/vtune tooling. "
77+
+ "By default the chosen profilers are {}".format(PROFILERS_DEFAULT)
78+
+ "Full list of profilers: {}".format(ALLOWED_PROFILERS)
79+
+ "Only available on x86 Linux platform and kernel version >= 4.9",
80+
)
81+
6782
parser.add_argument(
6883
"--flushall_on_every_test_start",
6984
default=False,

redis_benchmarks_specification/__runner__/runner.py

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
from pathlib import Path
1010
import shutil
1111

12+
from redisbench_admin.profilers.profilers_local import (
13+
check_compatible_system_and_kernel_and_prepare_profile,
14+
profilers_start_if_required,
15+
local_profilers_platform_checks,
16+
profilers_stop_if_required,
17+
)
1218
import docker
1319
import redis
1420
from docker.models.containers import Container
@@ -36,6 +42,7 @@
3642
LOG_LEVEL,
3743
REDIS_HEALTH_CHECK_INTERVAL,
3844
REDIS_SOCKET_TIMEOUT,
45+
S3_BUCKET_NAME,
3946
)
4047
from redis_benchmarks_specification.__common__.package import (
4148
get_version_string,
@@ -124,6 +131,20 @@ def main():
124131
preserve_temporary_client_dirs = args.preserve_temporary_client_dirs
125132
docker_client = docker.from_env()
126133
home = str(Path.home())
134+
135+
profilers_list = []
136+
profilers_enabled = args.enable_profilers
137+
if profilers_enabled:
138+
profilers_list = args.profilers.split(",")
139+
res = check_compatible_system_and_kernel_and_prepare_profile(args)
140+
if res is False:
141+
logging.error(
142+
"Requested for the following profilers to be enabled but something went wrong: {}.".format(
143+
" ".join(profilers_list)
144+
)
145+
)
146+
exit(1)
147+
127148
logging.info("Running the benchmark specs.")
128149

129150
process_self_contained_coordinator_stream(
@@ -136,6 +157,8 @@ def main():
136157
testsuite_spec_files,
137158
{},
138159
running_platform,
160+
profilers_enabled,
161+
profilers_list,
139162
tls_enabled,
140163
tls_skip_verify,
141164
tls_cert,
@@ -198,6 +221,8 @@ def process_self_contained_coordinator_stream(
198221
testsuite_spec_files,
199222
topologies_map,
200223
running_platform,
224+
profilers_enabled=False,
225+
profilers_list=[],
201226
tls_enabled=False,
202227
tls_skip_verify=False,
203228
tls_cert=None,
@@ -258,6 +283,34 @@ def process_self_contained_coordinator_stream(
258283
ssl_check_hostname=False,
259284
)
260285
r.ping()
286+
redis_pids = []
287+
first_redis_pid = r.info()["process_id"]
288+
redis_pids.append(first_redis_pid)
289+
290+
setup_name = "oss-standalone"
291+
github_actor = "{}-{}".format(
292+
tf_triggering_env, running_platform
293+
)
294+
dso = "redis-server"
295+
profilers_artifacts_matrix = []
296+
297+
collection_summary_str = ""
298+
if profilers_enabled:
299+
collection_summary_str = (
300+
local_profilers_platform_checks(
301+
dso,
302+
github_actor,
303+
git_branch,
304+
tf_github_repo,
305+
git_hash,
306+
)
307+
)
308+
logging.info(
309+
"Using the following collection summary string for profiler description: {}".format(
310+
collection_summary_str
311+
)
312+
)
313+
261314

262315
ceil_client_cpu_limit = extract_client_cpu_limit(benchmark_config)
263316
client_cpuset_cpus, current_cpu_pos = generate_cpuset_cpus(
@@ -369,6 +422,23 @@ def process_self_contained_coordinator_stream(
369422
client_container_image = extract_client_container_image(
370423
benchmark_config
371424
)
425+
profiler_call_graph_mode = "dwarf"
426+
profiler_frequency = 99
427+
428+
# start the profile
429+
(
430+
profiler_name,
431+
profilers_map,
432+
) = profilers_start_if_required(
433+
profilers_enabled,
434+
profilers_list,
435+
redis_pids,
436+
setup_name,
437+
start_time_str,
438+
test_name,
439+
profiler_frequency,
440+
profiler_call_graph_mode,
441+
)
372442
logging.info(
373443
"Using docker image {} as benchmark client image (cpuset={}) with the following args: {}".format(
374444
client_container_image,
@@ -402,8 +472,23 @@ def process_self_contained_coordinator_stream(
402472
benchmark_end_time, benchmark_start_time
403473
)
404474
)
475+
(_, overall_tabular_data_map,) = profilers_stop_if_required(
476+
datasink_push_results_redistimeseries,
477+
benchmark_duration_seconds,
478+
collection_summary_str,
479+
dso,
480+
tf_github_org,
481+
tf_github_repo,
482+
profiler_name,
483+
profilers_artifacts_matrix,
484+
profilers_enabled,
485+
profilers_map,
486+
redis_pids,
487+
S3_BUCKET_NAME,
488+
test_name,
489+
)
490+
405491
logging.info("Printing client tool stdout output")
406-
print()
407492
if args.flushall_on_every_test_end:
408493
logging.info("Sending FLUSHALL to the DB")
409494
r.flushall()

0 commit comments

Comments
 (0)