Skip to content

Commit 7bb0264

Browse files
committed
perf test
1 parent 5219a69 commit 7bb0264

9 files changed

Lines changed: 761 additions & 235 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 142 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,12 @@ jobs:
4040
uses: actions/checkout@v6
4141
with:
4242
submodules: 'recursive'
43-
43+
4444
- name: Install depedencies
4545
run: |
4646
sudo apt-get update
4747
sudo apt-get install -y build-essential cmake clang-tidy clang-format
48-
49-
#- name: Run Clang-Format Check
50-
# run: |
51-
# find src include tests -name "*.cpp" -o -name "*.hpp" | xargs clang-format --dry-run --Werror
52-
53-
#- name: Run Clang-Tidy (Linter)
54-
# run: |
55-
# # Run the linter on all our source files
56-
# clang-tidy src/core/*.cpp include/core/*.hpp -- -Iinclude -Ithird_party/json/include -std=c++20
57-
48+
5849
- name: Configure CMake
5950
run: |
6051
mkdir build
@@ -71,7 +62,7 @@ jobs:
7162
cd build
7263
ctest --output-on-failure
7364
74-
run-benchmarks:
65+
benchmarks:
7566
name: Performance Benchmarks
7667
runs-on: ubuntu-latest
7768
steps:
@@ -85,18 +76,150 @@ jobs:
8576
sudo apt-get update
8677
sudo apt-get install -y build-essential cmake
8778
79+
- name: CPU info
80+
run: |
81+
echo "## CPU Context" >> $GITHUB_STEP_SUMMARY
82+
echo '```' >> $GITHUB_STEP_SUMMARY
83+
lscpu >> $GITHUB_STEP_SUMMARY
84+
echo '```' >> $GITHUB_STEP_SUMMARY
85+
echo "" >> $GITHUB_STEP_SUMMARY
86+
8887
- name: Configure and Build
8988
run: |
90-
mkdir build
91-
cd build
89+
mkdir -p build && cd build
9290
cmake .. -DCMAKE_BUILD_TYPE=Release
93-
make -j$(nproc) raijin_benchmarks
91+
make -j$(nproc) raijin_benchmarks raijin_latency_histograms
92+
93+
- name: Run Microbenchmarks
94+
run: |
95+
cd build
96+
echo "## Microbenchmarks (ns, median of 3 runs)" >> $GITHUB_STEP_SUMMARY
97+
echo '```text' >> $GITHUB_STEP_SUMMARY
98+
./raijin_benchmarks --benchmark_repetitions=3 --benchmark_min_time=0.3s >> $GITHUB_STEP_SUMMARY
99+
echo '```' >> $GITHUB_STEP_SUMMARY
100+
echo "" >> $GITHUB_STEP_SUMMARY
94101
95-
- name: Run Benchmarks and Report to Summary
102+
- name: Run Latency Histograms
96103
run: |
97104
cd build
98-
echo "## Raijin-LOB Performance Benchmarks" >> $GITHUB_STEP_SUMMARY
99-
echo "### Microbench (Deterministic Data)" >> $GITHUB_STEP_SUMMARY
105+
echo "## Latency Histograms (CPU cycles, median of 3 runs)" >> $GITHUB_STEP_SUMMARY
100106
echo '```text' >> $GITHUB_STEP_SUMMARY
101-
./raijin_benchmarks >> $GITHUB_STEP_SUMMARY
107+
./raijin_latency_histograms --benchmark_counters_tabular=true --benchmark_repetitions=3 --benchmark_min_time=0.1s >> $GITHUB_STEP_SUMMARY
108+
echo '```' >> $GITHUB_STEP_SUMMARY
109+
echo "" >> $GITHUB_STEP_SUMMARY
110+
111+
- name: Generate JSON artifact
112+
run: |
113+
cd build
114+
./raijin_benchmarks --benchmark_format=json --benchmark_out=benchmark_results.json --benchmark_repetitions=3 --benchmark_min_time=0.3s
115+
116+
- name: Upload benchmark JSON
117+
uses: actions/upload-artifact@v4
118+
with:
119+
name: benchmark-results
120+
path: build/benchmark_results.json
121+
122+
- name: Binary sizes
123+
run: |
124+
cd build
125+
echo "## Binary Sizes" >> $GITHUB_STEP_SUMMARY
126+
echo '```' >> $GITHUB_STEP_SUMMARY
127+
ls -lh raijin_engine raijin_benchmarks raijin_latency_histograms raijin_tests >> $GITHUB_STEP_SUMMARY
128+
echo '```' >> $GITHUB_STEP_SUMMARY
129+
130+
perf-profile:
131+
name: Hardware Profile
132+
runs-on: ubuntu-latest
133+
steps:
134+
- name: Checkout code
135+
uses: actions/checkout@v6
136+
with:
137+
submodules: 'recursive'
138+
139+
- name: Install dependencies
140+
run: |
141+
sudo apt-get update
142+
sudo apt-get install -y build-essential cmake linux-tools-generic || true
143+
144+
- name: CPU info
145+
run: |
146+
echo "## CPU Context" >> $GITHUB_STEP_SUMMARY
147+
echo '```' >> $GITHUB_STEP_SUMMARY
148+
lscpu >> $GITHUB_STEP_SUMMARY
149+
echo '```' >> $GITHUB_STEP_SUMMARY
150+
echo "" >> $GITHUB_STEP_SUMMARY
151+
152+
- name: Configure and Build
153+
run: |
154+
mkdir -p build && cd build
155+
cmake .. -DCMAKE_BUILD_TYPE=Release
156+
make -j$(nproc) raijin_latency_histograms raijin_benchmarks
157+
158+
- name: Binary sizes
159+
run: |
160+
cd build
161+
echo "## Binary Sizes" >> $GITHUB_STEP_SUMMARY
162+
echo '```' >> $GITHUB_STEP_SUMMARY
163+
ls -lh raijin_engine raijin_benchmarks raijin_latency_histograms raijin_tests >> $GITHUB_STEP_SUMMARY
164+
echo '```' >> $GITHUB_STEP_SUMMARY
165+
echo "" >> $GITHUB_STEP_SUMMARY
166+
167+
- name: Perf stat (basic counters)
168+
run: |
169+
cd build
170+
echo "## Hardware Counters — Basic" >> $GITHUB_STEP_SUMMARY
171+
echo '```' >> $GITHUB_STEP_SUMMARY
172+
sudo perf stat -e cycles,instructions,cache-references,cache-misses,branch-misses,branch-instructions \
173+
./raijin_latency_histograms --benchmark_repetitions=1 --benchmark_min_time=0.1s >> $GITHUB_STEP_SUMMARY 2>&1 || echo "perf not available" >> $GITHUB_STEP_SUMMARY
174+
echo '```' >> $GITHUB_STEP_SUMMARY
175+
echo "" >> $GITHUB_STEP_SUMMARY
176+
177+
- name: Perf stat (detailed — L1/L2/LLC/TLB)
178+
run: |
179+
cd build
180+
echo "## Hardware Counters — Detailed (L1/L2/LLC/TLB)" >> $GITHUB_STEP_SUMMARY
181+
echo '```' >> $GITHUB_STEP_SUMMARY
182+
sudo perf stat -d \
183+
./raijin_latency_histograms --benchmark_repetitions=1 --benchmark_min_time=0.1s >> $GITHUB_STEP_SUMMARY 2>&1 || echo "perf not available" >> $GITHUB_STEP_SUMMARY
184+
echo '```' >> $GITHUB_STEP_SUMMARY
185+
echo "" >> $GITHUB_STEP_SUMMARY
186+
187+
- name: Perf stat (random-ID add only)
188+
run: |
189+
cd build
190+
echo "## Hardware Counters — Random-ID Add (BM_Hist_AddNoMatch only)" >> $GITHUB_STEP_SUMMARY
191+
echo '```' >> $GITHUB_STEP_SUMMARY
192+
sudo perf stat -e cycles,instructions,cache-references,cache-misses,branch-misses,L1-dcache-load-misses,L1-icache-load-misses,LLC-load-misses,dTLB-load-misses \
193+
./raijin_latency_histograms --benchmark_filter=BM_Hist_AddNoMatch --benchmark_repetitions=1 --benchmark_min_time=0.2s >> $GITHUB_STEP_SUMMARY 2>&1 || echo "perf not available" >> $GITHUB_STEP_SUMMARY
194+
echo '```' >> $GITHUB_STEP_SUMMARY
195+
echo "" >> $GITHUB_STEP_SUMMARY
196+
197+
- name: Perf stat (match only)
198+
run: |
199+
cd build
200+
echo "## Hardware Counters — Match (BM_Hist_MatchOneLevel only)" >> $GITHUB_STEP_SUMMARY
102201
echo '```' >> $GITHUB_STEP_SUMMARY
202+
sudo perf stat -e cycles,instructions,cache-references,cache-misses,branch-misses,L1-dcache-load-misses,L1-icache-load-misses,LLC-load-misses,dTLB-load-misses \
203+
./raijin_latency_histograms --benchmark_filter=BM_Hist_MatchOneLevel --benchmark_repetitions=1 --benchmark_min_time=0.2s >> $GITHUB_STEP_SUMMARY 2>&1 || echo "perf not available" >> $GITHUB_STEP_SUMMARY
204+
echo '```' >> $GITHUB_STEP_SUMMARY
205+
echo "" >> $GITHUB_STEP_SUMMARY
206+
207+
- name: Perf record (flamegraph data)
208+
run: |
209+
cd build
210+
echo "## Perf Record" >> $GITHUB_STEP_SUMMARY
211+
echo "Generating flamegraph data (uploaded as artifact)..." >> $GITHUB_STEP_SUMMARY
212+
echo "" >> $GITHUB_STEP_SUMMARY
213+
sudo perf record --call-graph dwarf -o perf.data \
214+
./raijin_latency_histograms --benchmark_repetitions=1 --benchmark_min_time=0.1s || true
215+
sudo perf script -i perf.data > perf_script.txt 2>&1 || true
216+
gzip -c perf.data > perf_data.gz || true
217+
echo "Flamegraph data ready." >> $GITHUB_STEP_SUMMARY
218+
219+
- name: Upload perf data
220+
uses: actions/upload-artifact@v4
221+
with:
222+
name: perf-data
223+
path: |
224+
build/perf_data.gz
225+
build/perf_script.txt

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
.vscode/
22
build/
3-
build-wsl/
3+
build-*/
44
*.exe
55
*.o
66
*.obj
77
.DS_Store
88
Release/
9-
9+
.cache/
10+
${APPDATA}/
11+
AGENTS.md
12+
AGENTS.md

AGENTS.md

Lines changed: 0 additions & 165 deletions
This file was deleted.

0 commit comments

Comments
 (0)