Skip to content

Commit 019283a

Browse files
authored
Merge pull request #244 from smuppand/sysbench
Performance/Sysbench: baseline gating, MB/sec normalization, clock sanity + docs/YAML updates
2 parents ceff462 + 6156c60 commit 019283a

6 files changed

Lines changed: 2398 additions & 14 deletions

File tree

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
# Sysbench_Performance
2+
3+
This suite runs a **repeatable Sysbench performance baseline** on Yocto/QLI targets in a CI-friendly way.
4+
5+
It runs the following test cases for one or more thread counts and for N iterations:
6+
7+
- **CPU** (`sysbench cpu`)
8+
- **Memory bandwidth** (`sysbench memory`)
9+
- **Threads** (`sysbench threads`)
10+
- **Mutex** (`sysbench mutex`)
11+
- **File I/O throughput** (`sysbench fileio`) — **seqwr / seqrd / rndwr / rndrd**
12+
13+
For each case it:
14+
- prints sysbench output live to console (and saves per-iteration logs),
15+
- records per-iteration KPIs into `*.values` files,
16+
- prints a compact per-iteration KPI line (`ITER_SUMMARY`) to console,
17+
- computes averages and writes `OUT_DIR/sysbench_summary.txt`,
18+
- optionally appends per-iteration + avg rows to a CSV (only if `CSV_FILE` is provided),
19+
- optionally enforces PASS/FAIL **baseline gating** (when a baseline file is provided or auto-detected).
20+
21+
---
22+
23+
## KPIs collected (and “better” direction)
24+
25+
| Case | KPI name (run.sh / baseline key) | Unit | Better |
26+
|---|---|---:|---|
27+
| CPU | `cpu_time_sec` | seconds | **lower** |
28+
| Memory | `memory_mem_mbps` | MB/s | **higher** |
29+
| Threads | `threads_time_sec` | seconds | **lower** |
30+
| Mutex | `mutex_time_sec` | seconds | **lower** |
31+
| File I/O seq write | `fileio_seqwr_mbps` | MB/s | **higher** |
32+
| File I/O seq read | `fileio_seqrd_mbps` | MB/s | **higher** |
33+
| File I/O rnd write | `fileio_rndwr_mbps` | MB/s | **higher** |
34+
| File I/O rnd read | `fileio_rndrd_mbps` | MB/s | **higher** |
35+
36+
> Note: even if you think of reads as “GB/s”, the suite **stores and gates in MB/s** for consistency.
37+
> If you have a baseline in GB/s, convert to MB/s (GB/s × 1024).
38+
39+
---
40+
41+
## Baseline gating (PASS/FAIL)
42+
43+
Baseline gating is enabled when either:
44+
- `BASELINE_FILE` / `--baseline FILE` is set, **or**
45+
- `./sysbench_baseline.conf` exists in the **same folder as `run.sh`** (auto-detected).
46+
47+
`ALLOWED_DEVIATION` / `--delta` controls tolerance:
48+
49+
- **Higher-is-better** metrics (MB/s):
50+
**PASS** if `avg >= baseline * (1 - delta)`
51+
(recommend **0.05** → “>= 95% of baseline”)
52+
- **Lower-is-better** metrics (seconds):
53+
**PASS** if `avg <= baseline * (1 + delta)`
54+
(recommend **0.05** → “<= 105% of baseline”)
55+
56+
The console shows a per-metric GATE line and `sysbench_summary.txt` includes a `gate_*` section.
57+
58+
---
59+
60+
## Baseline file format (`sysbench_baseline.conf`)
61+
62+
Plain `key=value` format (comments allowed with `#`). Keys are per-thread-count:
63+
64+
```
65+
# ---- Threads = 4 ----
66+
cpu_time_sec.t4=3.483
67+
memory_mem_mbps.t4=4120.000
68+
threads_time_sec.t4=3.703
69+
mutex_time_sec.t4=0.004
70+
71+
fileio_seqwr_mbps.t4=0.400
72+
fileio_seqrd_mbps.t4=29.300
73+
fileio_rndwr_mbps.t4=0.610
74+
fileio_rndrd_mbps.t4=29.300
75+
```
76+
77+
Use `t1`, `t4`, `t8`, … matching your `THREADS_LIST`.
78+
79+
---
80+
81+
## Parameters (env vars / CLI)
82+
83+
The suite is controlled by environment variables (and equivalent CLI flags). Typical params:
84+
85+
### Common
86+
- `OUT_DIR` (default `./sysbench_out`) – where logs / values / summary go
87+
- `ITERATIONS` (default `1`)
88+
- `TIME` (default `30`)
89+
- `RAND_SEED` (default `1234`)
90+
- `THREADS_LIST` (default `"4"`) – space-separated list of thread counts
91+
- `TASKSET_CPU_LIST` (default empty) – passed to `taskset -c`, e.g. `"6-7"`
92+
- `BASELINE_FILE` (default empty; auto-detects `sysbench_baseline.conf` next to `run.sh`)
93+
- `ALLOWED_DEVIATION` (default `0.10`; recommended `0.05`)
94+
- `CSV_FILE` (default empty → **no CSV by default**)
95+
96+
### CPU
97+
- `CPU_MAX_PRIME` (default `20000`)
98+
99+
### Threads
100+
- `THREAD_LOCKS` (default `20`)
101+
- `THREAD_YIELDS` (default empty → sysbench default)
102+
103+
### Memory
104+
- `MEMORY_OPER` (default `write`) – `read|write`
105+
- `MEMORY_ACCESS_MODE` (default `rnd`) – `seq|rnd`
106+
- `MEMORY_BLOCK_SIZE` (default `1M`)
107+
- `MEMORY_TOTAL_SIZE` (default `100G`)
108+
109+
### File I/O
110+
File I/O uses sysbench `fileio` with a **prepare → run → cleanup** flow.
111+
112+
Recommended knobs (names match the suite params):
113+
- `FILEIO_DIR` – directory where files are created (recommended: **tmpfs** like `/tmp`)
114+
- `FILE_TOTAL_SIZE` – total size per file, e.g. `1G`
115+
- `FILE_BLOCK_SIZE` – e.g. `4K`, `1M`
116+
- `FILE_NUM` – number of files, e.g. `1`, `4`
117+
- `FILE_IO_MODE` – e.g. `sync` (stable), `async`
118+
- `FILE_FSYNC_FREQ` – optional, e.g. `0` (disable) or `1` (every op)
119+
120+
> Your `run.sh` may expose additional `FILE_*` knobs; keep them documented here as you add them.
121+
122+
---
123+
124+
## Safety warning for File I/O
125+
126+
`sysbench fileio` **creates files and performs reads/writes** in `FILEIO_DIR`.
127+
128+
To avoid accidental wear / regression noise:
129+
- Prefer `FILEIO_DIR=/tmp/...` (tmpfs) for CI gating.
130+
- If you must test real storage, point to a **dedicated mount** (not `/`), and keep sizes small.
131+
- Do **NOT** point fileio at your root filesystem (`/`) unless you fully understand the impact.
132+
133+
---
134+
135+
## Outputs
136+
137+
In `OUT_DIR/` you will see:
138+
139+
- `*_iterN.log` — full sysbench stdout/stderr per test case + iteration
140+
- `*.values` — one KPI value per iteration (for averaging)
141+
- `sysbench_summary.txt` — averages + gating summary
142+
- Optional CSV (only when `CSV_FILE` is set)
143+
144+
Result file:
145+
- `./Sysbench_Performance.res``PASS` / `FAIL` / `SKIP`
146+
147+
---
148+
149+
## Examples (using our `run.sh`)
150+
151+
All examples are run from:
152+
153+
```
154+
cd Runner/suites/Performance/Sysbench_Performance/
155+
```
156+
157+
### 1) Full suite (CPU + memory + threads + mutex + fileio)
158+
```
159+
./run.sh
160+
```
161+
162+
### 2) 3 iterations, pin to big cores, tighter gating (95% baseline)
163+
(Uses `./sysbench_baseline.conf` automatically if present.)
164+
```
165+
./run.sh --iterations 3 --threads-list "4" --taskset-cpu-list "6-7" --delta 0.05
166+
```
167+
168+
### 3) Explicit baseline file path
169+
```
170+
./run.sh --baseline ./sysbench_baseline.conf --delta 0.05
171+
```
172+
173+
### 4) Enable CSV (NOT default)
174+
```
175+
./run.sh --csv ./sysbench_out/sysbench.csv
176+
```
177+
178+
### 5) CPU time focus (reduce noise)
179+
You can’t “run only CPU” without editing the script, but you can reduce runtime:
180+
```
181+
./run.sh --iterations 1 --time 15 --cpu-max-prime 20000 --threads-list "4"
182+
```
183+
Then read:
184+
- console `ITER_SUMMARY ... cpu_time_sec=...`
185+
- `OUT_DIR/cpu_t4.values`
186+
- CSV rows (if enabled)
187+
188+
### 6) Memory bandwidth focus (use seq vs rnd)
189+
```
190+
MEMORY_ACCESS_MODE=seq ./run.sh --iterations 1 --threads-list "4"
191+
MEMORY_ACCESS_MODE=rnd ./run.sh --iterations 1 --threads-list "4"
192+
```
193+
194+
### 7) File I/O on tmpfs (recommended for CI)
195+
```
196+
FILEIO_DIR=/tmp/sysbench_fileio ./run.sh --iterations 1 --threads-list "4"
197+
```
198+
199+
### 8) File I/O heavier workload (be careful)
200+
```
201+
FILEIO_DIR=/tmp/sysbench_fileio FILE_TOTAL_SIZE=1G FILE_BLOCK_SIZE=4K FILE_NUM=4 ./run.sh --iterations 1 --threads-list "4"
202+
```
203+
204+
### 9) Verifying seq/rnd IO KPIs
205+
After the run, check:
206+
- `sysbench_summary.txt` for:
207+
- `fileio_seqwr_mbps`, `fileio_seqrd_mbps`, `fileio_rndwr_mbps`, `fileio_rndrd_mbps`
208+
- per-iteration logs:
209+
- `fileio_*_iter*.log`
210+
211+
---
212+
213+
## LAVA YAML integration
214+
215+
Your LAVA test definition should:
216+
- `cd Runner/suites/Performance/Sysbench_Performance/`
217+
- run `./run.sh`
218+
- publish `Sysbench_Performance.res` via `send-to-lava.sh`
219+
220+
Keep `CSV_FILE` empty by default (to avoid extra artifacts) and enable only when you explicitly need CSV.
221+
222+
---
223+
224+
## License
225+
226+
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
227+
SPDX-License-Identifier: BSD-3-Clause-Clear
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
metadata:
2+
name: sysbench-performance
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Sysbench performance suite (CPU / memory / threads / mutex + fileio seqwr/seqrd/rndwr/rndrd) with per-iteration logs + summary averages + optional baseline gating."
5+
os:
6+
- linux
7+
scope:
8+
- performance
9+
- functional
10+
11+
params:
12+
OUT_DIR: "./logs_Sysbench_Performance"
13+
14+
# Iteration controls
15+
ITERATIONS: "3"
16+
TIME: "30"
17+
RAND_SEED: "1234"
18+
THREADS_LIST: "4"
19+
20+
# CPU
21+
CPU_MAX_PRIME: "20000"
22+
23+
# Threads test
24+
THREAD_LOCKS: "20"
25+
THREAD_YIELDS: ""
26+
27+
# Memory test
28+
MEMORY_OPER: "write"
29+
MEMORY_ACCESS_MODE: "rnd"
30+
MEMORY_BLOCK_SIZE: "1M"
31+
MEMORY_TOTAL_SIZE: "100G"
32+
33+
# Mutex test
34+
MUTEX_NUM: ""
35+
MUTEX_LOCKS: ""
36+
MUTEX_LOOPS: ""
37+
38+
# Core pinning (optional)
39+
TASKSET_CPU_LIST: ""
40+
41+
# Baselines + thresholds (optional gating)
42+
BASELINE_FILE: ""
43+
ALLOWED_DEVIATION: "0.10"
44+
45+
# Optional CSV append
46+
CSV_FILE: ""
47+
48+
VERBOSE: "0"
49+
50+
# ---------------- FileIO (storage-backed) ----------------
51+
FILEIO_DIR: "/var/tmp/sysbench_fileio"
52+
FILEIO_TOTAL_SIZE: "1G"
53+
FILEIO_NUM: "64"
54+
FILEIO_BLOCK_SIZE: "4K"
55+
FILEIO_IO_MODE: "sync"
56+
FILEIO_FSYNC_FREQ: "0"
57+
FILEIO_EXTRA_FLAGS: "none"
58+
59+
# If/when run.sh supports it:
60+
# FILEIO_MODE_LIST: "seqwr seqrd rndwr rndrd"
61+
62+
run:
63+
steps:
64+
- REPO_PATH=$PWD
65+
- cd Runner/suites/Performance/Sysbench_Performance/
66+
67+
# Explicitly forward params to run.sh (best practice)
68+
- >
69+
./run.sh
70+
--OUT_DIR "$OUT_DIR"
71+
--ITERATIONS "$ITERATIONS"
72+
--TIME "$TIME"
73+
--RAND_SEED "$RAND_SEED"
74+
--THREADS_LIST "$THREADS_LIST"
75+
--CPU_MAX_PRIME "$CPU_MAX_PRIME"
76+
--THREAD_LOCKS "$THREAD_LOCKS"
77+
--THREAD_YIELDS "$THREAD_YIELDS"
78+
--MEMORY_OPER "$MEMORY_OPER"
79+
--MEMORY_ACCESS_MODE "$MEMORY_ACCESS_MODE"
80+
--MEMORY_BLOCK_SIZE "$MEMORY_BLOCK_SIZE"
81+
--MEMORY_TOTAL_SIZE "$MEMORY_TOTAL_SIZE"
82+
--MUTEX_NUM "$MUTEX_NUM"
83+
--MUTEX_LOCKS "$MUTEX_LOCKS"
84+
--MUTEX_LOOPS "$MUTEX_LOOPS"
85+
--TASKSET_CPU_LIST "$TASKSET_CPU_LIST"
86+
--BASELINE_FILE "$BASELINE_FILE"
87+
--ALLOWED_DEVIATION "$ALLOWED_DEVIATION"
88+
--CSV_FILE "$CSV_FILE"
89+
--VERBOSE "$VERBOSE"
90+
--FILEIO_DIR "$FILEIO_DIR"
91+
--FILEIO_TOTAL_SIZE "$FILEIO_TOTAL_SIZE"
92+
--FILEIO_NUM "$FILEIO_NUM"
93+
--FILEIO_BLOCK_SIZE "$FILEIO_BLOCK_SIZE"
94+
--FILEIO_IO_MODE "$FILEIO_IO_MODE"
95+
--FILEIO_FSYNC_FREQ "$FILEIO_FSYNC_FREQ"
96+
--FILEIO_EXTRA_FLAGS "$FILEIO_EXTRA_FLAGS"
97+
|| true
98+
99+
- $REPO_PATH/Runner/utils/send-to-lava.sh Sysbench_Performance.res

0 commit comments

Comments
 (0)