-
Notifications
You must be signed in to change notification settings - Fork 60
Add stress benchmark CI workflow #3426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3cc775d
26bde5c
7b261b5
4861700
d350631
bb9a516
5306b46
0bb8431
6b8e5bf
45c5b81
7cf8c79
1592371
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| # Copyright The Conforma Contributors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| --- | ||
| name: Stress Benchmark | ||
|
|
||
| "on": | ||
| pull_request: | ||
| branches: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [medium] action-version-pinning The pinned action versions are older than those used in other repository workflows. step-security/harden-runner uses v2.15.1 while others use v2.20.0+; actions/checkout uses v6.0.2 vs v6.1.0; actions/cache/restore uses v5.0.4 vs v5.1.0; actions/setup-go uses v6.3.0 vs v6.5.0. Suggested fix: Update action pins to match the versions used in other workflows: harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920, checkout@d23441a48e516b6c34aea4fa41551a30e30af803, cache/restore@caa296126883cff596d87d8935842f9db880ef25, setup-go@924ae3a1cded613372ab5595356fb5720e22ba16. |
||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
|
|
||
| stress: | ||
| name: Stress Benchmark | ||
| runs-on: ubuntu-latest | ||
|
dheerajodha marked this conversation as resolved.
dheerajodha marked this conversation as resolved.
dheerajodha marked this conversation as resolved.
|
||
| timeout-minutes: 15 | ||
| continue-on-error: true | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| env: | ||
| # Tuned for 4 vCPU / 16 GB CI runners to complete within 5 minutes. | ||
| # Code defaults are 10 components / 35 workers. | ||
| EC_STRESS_COMPONENTS: "10" | ||
| EC_STRESS_WORKERS: "10" | ||
|
dheerajodha marked this conversation as resolved.
|
||
| steps: | ||
| - name: Harden Runner | ||
| uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1 | ||
| with: | ||
| egress-policy: audit | ||
| disable-telemetry: true | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Restore Cache | ||
| uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | ||
| with: | ||
| key: main | ||
| path: '**' | ||
|
|
||
| - name: Setup Go environment | ||
| uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 | ||
| with: | ||
|
dheerajodha marked this conversation as resolved.
|
||
| go-version-file: go.mod | ||
|
dheerajodha marked this conversation as resolved.
|
||
| cache: false | ||
|
|
||
| - name: Setup ORAS | ||
| uses: oras-project/setup-oras@1d808f7d7f6995cc68b7bf507bfe5c5446e1dc9d # v2.0.1 | ||
|
|
||
| - name: Prepare benchmark data | ||
| run: | | ||
| cd benchmark/stress | ||
| ./prepare_data.sh | ||
|
|
||
| - name: Build stress benchmark | ||
| run: go build -o benchmark/stress/stress ./benchmark/stress | ||
|
qodo-for-conforma[bot] marked this conversation as resolved.
|
||
|
|
||
| - name: Run stress benchmark | ||
| id: bench | ||
| run: | | ||
| set -o pipefail | ||
| cd benchmark/stress | ||
| ./stress 2>benchmark-stderr.txt | tee benchmark-output.txt | ||
|
|
||
|
dheerajodha marked this conversation as resolved.
|
||
| - name: Write job summary | ||
|
dheerajodha marked this conversation as resolved.
|
||
| if: always() | ||
|
dheerajodha marked this conversation as resolved.
|
||
| run: | | ||
|
dheerajodha marked this conversation as resolved.
|
||
| if [[ "${{ steps.bench.outcome }}" == "failure" && -s benchmark/stress/benchmark-stderr.txt ]]; then | ||
| { | ||
| echo "### Stderr" | ||
| echo '```' | ||
| tail -50 benchmark/stress/benchmark-stderr.txt | ||
| echo '```' | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
| fi | ||
|
|
||
|
dheerajodha marked this conversation as resolved.
|
||
| if [[ ! -f benchmark/stress/benchmark-output.txt ]]; then | ||
| echo "## Stress Benchmark" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "Benchmark did not produce output." >> "$GITHUB_STEP_SUMMARY" | ||
| exit 0 | ||
| fi | ||
|
|
||
| line=$(grep '^BenchmarkStress' benchmark/stress/benchmark-output.txt || true) | ||
|
qodo-for-conforma[bot] marked this conversation as resolved.
dheerajodha marked this conversation as resolved.
|
||
| if [[ -z "$line" ]]; then | ||
| echo "## Stress Benchmark" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "No benchmark results found in output." >> "$GITHUB_STEP_SUMMARY" | ||
| exit 0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] edge-case The grep patterns use [\d.]+ which would match malformed numeric strings containing multiple dots. In practice the Go benchmark driver produces well-formed numbers, so this is unlikely to cause issues. |
||
| fi | ||
|
|
||
| ns_op=$(echo "$line" | grep -oP '[\d.]+ ns/op' | awk '{print $1}') | ||
|
qodo-for-conforma[bot] marked this conversation as resolved.
|
||
| peak_rss=$(echo "$line" | grep -oP '[\d.]+ peak-RSS-bytes' | awk '{print $1}') | ||
|
dheerajodha marked this conversation as resolved.
|
||
| alloc=$(echo "$line" | grep -oP '[\d.]+ allocated-bytes/op' | awk '{print $1}') | ||
| heap=$(echo "$line" | grep -oP '[\d.]+ heap-bytes-from-system' | awk '{print $1}') | ||
|
|
||
| secs=$(awk -v val="${ns_op:-0}" 'BEGIN {printf "%.1f", val / 1000000000}') | ||
| rss_mb=$(awk -v val="${peak_rss:-0}" 'BEGIN {printf "%.0f", val / 1048576}') | ||
| alloc_mb=$(awk -v val="${alloc:-0}" 'BEGIN {printf "%.0f", val / 1048576}') | ||
| heap_mb=$(awk -v val="${heap:-0}" 'BEGIN {printf "%.0f", val / 1048576}') | ||
|
|
||
| { | ||
| echo "## Stress Benchmark" | ||
| echo "" | ||
| echo "| Metric | Value | Description |" | ||
| echo "|--------|-------|-------------|" | ||
| echo "| Components | ${EC_STRESS_COMPONENTS} | Snapshot components validated |" | ||
| echo "| Workers | ${EC_STRESS_WORKERS} | Parallel validation workers |" | ||
| echo "| Execution time | ${secs}s | Wall-clock time per iteration |" | ||
| echo "| Peak RSS | ${rss_mb} MB | Max physical memory used |" | ||
| echo "| Allocated memory | ${alloc_mb} MB | Total Go heap allocations |" | ||
| echo "| Heap from system | ${heap_mb} MB | Heap memory requested from OS |" | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,6 +165,7 @@ func ec(dir string, components, workers int) func() { | |
| strconv.Itoa(workers), | ||
| "--effective-time", | ||
| "2024-12-10T00:00:00Z", | ||
| "--allow-past-effective-time", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] scope-consistency The PR description does not mention the --allow-past-effective-time flag addition and why it is needed (the hardcoded effective-time 2024-12-10T00:00:00Z is now in the past). Suggested fix: Update the PR description to mention the supporting change. |
||
| }); err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.