99from pathlib import Path
1010import 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+ )
1218import docker
1319import redis
1420from docker .models .containers import Container
3642 LOG_LEVEL ,
3743 REDIS_HEALTH_CHECK_INTERVAL ,
3844 REDIS_SOCKET_TIMEOUT ,
45+ S3_BUCKET_NAME ,
3946)
4047from 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