Skip to content

Commit b3b2d8c

Browse files
Enabled to use only last N samples of each timeserie on compare tool (#338)
* Updated ann-benchmark to the latest pkg version and extend tests on create_website.py * Enabled to use only last N samples of each timeserie on redisbench-admin compare * Fixed bug introduced in last_n compare tool
1 parent ede8335 commit b3b2d8c

File tree

10 files changed

+96
-49
lines changed

10 files changed

+96
-49
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redisbench-admin"
3-
version = "0.7.35"
3+
version = "0.7.40"
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 <filipecosta.90@gmail.com>","Redis Performance Group <performance@redis.com>"]
66
readme = "README.md"

redisbench_admin/compare/args.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ def create_compare_arguments(parser):
4747
parser.add_argument("--baseline_deployment_name", type=str, default="")
4848
parser.add_argument("--comparison_deployment_name", type=str, default="")
4949
parser.add_argument("--metric_name", type=str, default="Tests.Overall.rps")
50+
parser.add_argument(
51+
"--last_n",
52+
type=int,
53+
default=-1,
54+
help="Use the last N samples for each time-serie. by default will use all available values",
55+
)
5056
parser.add_argument(
5157
"--from-date",
5258
type=lambda s: datetime.datetime.strptime(s, "%Y-%m-%d"),

redisbench_admin/compare/compare.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ def compare_command_logic(args, project_name, project_version):
5454
comparison_deployment_name,
5555
)
5656
)
57+
if args.last_n > 0:
58+
logging.info(
59+
"Using the last {} samples of each timeserie to compute the tables".format(
60+
args.last_n
61+
)
62+
)
5763
from_ts_ms = args.from_timestamp
5864
to_ts_ms = args.to_timestamp
5965
if from_ts_ms is None:
@@ -161,7 +167,7 @@ def compare_command_logic(args, project_name, project_version):
161167
total_stable = 0
162168
total_unstable = 0
163169
total_regressions = 0
164-
noise_waterline = 2.5
170+
noise_waterline = 3
165171
progress = tqdm(unit="benchmark time-series", total=len(test_names))
166172
for test_name in test_names:
167173
filters_baseline = [
@@ -234,7 +240,10 @@ def compare_command_logic(args, project_name, project_version):
234240
if baseline_nsamples > 0:
235241
_, baseline_v = baseline_datapoints[0]
236242
for tuple in baseline_datapoints:
237-
baseline_values.append(tuple[1])
243+
if args.last_n < 0 or (
244+
args.last_n > 0 and len(baseline_values) < args.last_n
245+
):
246+
baseline_values.append(tuple[1])
238247
baseline_df = pd.DataFrame(baseline_values)
239248
baseline_median = float(baseline_df.median())
240249
baseline_v = baseline_median
@@ -249,7 +258,10 @@ def compare_command_logic(args, project_name, project_version):
249258
if comparison_nsamples > 0:
250259
_, comparison_v = comparison_datapoints[0]
251260
for tuple in comparison_datapoints:
252-
comparison_values.append(tuple[1])
261+
if args.last_n < 0 or (
262+
args.last_n > 0 and len(comparison_values) < args.last_n
263+
):
264+
comparison_values.append(tuple[1])
253265
comparison_df = pd.DataFrame(comparison_values)
254266
comparison_median = float(comparison_df.median())
255267
comparison_v = comparison_median
@@ -275,13 +287,13 @@ def compare_command_logic(args, project_name, project_version):
275287
if baseline_pct_change > 10.0:
276288
stamp_b = "UNSTABLE"
277289
baseline_v_str = " {:.0f} +- {:.1f}% {} ({} datapoints)".format(
278-
baseline_v, baseline_pct_change, stamp_b, baseline_nsamples
290+
baseline_v, baseline_pct_change, stamp_b, len(baseline_values)
279291
)
280292
stamp_c = ""
281293
if comparison_pct_change > 10.0:
282294
stamp_c = "UNSTABLE"
283295
comparison_v_str = " {:.0f} +- {:.1f}% {} ({} datapoints)".format(
284-
comparison_v, comparison_pct_change, stamp_c, comparison_nsamples
296+
comparison_v, comparison_pct_change, stamp_c, len(comparison_values)
285297
)
286298
if metric_mode == "higher-better":
287299
percentage_change = (
@@ -297,7 +309,7 @@ def compare_command_logic(args, project_name, project_version):
297309
detected_improvement = False
298310
if percentage_change < 0.0 and not unstable:
299311

300-
if percentage_change < -waterline:
312+
if -waterline >= percentage_change:
301313
detected_regression = True
302314
total_regressions = total_regressions + 1
303315
note = note + " REGRESSION"
@@ -339,19 +351,22 @@ def compare_command_logic(args, project_name, project_version):
339351
)
340352

341353
logging.info("Printing differential analysis between branches")
354+
355+
baseline = baseline_branch if args.baseline_branch else baseline_tag
356+
comparison = comparison_branch if args.comparison_branch else comparison_tag
342357
writer = MarkdownTableWriter(
343358
table_name="Comparison between {} and {} for metric: {}. Time Period from {} to {}. (environment used: {})".format(
344-
baseline_branch,
345-
comparison_branch,
359+
baseline,
360+
comparison,
346361
metric_name,
347362
from_human_str,
348363
to_human_str,
349364
baseline_deployment_name,
350365
),
351366
headers=[
352367
"Test Case",
353-
"Baseline {} (median obs. +- std.dev)".format(baseline_branch),
354-
"Comparison {} (median obs. +- std.dev)".format(comparison_branch),
368+
"Baseline {} (median obs. +- std.dev)".format(baseline),
369+
"Comparison {} (median obs. +- std.dev)".format(comparison),
355370
"% change ({})".format(metric_mode),
356371
"Note",
357372
],

redisbench_admin/environments/oss_cluster.py

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414

1515
def spin_up_local_redis_cluster(
16+
binary,
1617
dbdir,
1718
shard_count,
1819
ip,
@@ -27,8 +28,12 @@ def spin_up_local_redis_cluster(
2728

2829
for master_shard_id in range(1, shard_count + 1):
2930
shard_port = master_shard_id + start_port - 1
30-
31+
binary = binary
32+
if master_shard_id > 1:
33+
binary = "redis-server"
34+
logging.info("Ignoring redis binary definition for primary shard > 1")
3135
command, _ = generate_cluster_redis_server_args(
36+
binary,
3237
dbdir,
3338
local_module_file,
3439
ip,
@@ -133,6 +138,7 @@ def setup_oss_cluster_from_conns(meet_cmds, redis_conns, shard_count):
133138

134139

135140
def generate_cluster_redis_server_args(
141+
binary,
136142
dbdir,
137143
local_module_file,
138144
ip,
@@ -145,34 +151,39 @@ def generate_cluster_redis_server_args(
145151
if logname_prefix is None:
146152
logname_prefix = ""
147153
logfile = "{}cluster-node-port-{}.log".format(logname_prefix, port)
154+
if type(binary) == list:
155+
command = binary
156+
else:
157+
command = [binary]
148158
# start redis-server
149-
command = [
150-
"redis-server",
151-
"--appendonly",
152-
"no",
153-
"--logfile",
154-
logfile,
155-
"--cluster-enabled",
156-
"yes",
157-
"--daemonize",
158-
daemonize,
159-
"--dbfilename",
160-
get_cluster_dbfilename(port),
161-
"--protected-mode",
162-
"no",
163-
"--bind",
164-
"{}".format(ip),
165-
"--cluster-config-file",
166-
"cluster-node-port-{}.config".format(port),
167-
"--save",
168-
"''",
169-
"--cluster-announce-ip",
170-
"{}".format(ip),
171-
"--port",
172-
"{}".format(port),
173-
"--dir",
174-
dbdir,
175-
]
159+
command.extend(
160+
[
161+
"--appendonly",
162+
"no",
163+
"--logfile",
164+
logfile,
165+
"--cluster-enabled",
166+
"yes",
167+
"--daemonize",
168+
daemonize,
169+
"--dbfilename",
170+
get_cluster_dbfilename(port),
171+
"--protected-mode",
172+
"no",
173+
"--bind",
174+
"{}".format(ip),
175+
"--cluster-config-file",
176+
"cluster-node-port-{}.config".format(port),
177+
"--save",
178+
"''",
179+
"--cluster-announce-ip",
180+
"{}".format(ip),
181+
"--port",
182+
"{}".format(port),
183+
"--dir",
184+
dbdir,
185+
]
186+
)
176187
if configuration_parameters is not None:
177188
for parameter, parameter_value in configuration_parameters.items():
178189
command.extend(

redisbench_admin/environments/oss_standalone.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,21 @@ def generate_standalone_redis_server_args(
5050
configuration_parameters=None,
5151
modules_configuration_parameters_map={},
5252
):
53+
if type(binary) == list:
54+
command = binary
55+
else:
56+
command = [binary]
5357
# start redis-server
54-
command = [
55-
binary,
56-
"--save",
57-
"",
58-
"--port",
59-
"{}".format(port),
60-
"--dir",
61-
dbdir,
62-
]
58+
command.extend(
59+
[
60+
"--save",
61+
"",
62+
"--port",
63+
"{}".format(port),
64+
"--dir",
65+
dbdir,
66+
]
67+
)
6368
if configuration_parameters is not None:
6469
for parameter, parameter_value in configuration_parameters.items():
6570
command.extend(

redisbench_admin/run/cluster.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def spin_up_redis_cluster_remote_redis(
122122
shard_port = master_shard_id + start_port - 1
123123

124124
command, logfile = generate_cluster_redis_server_args(
125+
"redis-server",
125126
dbdir_folder,
126127
remote_module_files,
127128
server_private_ip,

redisbench_admin/run/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
)
5353

5454
BENCHMARK_REPETITIONS = int(os.getenv("BENCHMARK_REPETITIONS", 1))
55+
REDIS_BINARY = os.getenv("REDIS_BINARY", "redis-server")
5556

5657

5758
def prepare_benchmark_parameters(

redisbench_admin/run_local/args.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
#
66

77
from redisbench_admin.run.args import common_run_args
8+
from redisbench_admin.run.common import REDIS_BINARY
89

910

1011
def create_run_local_arguments(parser):
1112
parser = common_run_args(parser)
1213
parser.add_argument("--port", type=int, default=6379)
14+
parser.add_argument("--redis-binary", type=str, default=REDIS_BINARY)
1315
return parser

redisbench_admin/run_local/local_db.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636

3737
def local_db_spin(
38+
binary,
3839
args,
3940
benchmark_config,
4041
clusterconfig,
@@ -79,6 +80,7 @@ def local_db_spin(
7980
cluster_api_enabled = True
8081
shard_host = "127.0.0.1"
8182
redis_processes, redis_conns = spin_up_local_redis_cluster(
83+
binary,
8284
temporary_dir,
8385
shard_count,
8486
shard_host,
@@ -106,7 +108,7 @@ def local_db_spin(
106108
)
107109
if setup_type == "oss-standalone":
108110
redis_processes = spin_up_local_redis(
109-
"redis-server",
111+
binary,
110112
args.port,
111113
temporary_dir,
112114
local_module_file,

redisbench_admin/run_local/run_local.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,15 @@ def run_local_command_logic(args, project_name, project_version):
178178
setup_name, setup_type, shard_count
179179
)
180180
)
181+
binary = args.redis_binary
182+
if " " in binary:
183+
binary = binary.split(" ")
181184
(
182185
cluster_api_enabled,
183186
redis_conns,
184187
redis_processes,
185188
) = local_db_spin(
189+
binary,
186190
args,
187191
benchmark_config,
188192
clusterconfig,

0 commit comments

Comments
 (0)