Skip to content

Commit c80d61a

Browse files
Added watchdog feature to keep track of current aws bench VMs. Enabled tracking rdb load time (#131)
* [add] Included track of benchmark duration. Small refactor/reuse of code within break/by timeseries * Bumping version from 0.2.1 to 0.2.2 * [add] added watchdog feature to keep track of current aws bench VMs. Enabled tracking rdb load time
1 parent aa9ef5e commit c80d61a

File tree

16 files changed

+761
-390
lines changed

16 files changed

+761
-390
lines changed

poetry.lock

Lines changed: 23 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redisbench-admin"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
description = "Redis benchmark run helper. A wrapper around Redis and Redis Modules benchmark tools ( ftsb_redisearch, memtier_benchmark, redis-benchmark, aibench, etc... )."
55
authors = ["filipecosta90 <[email protected]>"]
66
readme = "README.md"
@@ -27,6 +27,7 @@ GitPython = "^3.1.12"
2727
PyYAML = "^5.4.0"
2828
wget = "^3.2"
2929
pytablewriter = "^0.60.0"
30+
sshtunnel = "^0.4.0"
3031

3132
[tool.poetry.dev-dependencies]
3233
pytest = "^4.6"

redisbench_admin/cli.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from redisbench_admin.run_local.run_local import run_local_command_logic
2020
from redisbench_admin.run_remote.args import create_run_remote_arguments, LOG_LEVEL
2121
from redisbench_admin.run_remote.run_remote import run_remote_command_logic
22+
from redisbench_admin.watchdog.args import create_watchdog_arguments
23+
from redisbench_admin.watchdog.watchdog import watchdog_command_logic
2224

2325

2426
def populate_with_poetry_data():
@@ -73,14 +75,22 @@ def main():
7375
parser = create_extract_arguments(parser)
7476
elif requested_tool == "export":
7577
parser = create_export_arguments(parser)
78+
elif requested_tool == "watchdog":
79+
parser = create_watchdog_arguments(parser)
7680
elif requested_tool == "--version":
7781
print_version(project_name, project_version)
7882
sys.exit(0)
7983
elif requested_tool == "--help":
8084
print_help(project_name, project_version)
8185
sys.exit(0)
8286
else:
83-
valid_tool_options = ["run-local", "run-remote", "export", "extract"]
87+
valid_tool_options = [
88+
"run-local",
89+
"run-remote",
90+
"export",
91+
"extract",
92+
"watchdog",
93+
]
8494
print_invalid_tool_option(requested_tool, valid_tool_options)
8595
sys.exit(1)
8696

@@ -94,6 +104,8 @@ def main():
94104
export_command_logic(args)
95105
if requested_tool == "extract":
96106
extract_command_logic(args)
107+
if requested_tool == "watchdog":
108+
watchdog_command_logic(args)
97109

98110

99111
def print_invalid_tool_option(requested_tool, valid_tool_options):
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Apache License Version 2.0
2+
#
3+
# Copyright (c) 2021., Redis Labs Modules
4+
# All rights reserved.
5+
#

redisbench_admin/export/common/common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,16 @@ def split_key_metrics_by_step(key_metrics_specs):
7272
return key_metrics_by_step
7373

7474

75-
def get_or_none(dictionary, prop: str):
75+
def get_or_none(dictionary, prop: str, inner_prop=None):
7676
result = None
7777
if prop in dictionary:
7878
result = dictionary[prop]
79+
if inner_prop is not None:
80+
if inner_prop in result:
81+
result = result[inner_prop]
82+
else:
83+
None
84+
7985
return result
8086

8187

redisbench_admin/profilers/perf.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import subprocess
1111
import time
1212

13+
1314
from redisbench_admin.profilers.pprof import (
1415
PPROF_FORMAT_TEXT,
1516
run_pprof,
@@ -19,6 +20,18 @@
1920
from redisbench_admin.utils.utils import whereis
2021

2122

23+
PERF_CALLGRAPH_MODE_DEFAULT = "lbr"
24+
LINUX_PERF_SETTINGS_MESSAGE = (
25+
"If running in non-root user please confirm that you have:\n"
26+
+ " - access to Kernel address maps."
27+
+ " Check if `0` ( disabled ) appears from the output of `cat /proc/sys/kernel/kptr_restrict`\n"
28+
+ ' If not then fix via: `sudo sh -c " echo 0 > /proc/sys/kernel/kptr_restrict"`\n'
29+
+ " - permission to collect stats."
30+
+ " Check if `-1` appears from the output of `cat /proc/sys/kernel/perf_event_paranoid`\n"
31+
+ " If not then fix via: `sudo sh -c 'echo -1 > /proc/sys/kernel/perf_event_paranoid'`\n"
32+
)
33+
34+
2235
class Perf:
2336
def __init__(self):
2437
"""
@@ -29,13 +42,11 @@ def __init__(self):
2942
if not self.perf:
3043
self.perf = "perf"
3144

32-
self.stack_collapser = os.getenv("STACKCOLLAPSE_PATH")
33-
if not self.stack_collapser:
34-
self.stack_collapser = STACKCOLLAPSE_PATH
35-
36-
self.flamegraph_utity = os.getenv("FLAMEGRAPH_PATH")
37-
if not self.flamegraph_utity:
38-
self.flamegraph_utity = FLAMEGRAPH_PATH
45+
self.stack_collapser = os.getenv("STACKCOLLAPSE_PATH", STACKCOLLAPSE_PATH)
46+
self.flamegraph_utity = os.getenv("FLAMEGRAPH_PATH", FLAMEGRAPH_PATH)
47+
self.callgraph_mode = os.getenv(
48+
"PERF_CALLGRAPH_MODE", PERF_CALLGRAPH_MODE_DEFAULT
49+
)
3950

4051
self.output = None
4152
self.profiler_process = None
@@ -44,6 +55,7 @@ def __init__(self):
4455
self.profiler_process_exit_code = None
4556
self.trace_file = None
4657
self.collapsed_stack_file = None
58+
self.stack_collapse_file = None
4759
self.collapsed_stacks = []
4860
self.pid = None
4961
self.started_profile = False
@@ -71,7 +83,7 @@ def retrieve_perf_version(self):
7183
self.version_minor = m.group(2)
7284
return m, self.version_major, self.version_minor
7385

74-
def generate_record_command(self, pid, output, frequency=None, call_graph="lbr"):
86+
def generate_record_command(self, pid, output, frequency=None):
7587
self.output = output
7688
self.pid = pid
7789
cmd = [
@@ -85,7 +97,7 @@ def generate_record_command(self, pid, output, frequency=None, call_graph="lbr")
8597
"--output",
8698
output,
8799
"--call-graph",
88-
call_graph,
100+
self.callgraph_mode,
89101
]
90102
if frequency:
91103
cmd += ["--freq", "{}".format(frequency)]
@@ -172,13 +184,7 @@ def stop_profile(self, **kwargs):
172184
"Profiler process exit with error. Exit code: {}\n\n".format(
173185
self.profiler_process_exit_code
174186
)
175-
+ "If running in non-root user please confirm that you have:\n"
176-
+ " - access to Kernel address maps."
177-
+ " Check if `0` ( disabled ) appears from the output of `cat /proc/sys/kernel/kptr_restrict`\n"
178-
+ ' If not then fix via: `sudo sh -c " echo 0 > /proc/sys/kernel/kptr_restrict"`\n'
179-
+ " - permission to collect stats."
180-
+ " Check if `-1` appears from the output of `cat /proc/sys/kernel/perf_event_paranoid`\n"
181-
+ " If not then fix via: `sudo sh -c 'echo -1 > /proc/sys/kernel/perf_event_paranoid'`\n"
187+
+ LINUX_PERF_SETTINGS_MESSAGE
182188
)
183189

184190
except OSError as e:

redisbench_admin/run/common.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import datetime as dt
88
import logging
9+
import os
910

1011
from redisbench_admin.run.redis_benchmark.redis_benchmark import (
1112
prepare_redis_benchmark_command,
@@ -28,6 +29,8 @@
2829
extract_perbranch_timeseries_from_results,
2930
)
3031

32+
BENCHMARK_REPETITIONS = int(os.getenv("BENCHMARK_REPETITIONS", 1))
33+
3134

3235
def prepare_benchmark_parameters(
3336
benchmark_config,
@@ -221,3 +224,16 @@ def get_start_time_vars(start_time=None):
221224
start_time_ms = int((start_time - dt.datetime(1970, 1, 1)).total_seconds() * 1000)
222225
start_time_str = start_time.strftime("%Y-%m-%d-%H-%M-%S")
223226
return start_time, start_time_ms, start_time_str
227+
228+
229+
def execute_init_commands(benchmark_config, r, dbconfig_keyname="dbconfig"):
230+
cmds = None
231+
if dbconfig_keyname in benchmark_config:
232+
for k in benchmark_config[dbconfig_keyname]:
233+
if "init_commands" in k:
234+
cmds = k["init_commands"]
235+
if cmds is not None:
236+
for cmd in cmds:
237+
cmd_split = cmd.split(None, 2)
238+
stdout = r.execute_command(*cmd_split)
239+
print(stdout)

redisbench_admin/run_local/run_local.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from redisbench_admin.run.common import (
2424
prepare_benchmark_parameters,
2525
get_start_time_vars,
26+
execute_init_commands,
2627
)
2728
from redisbench_admin.run_local.args import PROFILE_FREQ
2829
from redisbench_admin.utils.benchmark_config import (
@@ -149,7 +150,6 @@ def run_local_command_logic(args):
149150

150151
r = redis.StrictRedis(port=args.port)
151152
stdout = r.execute_command("info modules")
152-
print(stdout)
153153
(
154154
module_names,
155155
_,
@@ -525,16 +525,3 @@ def which_local(benchmark_tool, executable, full_path, which_benchmark_tool):
525525
which_benchmark_tool = full_path_filename
526526
break
527527
return which_benchmark_tool
528-
529-
530-
def execute_init_commands(benchmark_config, r, dbconfig_keyname="dbconfig"):
531-
cmds = None
532-
if dbconfig_keyname in benchmark_config:
533-
for k in benchmark_config[dbconfig_keyname]:
534-
if "init_commands" in k:
535-
cmds = k["init_commands"]
536-
if cmds is not None:
537-
for cmd in cmds:
538-
cmd_split = cmd.split(None, 2)
539-
stdout = r.execute_command(*cmd_split)
540-
print(stdout)

redisbench_admin/run_remote/args.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@
88
import socket
99

1010
# environment variables
11-
PERFORMANCE_RTS_PUSH = bool(os.getenv("PUSH_RTS", False))
12-
PERFORMANCE_RTS_AUTH = os.getenv("PERFORMANCE_RTS_AUTH", None)
13-
PERFORMANCE_RTS_HOST = os.getenv("PERFORMANCE_RTS_HOST", 6379)
14-
PERFORMANCE_RTS_PORT = os.getenv("PERFORMANCE_RTS_PORT", None)
15-
TERRAFORM_BIN_PATH = os.getenv("TERRAFORM_BIN_PATH", "terraform")
11+
from redisbench_admin.utils.remote import (
12+
TERRAFORM_BIN_PATH,
13+
PERFORMANCE_RTS_HOST,
14+
PERFORMANCE_RTS_PORT,
15+
PERFORMANCE_RTS_AUTH,
16+
PERFORMANCE_RTS_PUSH,
17+
)
1618

1719
LOG_LEVEL = logging.INFO
1820
if os.getenv("VERBOSE", "1") == "0":
1921
LOG_LEVEL = logging.WARN
2022

23+
DEFAULT_TRIGGERING_ENV = socket.gethostname()
24+
TRIGGERING_ENV = os.getenv("TRIGGERING_ENV", DEFAULT_TRIGGERING_ENV)
25+
2126

2227
def create_run_remote_arguments(parser):
2328
parser.add_argument("--module_path", type=str, required=True)
@@ -45,7 +50,7 @@ def create_run_remote_arguments(parser):
4550
"You can use `--required-module` more than once",
4651
)
4752
parser.add_argument("--github_branch", type=str, default=None, nargs="?", const="")
48-
parser.add_argument("--triggering_env", type=str, default=socket.gethostname())
53+
parser.add_argument("--triggering_env", type=str, default=TRIGGERING_ENV)
4954
parser.add_argument("--terraform_bin_path", type=str, default=TERRAFORM_BIN_PATH)
5055
parser.add_argument("--setup_name_sufix", type=str, default="")
5156
parser.add_argument(

0 commit comments

Comments
 (0)