-
Notifications
You must be signed in to change notification settings - Fork 5
154 lines (128 loc) · 5.95 KB
/
benchmark.yml
File metadata and controls
154 lines (128 loc) · 5.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Benchmark
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
benchmark:
runs-on: ubuntu-latest
services:
redis:
image: redis:7.0
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
ruby-version: ['3.4']
steps:
- uses: actions/checkout@v6
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Cache Redis CLI
uses: actions/cache@v4
id: cache-redis-tools
with:
path: /usr/bin/redis-cli
key: redis-tools-${{ runner.os }}
- name: Install Redis CLI
if: steps.cache-redis-tools.outputs.cache-hit != 'true'
run: sudo apt-get update && sudo apt-get install -y redis-tools
- name: Wait for Redis
run: |
until redis-cli ping; do
echo "Waiting for Redis..."
sleep 1
done
- name: Run benchmark without memory logger
id: benchmark_without
run: |
echo "Running benchmark WITHOUT memory logger..."
output=$(ITER=50 timeout 120 bundle exec bin/sidekiqload 2>&1 || true)
echo "$output"
# Extract performance metrics
jobs_per_sec=$(echo "$output" | grep -oE '[0-9]+ jobs/sec' | grep -oE '[0-9]+' | head -1 || echo "0")
ending_rss=$(echo "$output" | grep 'Ending RSS:' | grep -oE '[0-9]+' | head -1 || echo "0")
echo "without_jobs_per_sec=$jobs_per_sec" >> $GITHUB_OUTPUT
echo "without_ending_rss=$ending_rss" >> $GITHUB_OUTPUT
# Save full output for comparison
echo "WITHOUT_OUTPUT<<EOF" >> $GITHUB_ENV
echo "$output" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Run benchmark with memory logger
id: benchmark_with
run: |
echo "Running benchmark WITH memory logger..."
output=$(MEMORY_LOGGER=1 ITER=50 timeout 120 bundle exec bin/sidekiqload 2>&1 || true)
echo "$output"
# Extract performance metrics
jobs_per_sec=$(echo "$output" | grep -oE '[0-9]+ jobs/sec' | grep -oE '[0-9]+' | head -1 || echo "0")
ending_rss=$(echo "$output" | grep 'Ending RSS:' | grep -oE '[0-9]+' | head -1 || echo "0")
echo "with_jobs_per_sec=$jobs_per_sec" >> $GITHUB_OUTPUT
echo "with_ending_rss=$ending_rss" >> $GITHUB_OUTPUT
# Save full output for comparison
echo "WITH_OUTPUT<<EOF" >> $GITHUB_ENV
echo "$output" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Compare results
run: |
echo "## Benchmark Results Comparison" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Without Memory Logger" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$WITHOUT_OUTPUT" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### With Memory Logger" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$WITH_OUTPUT" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Performance comparison
without_jps=${{ steps.benchmark_without.outputs.without_jobs_per_sec }}
with_jps=${{ steps.benchmark_with.outputs.with_jobs_per_sec }}
echo "### Performance Metrics" >> $GITHUB_STEP_SUMMARY
echo "| Metric | Without Logger | With Logger | Difference |" >> $GITHUB_STEP_SUMMARY
echo "|--------|----------------|-------------|------------|" >> $GITHUB_STEP_SUMMARY
echo "| Jobs/sec | $without_jps | $with_jps | $(($with_jps - $without_jps)) |" >> $GITHUB_STEP_SUMMARY
# Calculate milliseconds per job
if [ "$without_jps" -gt 0 ] && [ "$with_jps" -gt 0 ]; then
without_ms_per_job=$(echo "scale=3; 1000.0 / $without_jps" | bc -l)
with_ms_per_job=$(echo "scale=3; 1000.0 / $with_jps" | bc -l)
ms_per_job_diff=$(echo "scale=3; $with_ms_per_job - $without_ms_per_job" | bc -l)
echo "| Milliseconds per job | $without_ms_per_job | $with_ms_per_job | $ms_per_job_diff |" >> $GITHUB_STEP_SUMMARY
fi
- name: Output results to console
run: |
echo "=== BENCHMARK RESULTS ==="
echo "Without Memory Logger:"
echo " Jobs/sec: ${{ steps.benchmark_without.outputs.without_jobs_per_sec }}"
echo " Ending RSS: ${{ steps.benchmark_without.outputs.without_ending_rss }} KB"
echo ""
echo "With Memory Logger:"
echo " Jobs/sec: ${{ steps.benchmark_with.outputs.with_jobs_per_sec }}"
echo " Ending RSS: ${{ steps.benchmark_with.outputs.with_ending_rss }} KB"
echo ""
echo "Differences:"
echo " Jobs/sec difference: $((${{ steps.benchmark_with.outputs.with_jobs_per_sec }} - ${{ steps.benchmark_without.outputs.without_jobs_per_sec }}))"
echo " RSS difference: $((${{ steps.benchmark_with.outputs.with_ending_rss }} - ${{ steps.benchmark_without.outputs.without_ending_rss }})) KB"
echo ""
# Calculate absolute latency added per job
without_jps=${{ steps.benchmark_without.outputs.without_jobs_per_sec }}
with_jps=${{ steps.benchmark_with.outputs.with_jobs_per_sec }}
if [ "$without_jps" -gt 0 ] && [ "$with_jps" -gt 0 ]; then
# Convert jobs/sec to milliseconds per job, then calculate difference
without_ms_per_job=$(echo "scale=6; 1000.0 / $without_jps" | bc -l)
with_ms_per_job=$(echo "scale=6; 1000.0 / $with_jps" | bc -l)
latency_added=$(echo "scale=3; $with_ms_per_job - $without_ms_per_job" | bc -l)
echo "Memory logger adds $latency_added milliseconds per job"
fi