Skip to content

Commit efa8834

Browse files
authored
loadgen: Allow shuffling signal benchmark order (#704)
* loadgen: Allow shuffling signal benchmark order Adds a new `-shuffle` flag to randomize the order of signals in the benchmark runs. This is useful for cases where multiple instances of the loadgen are run concurrently, allowing more varied benchmarking. Signed-off-by: Marc Lopez Rubio <[email protected]> * Add PR Signed-off-by: Marc Lopez Rubio <[email protected]> --------- Signed-off-by: Marc Lopez Rubio <[email protected]>
1 parent 56a93c7 commit efa8834

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
7+
note: "Add `-shuffle` flag to randomize the order of benchmarks"
8+
9+
# It is mandatory to specify the component. Do not change this.
10+
component: otelbench
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [704]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
Adds a new `-shuffle` flag to randomize the order of benchmarks. This allows concurrent
20+
runs to potentially target different signals, allowing multiple signals to be benchmarked
21+
at once. For non-concurrent benchmarks, there shouldn't be a significant difference due
22+
the execution order.

loadgen/cmd/otelbench/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include ../../../Makefile.Common
22

3-
VERSION := v0.2.2
3+
VERSION := v0.3.0
44

55
.PHONY: get-version
66
get-version:
@@ -17,4 +17,4 @@ chlog-validate: $(CHLOGGEN) # Validate the new changelog entry
1717

1818
.PHONY: chlog-preview
1919
chlog-preview: $(CHLOGGEN) # Preview the changelog entry in CHANGELOG.md
20-
$(CHLOGGEN) update --dry
20+
$(CHLOGGEN) update --dry

loadgen/cmd/otelbench/flags.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ var Config struct {
4848
ExporterOTLPHTTP bool
4949

5050
ConcurrencyList []int
51+
Shuffle bool
5152

5253
Telemetry TelemetryConfig
5354
}
@@ -132,6 +133,8 @@ func Init() error {
132133
flag.BoolVar(&Config.Metrics, "metrics", true, "benchmark metrics")
133134
flag.BoolVar(&Config.Traces, "traces", true, "benchmark traces")
134135

136+
flag.BoolVar(&Config.Shuffle, "shuffle", false, "shuffle the order of benchmarks. This is useful for concurrent runs.")
137+
135138
// `concurrency` is similar to `agents` config in apmbench
136139
// Each value passed into `concurrency` list will be used as loadgenreceiver `concurrency` config
137140
flag.Func("concurrency", "comma-separated `list` of concurrency (number of simulated agents) to run each benchmark with. Supports numeric values (e.g., \"1,4,8\"), \"auto\" to use available CPU cores, or \"auto:Nx\" for multipliers (e.g., \"auto:2x\" for double, \"auto:0.5x\" for half)",

loadgen/cmd/otelbench/main.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
_ "embed"
2323
"flag"
2424
"fmt"
25+
"math/rand/v2"
2526
"net"
2627
"net/http"
2728
"os"
@@ -200,9 +201,17 @@ func main() {
200201

201202
// Get the benchmark count from -test.count flag
202203
count := getBenchCount()
204+
205+
signals := getSignals()
206+
exporters := getExporters()
207+
if Config.Shuffle {
208+
rand.Shuffle(len(signals), func(i, j int) {
209+
signals[i], signals[j] = signals[j], signals[i]
210+
})
211+
}
203212
for _, concurrency := range Config.ConcurrencyList {
204-
for _, signal := range getSignals() {
205-
for _, exporter := range getExporters() {
213+
for _, signal := range signals {
214+
for _, exporter := range exporters {
206215
benchName := fullBenchmarkName(signal, exporter, concurrency)
207216
for i := 0; i < count; i++ {
208217
t := time.Now().UTC()

0 commit comments

Comments
 (0)