Skip to content

Commit 9f9f047

Browse files
profiler-daemon failure improvements (#273)
* [fix] Fixed spin_up_redis_cluster_remote_redis after module config parameters change * Fixed profiler daemon log extraction
1 parent 4c517fc commit 9f9f047

File tree

16 files changed

+168
-132
lines changed

16 files changed

+168
-132
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Installation is done using pip, the package installer for Python, in the followi
3434
python3 -m pip install redisbench-admin
3535
```
3636

37+
## Profiler daemon
38+
39+
3740
## Development
3841

3942
1. Install [pypoetry](https://python-poetry.org/) to manage your dependencies and trigger tooling.

docs/export.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Optional arguments:
7373
branch/ref time-series are created (default: None)
7474
--local-dir LOCAL_DIR
7575
local dir to use as storage (default: ./)
76-
--logname LOGNAME logname to write the logs to (default: None)
76+
--local_file PERF_DAEMON_LOGNAME local_file to write the logs to (default: None)
7777
--github_actor [GITHUB_ACTOR]
7878
--github_repo GITHUB_REPO
7979
--github_org GITHUB_ORG

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.6.10"
3+
version = "0.6.11"
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]>","Redis Performance Group <[email protected]>"]
66
readme = "README.md"

redisbench_admin/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def main():
7171
"--local-dir", type=str, default="./", help="local dir to use as storage"
7272
)
7373
parser.add_argument(
74-
"--logname", type=str, default=None, help="logname to write the logs to"
74+
"--logname", type=str, default=None, help="local file to write the logs to"
7575
)
7676

7777
if requested_tool == "run-remote":

redisbench_admin/profilers/daemon.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,26 @@
44
# All rights reserved.
55
#
66

7+
import argparse
8+
import json
9+
710
# !/usr/bin/env python3
811
import logging
9-
10-
import argparse
12+
import os
13+
import sys
1114

1215
import botocore
13-
from flask import Flask, request
1416
import daemonize
15-
import json
16-
import sys
17-
import os
17+
from flask import Flask, request
1818

1919
from redisbench_admin.cli import populate_with_poetry_data
20+
from redisbench_admin.profilers.perf import Perf
21+
from redisbench_admin.profilers.perf_daemon_caller import PERF_DAEMON_LOGNAME
22+
from redisbench_admin.profilers.profile_local import local_profilers_platform_checks
2023
from redisbench_admin.run.args import S3_BUCKET_NAME
24+
from redisbench_admin.run.common import get_start_time_vars
2125
from redisbench_admin.run.s3 import get_test_s3_bucket_path
2226
from redisbench_admin.utils.remote import extract_git_vars
23-
24-
from redisbench_admin.profilers.perf import Perf
25-
from redisbench_admin.run.common import get_start_time_vars
26-
27-
from redisbench_admin.run_local.profile_local import local_profilers_platform_checks
2827
from redisbench_admin.utils.utils import upload_artifacts_to_s3
2928

3029
PID_FILE = "/tmp/perfdaemon.pid"
@@ -34,7 +33,6 @@
3433
LOG_LEVEL = logging.INFO
3534
LOG_FORMAT = "%(asctime)s %(levelname)-4s %(message)s"
3635
LOG_DATEFMT = "%Y-%m-%d %H:%M:%S"
37-
LOGNAME = "/tmp/perf-daemon.log"
3836

3937
app = Flask(__name__)
4038
app.use_reloader = False
@@ -53,8 +51,10 @@ def main(self):
5351
app.run(host="0.0.0.0", debug=False, port=5000)
5452

5553
def set_app_loggers(self, app):
56-
print("Writting log to {}".format(LOGNAME))
57-
handler = logging.handlers.RotatingFileHandler(LOGNAME, maxBytes=1024 * 1024)
54+
print("Writting log to {}".format(PERF_DAEMON_LOGNAME))
55+
handler = logging.handlers.RotatingFileHandler(
56+
PERF_DAEMON_LOGNAME, maxBytes=1024 * 1024
57+
)
5858
logging.getLogger("werkzeug").setLevel(logging.DEBUG)
5959
logging.getLogger("werkzeug").addHandler(handler)
6060
app.logger.setLevel(LOG_LEVEL)

redisbench_admin/profilers/perf.py

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

13-
1413
from redisbench_admin.profilers.pprof import (
1514
PPROF_FORMAT_TEXT,
1615
run_pprof,
@@ -19,7 +18,6 @@
1918
from redisbench_admin.profilers.profilers import STACKCOLLAPSE_PATH, FLAMEGRAPH_PATH
2019
from redisbench_admin.utils.utils import whereis
2120

22-
2321
PERF_CALLGRAPH_MODE_DEFAULT = "fp"
2422
LINUX_PERF_SETTINGS_MESSAGE = (
2523
"If running in non-root user please confirm that you have:\n"

redisbench_admin/profilers/perf_daemon_caller.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
# All rights reserved.
55
#
66
import logging
7+
78
import requests
9+
810
from redisbench_admin.utils.remote import extract_git_vars
911

1012
PERF_CALLGRAPH_MODE_DEFAULT = "fp"
13+
PERF_DAEMON_LOGNAME = "/tmp/perf-daemon.log"
1114

1215

1316
class PerfDaemonRemoteCaller:

redisbench_admin/profilers/pprof.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
import logging
88
import os
9-
import subprocess
109
import re
10+
import subprocess
1111

1212
PPROF_FORMAT_TEXT = "-text"
1313
PPROF_FORMAT_PS = "-ps"

redisbench_admin/run_local/profile_local.py renamed to redisbench_admin/profilers/profilers_local.py

Lines changed: 5 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,24 @@
11
# BSD 3-Clause License
22
#
3-
# Copyright (c) 2021., Redis Labs Modules
3+
# Copyright (c) 2022., Redis Labs Modules
44
# All rights reserved.
55
#
6+
7+
# BSD 3-Clause License
8+
#
9+
#
610
import logging
711
import platform
812

913
from cpuinfo import get_cpu_info
10-
from pytablewriter import MarkdownTableWriter
1114

1215
from redisbench_admin.profilers.perf import Perf
1316
from redisbench_admin.profilers.vtune import Vtune
1417
from redisbench_admin.run.args import PROFILE_FREQ, MAX_PROFILERS_PER_TYPE
15-
1618
from redisbench_admin.run.s3 import get_test_s3_bucket_path
1719
from redisbench_admin.utils.utils import upload_artifacts_to_s3
1820

1921

20-
def local_profilers_print_artifacts_table(profilers_artifacts_matrix):
21-
logging.info("Printing profiler generated artifacts")
22-
test_cases = []
23-
profilers = []
24-
use_local_file = True
25-
table_name = "Profiler artifacts"
26-
for row in profilers_artifacts_matrix:
27-
test_case = row[0]
28-
profiler = row[1]
29-
artifact = row[2]
30-
local_file = row[3]
31-
s3_link = row[4]
32-
if s3_link is not None:
33-
if len(s3_link) > 0:
34-
use_local_file = False
35-
36-
if test_case not in test_cases:
37-
test_cases.append(test_case)
38-
if profiler not in profilers:
39-
profilers.append(profiler)
40-
41-
# We only need to print the testcase if there are more than one
42-
use_test_cases_row = True
43-
44-
if len(test_cases) == 1:
45-
use_test_cases_row = False
46-
test_case = test_cases[0]
47-
table_name = "{} for testcase {}".format(table_name, test_case)
48-
49-
# We only need to print the profiler type if there are more than one
50-
use_profilers_row = True
51-
if len(profilers) == 1:
52-
use_profilers_row = False
53-
profiler = test_cases[0]
54-
table_name = "{}. Used profiler {}".format(table_name, profiler)
55-
56-
headers = []
57-
if use_test_cases_row:
58-
headers.append("Test Case")
59-
60-
if use_profilers_row:
61-
headers.append("Profiler")
62-
63-
headers.append("Artifact")
64-
if use_local_file:
65-
headers.append("Local file")
66-
else:
67-
headers.append("s3 link")
68-
69-
profilers_final_matrix = []
70-
for row in profilers_artifacts_matrix:
71-
test_case = row[0]
72-
profiler = row[1]
73-
artifact = row[2]
74-
local_file = "{} ".format(row[3])
75-
s3_link = "{} ".format(row[4])
76-
77-
final_row = []
78-
if use_test_cases_row:
79-
final_row.append(test_case)
80-
81-
if use_profilers_row:
82-
final_row.append(profiler)
83-
84-
final_row.append(artifact)
85-
if use_local_file:
86-
final_row.append(local_file)
87-
else:
88-
final_row.append(s3_link)
89-
profilers_final_matrix.append(final_row)
90-
91-
writer = MarkdownTableWriter(
92-
table_name=table_name,
93-
headers=headers,
94-
value_matrix=profilers_final_matrix,
95-
)
96-
writer.write_table()
97-
98-
99-
def get_profilers_rts_key_prefix(triggering_env, tf_github_org, tf_github_repo):
100-
zset_name = "ci.benchmarks.redis.com/{triggering_env}/{github_org}/{github_repo}:profiles".format(
101-
triggering_env=triggering_env,
102-
github_org=tf_github_org,
103-
github_repo=tf_github_repo,
104-
)
105-
return zset_name
106-
107-
10822
def profilers_stop_if_required(
10923
args,
11024
benchmark_duration_seconds,
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# BSD 3-Clause License
2+
#
3+
# Copyright (c) 2022., Redis Labs Modules
4+
# All rights reserved.
5+
#
6+
import logging
7+
8+
from pytablewriter import MarkdownTableWriter
9+
10+
11+
def get_profilers_rts_key_prefix(triggering_env, tf_github_org, tf_github_repo):
12+
zset_name = "ci.benchmarks.redis.com/{triggering_env}/{github_org}/{github_repo}:profiles".format(
13+
triggering_env=triggering_env,
14+
github_org=tf_github_org,
15+
github_repo=tf_github_repo,
16+
)
17+
return zset_name
18+
19+
20+
def local_profilers_print_artifacts_table(profilers_artifacts_matrix):
21+
logging.info("Printing profiler generated artifacts")
22+
test_cases = []
23+
profilers = []
24+
use_local_file = True
25+
table_name = "Profiler artifacts"
26+
for row in profilers_artifacts_matrix:
27+
test_case = row[0]
28+
profiler = row[1]
29+
artifact = row[2]
30+
local_file = row[3]
31+
s3_link = row[4]
32+
if s3_link is not None:
33+
if len(s3_link) > 0:
34+
use_local_file = False
35+
36+
if test_case not in test_cases:
37+
test_cases.append(test_case)
38+
if profiler not in profilers:
39+
profilers.append(profiler)
40+
41+
# We only need to print the testcase if there are more than one
42+
use_test_cases_row = True
43+
44+
if len(test_cases) == 1:
45+
use_test_cases_row = False
46+
test_case = test_cases[0]
47+
table_name = "{} for testcase {}".format(table_name, test_case)
48+
49+
# We only need to print the profiler type if there are more than one
50+
use_profilers_row = True
51+
if len(profilers) == 1:
52+
use_profilers_row = False
53+
profiler = test_cases[0]
54+
table_name = "{}. Used profiler {}".format(table_name, profiler)
55+
56+
headers = []
57+
if use_test_cases_row:
58+
headers.append("Test Case")
59+
60+
if use_profilers_row:
61+
headers.append("Profiler")
62+
63+
headers.append("Artifact")
64+
if use_local_file:
65+
headers.append("Local file")
66+
else:
67+
headers.append("s3 link")
68+
69+
profilers_final_matrix = []
70+
for row in profilers_artifacts_matrix:
71+
test_case = row[0]
72+
profiler = row[1]
73+
artifact = row[2]
74+
local_file = "{} ".format(row[3])
75+
s3_link = "{} ".format(row[4])
76+
77+
final_row = []
78+
if use_test_cases_row:
79+
final_row.append(test_case)
80+
81+
if use_profilers_row:
82+
final_row.append(profiler)
83+
84+
final_row.append(artifact)
85+
if use_local_file:
86+
final_row.append(local_file)
87+
else:
88+
final_row.append(s3_link)
89+
profilers_final_matrix.append(final_row)
90+
91+
writer = MarkdownTableWriter(
92+
table_name=table_name,
93+
headers=headers,
94+
value_matrix=profilers_final_matrix,
95+
)
96+
writer.write_table()

0 commit comments

Comments
 (0)