Skip to content

Commit f9dd21c

Browse files
authored
chore(benchmarks): add --artifacts and --configs options to perf-run-scenario (#14406)
The goal is to allow people to select which benchmark configs they want to run, this allows people to skip unrelated/unnecessary configs if they want to iterate quickly locally. Since we added --configs, moved artifacts to --artifacts as well, keeping the other positional arguments for now ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [ ] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
1 parent 0439e35 commit f9dd21c

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

benchmarks/base/run.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,13 @@ def run(scenario_py, cname, cvars, output_dir):
6464
output_dir = sys.argv[1]
6565
print("Saving results to {}".format(output_dir))
6666
config = read_config("config.yaml")
67+
68+
# Filter configs if BENCHMARK_CONFIGS is set
69+
benchmark_configs = os.environ.get("BENCHMARK_CONFIGS")
70+
if benchmark_configs:
71+
allowed_configs = set(c.strip() for c in benchmark_configs.split(","))
72+
config = {k: v for k, v in config.items() if k in allowed_configs}
73+
print("Filtering to configs: {}".format(", ".join(sorted(config.keys()))))
74+
6775
for cname, cvars in config.items():
6876
run("scenario.py", cname, cvars, output_dir)

scripts/perf-run-scenario

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SCRIPTNAME=$(basename $0)
55

66
if [[ $# -lt 3 ]]; then
77
cat << EOF
8-
Usage: ${SCRIPTNAME} <scenario> <version> <version> [artifacts]
8+
Usage: ${SCRIPTNAME} <scenario> <version> <version> [--configs config1,config2,...] [--artifacts path]
99
1010
Versions can be specified in the following formats:
1111
- "ddtrace==0.51.0" - to install a specific version from PyPI
@@ -16,7 +16,8 @@ Examples:
1616
${SCRIPTNAME} span ddtrace==0.51.0 ddtrace==0.50.0
1717
${SCRIPTNAME} span Datadog/[email protected] Datadog/[email protected]
1818
${SCRIPTNAME} span ddtrace==2.8.4 .
19-
${SCRIPTNAME} span ddtrace==0.51.0 ddtrace==0.50.0 ./artifacts/
19+
${SCRIPTNAME} span ddtrace==0.51.0 ddtrace==0.50.0 --artifacts ./artifacts/
20+
${SCRIPTNAME} django_simple ddtrace==2.8.4 . --configs tracer,baseline
2021
2122
EOF
2223
exit 1
@@ -45,10 +46,27 @@ DDTRACE_V2="$1"
4546
shift
4647

4748
ARTIFACTS=""
48-
if [[ $# -gt 0 ]]; then
49-
ARTIFACTS="$1"
50-
shift
51-
fi
49+
CONFIGS=""
50+
51+
# Parse remaining arguments
52+
while [[ $# -gt 0 ]]; do
53+
case $1 in
54+
--configs)
55+
CONFIGS="$2"
56+
shift # past argument
57+
shift # past value
58+
;;
59+
--artifacts)
60+
ARTIFACTS="$2"
61+
shift # past argument
62+
shift # past value
63+
;;
64+
*)
65+
echo "Unknown option: $1"
66+
exit 1
67+
;;
68+
esac
69+
done
5270

5371

5472
# Build scenario image
@@ -69,6 +87,7 @@ CMD+=" -v $(pwd):/src/ \
6987
-e CARGO_BUILD_JOBS=12 \
7088
-e DDTRACE_INSTALL_V1=$(expand_git_version $DDTRACE_V1) \
7189
-e DDTRACE_INSTALL_V2=$(expand_git_version $DDTRACE_V2) \
90+
-e BENCHMARK_CONFIGS=${CONFIGS} \
7291
${TAG}"
7392

7493
$CMD

0 commit comments

Comments
 (0)