Skip to content

Commit a8360a6

Browse files
Privacy Sandbox Teamcopybara-github
Privacy Sandbox Team
authored andcommitted
feat: Add multiple run and fixed invocations to script
Bug: b/387804510 Change-Id: I7aae7e4273b557a8f4a06eb704f3fb16dc860eee GitOrigin-RevId: 1202250b09c6ba28b32dca977b9da3bcff85ce69
1 parent 91189d5 commit a8360a6

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

src/roma/byob/benchmark/byob_rps

+23-6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ declare INPUT_ARGS="${DEFAULT_INPUT_ARGS}"
3434
declare -r DEFAULT_OUTPUT_FILE=""
3535
declare OUTPUT_FILE="${DEFAULT_OUTPUT_FILE}"
3636

37+
declare -r -i DEFAULT_RUNS=1
38+
declare -i RUNS=${DEFAULT_RUNS}
39+
40+
declare -r -i DEFAULT_TOTAL_INVOCATIONS=0
41+
declare -i TOTAL_INVOCATIONS=${DEFAULT_TOTAL_INVOCATIONS}
42+
3743
function usage() {
3844
local exitval=${1-1}
3945
cat &>/dev/stderr << USAGE
@@ -44,6 +50,8 @@ usage:
4450
--burst-size <range> number of RPCs within a burst. Default: ${DEFAULT_BURST_SIZE}.
4551
--num-workers <range> number of workers to execute, as an integer or a range (min:increment:max or min:max). Default: ${DEFAULT_NUM_WORKERS}.
4652
--num-qps <range> queries per second, as an integer or a range (min:increment:max or min:max). Default: ${DEFAULT_QPS}.
53+
--runs <int> number of times to run each configuration. Default: ${DEFAULT_RUNS}.
54+
--total-invocations <int> total number of invocations to execute. Default: ${DEFAULT_TOTAL_INVOCATIONS}.
4755
--mode <string> traffic generator mode: 'byob' or 'v8'. Default: byob
4856
--output-file <string> path to output JSON. Default: print to stdout.
4957
@@ -74,6 +82,8 @@ while [[ $# -gt 0 ]]; do
7482
--burst-size) BURST_SIZE="$2"; shift 2 || usage 1 ;;
7583
--num-workers) NUM_WORKERS="$2"; shift 2 || usage 1 ;;
7684
--num-qps) QPS="$2"; shift 2 || usage 1 ;;
85+
--runs) RUNS=$2; shift 2 || usage 1 ;;
86+
--total-invocations) TOTAL_INVOCATIONS=$2; shift 2 || usage 1 ;;
7787
--mode) MODE="$2"; shift 2 || usage 1 ;;
7888

7989
--cpus) CPUS=$2; shift 2 || usage 1 ;;
@@ -108,7 +118,8 @@ function run_test() {
108118
declare -r -i burst_size=$1; shift
109119
declare -r -i qps=$1; shift
110120
declare -r -i num_workers=$1; shift
111-
printf "running qps: %d\n" ${qps}
121+
declare -r run_id=$1; shift
122+
printf "running qps: %d with run_id: %s\n" ${qps} "${run_id}"
112123

113124
declare -a CMD_ARGS=(
114125
"--burst_size=${burst_size}"
@@ -117,6 +128,8 @@ function run_test() {
117128
"--queries_per_second=${qps}"
118129
"--mode=${MODE}"
119130
"--output_file=${OUTPUT_FILE}"
131+
"--total_invocations=${TOTAL_INVOCATIONS}"
132+
"--run_id=${run_id}"
120133
)
121134

122135
if [[ ${MODE} == v8 ]]; then
@@ -171,14 +184,18 @@ declare -a NUM_WORKERS_LIST=($(seq ${NUM_WORKERS//:/ }))
171184
declare -a BURST_SIZE_LIST=($(seq ${BURST_SIZE//:/ }))
172185

173186
declare -i qps num_workers burst_size
187+
declare BASE_RUN_ID
174188
for qps in "${QPS_LIST[@]}"; do
175189
for num_workers in "${NUM_WORKERS_LIST[@]}"; do
176190
for burst_size in "${BURST_SIZE_LIST[@]}"; do
177-
run_test ${burst_size} ${qps} ${num_workers}
178-
if [[ ${FAILURE_COUNT} -ge ${MAX_FAILURES} ]]; then
179-
printf "%d failures. Exiting\n" ${FAILURE_COUNT}
180-
exit 1
181-
fi
191+
BASE_RUN_ID="$(mktemp --dry-run XXXX)"
192+
for ((run=1; run<=RUNS; run++)); do
193+
run_test ${burst_size} ${qps} ${num_workers} "${BASE_RUN_ID}"-"${run}"
194+
if [[ ${FAILURE_COUNT} -ge ${MAX_FAILURES} ]]; then
195+
printf "%d failures. Exiting\n" ${FAILURE_COUNT}
196+
exit 1
197+
fi
198+
done
182199
done
183200
done
184201
done

src/roma/byob/benchmark/traffic_generator.cc

+15-3
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,19 @@
4545
#include "src/util/periodic_closure.h"
4646
#include "src/util/status_macro/status_macros.h"
4747

48-
ABSL_FLAG(std::string, run_id, "",
48+
ABSL_FLAG(std::string, run_id,
49+
google::scp::core::common::ToString(
50+
google::scp::core::common::Uuid::GenerateUuid()),
4951
"Arbitrary identifier included in the report");
5052
ABSL_FLAG(int, num_workers, 84, "Number of pre-created workers");
5153
ABSL_FLAG(int, queries_per_second, 42,
5254
"Number of queries to be sent in a second");
5355
ABSL_FLAG(int, burst_size, 14,
5456
"Number of times to call ProcessRequest for a single query");
5557
ABSL_FLAG(int, num_queries, 10'000, "Number of queries to be sent");
58+
ABSL_FLAG(int, total_invocations, 0,
59+
"Number of invocations to be sent. If non-zero, overrides "
60+
"num_queries, and num_queries = total_invocations / burst_size.");
5661
ABSL_FLAG(privacy_sandbox::server_common::byob::Mode, sandbox,
5762
privacy_sandbox::server_common::byob::Mode::kModeSandbox,
5863
"Run BYOB in sandbox mode.");
@@ -83,14 +88,21 @@ int main(int argc, char** argv) {
8388
absl::SetStderrThreshold(absl::LogSeverity::kInfo);
8489
const int num_workers = absl::GetFlag(FLAGS_num_workers);
8590
CHECK_GT(num_workers, 0);
86-
const int num_queries = absl::GetFlag(FLAGS_num_queries);
87-
CHECK_GT(num_queries, 0);
8891
const int burst_size = absl::GetFlag(FLAGS_burst_size);
8992
CHECK_GT(burst_size, 0);
9093
const int queries_per_second = absl::GetFlag(FLAGS_queries_per_second);
9194
CHECK_GT(queries_per_second, 0);
9295
const std::string output_file = absl::GetFlag(FLAGS_output_file);
9396

97+
int num_queries = absl::GetFlag(FLAGS_num_queries);
98+
const int total_invocations = absl::GetFlag(FLAGS_total_invocations);
99+
CHECK_GE(total_invocations, 0);
100+
if (total_invocations > 0) {
101+
num_queries = total_invocations / burst_size;
102+
} else {
103+
CHECK_GT(num_queries, 0);
104+
}
105+
94106
const std::string lib_mounts = absl::GetFlag(FLAGS_lib_mounts);
95107
const std::string binary_path = absl::GetFlag(FLAGS_binary_path);
96108
const privacy_sandbox::server_common::byob::Mode sandbox =

0 commit comments

Comments
 (0)