Skip to content

Commit 928e318

Browse files
rishav-karanjitjosecorellaShubhamChaturvedi7
authored
chore(go): add performance benchmark (#1983)
Co-authored-by: José Corella <39066999+josecorella@users.noreply.github.com> Co-authored-by: Shubham Chaturvedi <anotherosscontributor@gmail.com>
1 parent c397bf2 commit 928e318

17 files changed

Lines changed: 3203 additions & 0 deletions
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# This workflow runs every day 09:00 UTC (1AM PST)
2+
name: Performance Benchmarks
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
dafny:
8+
description: "The Dafny version to run"
9+
required: false
10+
default: "4.9.0"
11+
type: string
12+
regenerate-code:
13+
description: "Regenerate code using smithy-dafny"
14+
required: false
15+
default: false
16+
type: boolean
17+
mpl-version:
18+
description: "MPL version to use"
19+
required: false
20+
type: string
21+
mpl-head:
22+
description: "Running on MPL HEAD"
23+
required: false
24+
default: false
25+
type: boolean
26+
jobs:
27+
testGo:
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
library: [DynamoDbEncryption]
32+
benchmark-dir: [db-esdk-performance-testing]
33+
os: [macos-latest, ubuntu-latest]
34+
go-version: ["1.23", "1.24", "1.25"]
35+
runs-on: ${{ matrix.os }}
36+
permissions:
37+
id-token: write
38+
contents: read
39+
steps:
40+
- name: Configure AWS Credentials
41+
uses: aws-actions/configure-aws-credentials@v5
42+
with:
43+
aws-region: us-west-2
44+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
45+
role-session-name: DDBEC-Performance-Benchmarks-Go
46+
47+
- name: Support longpaths
48+
run: |
49+
git config --global core.longpaths true
50+
51+
- uses: actions/checkout@v5
52+
with:
53+
submodules: recursive
54+
- name: Init Submodules
55+
shell: bash
56+
run: |
57+
git submodule update --init --recursive submodules/smithy-dafny
58+
git submodule update --init --recursive submodules/MaterialProviders
59+
60+
- name: Create temporary global.json
61+
run: echo '{"sdk":{"rollForward":"latestFeature","version":"6.0.0"}}' > ./global.json
62+
63+
- name: Setup Java 17 for codegen
64+
uses: actions/setup-java@v5
65+
with:
66+
distribution: "corretto"
67+
java-version: "17"
68+
69+
- name: Update MPL submodule if using MPL HEAD
70+
if: ${{ inputs.mpl-head == true }}
71+
working-directory: submodules/MaterialProviders
72+
run: |
73+
git checkout main
74+
git pull
75+
git submodule update --init --recursive
76+
git rev-parse HEAD
77+
78+
- name: Update project.properties if using MPL HEAD
79+
if: ${{ inputs.mpl-head == true }}
80+
run: |
81+
sed "s/mplDependencyJavaVersion=.*/mplDependencyJavaVersion=${{inputs.mpl-version}}/g" project.properties > project.properties2; mv project.properties2 project.properties
82+
83+
- name: Install Go
84+
uses: actions/setup-go@v6
85+
with:
86+
go-version: ${{ matrix.go-version }}
87+
88+
- name: Setup Dafny
89+
uses: dafny-lang/setup-dafny-action@v1.8.0
90+
with:
91+
dafny-version: "4.9.0"
92+
93+
- name: Install Smithy-Dafny codegen dependencies
94+
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies
95+
96+
- name: Build ${{ matrix.library }} implementation
97+
shell: bash
98+
working-directory: ./${{ matrix.library }}
99+
run: |
100+
# This works because `node` is installed by default on GHA runners
101+
CORES=$(node -e 'console.log(os.cpus().length)')
102+
make transpile_go CORES=$CORES
103+
104+
- name: Run Performance Benchmarks - Quick Mode
105+
shell: bash
106+
working-directory: ./${{matrix.benchmark-dir}}/benchmarks/go
107+
run: |
108+
go run . --config ../config/test-scenarios.yaml --quick
109+
110+
- name: Parse and Format Logs
111+
working-directory: ./${{matrix.benchmark-dir}}/benchmarks/results/raw-data/
112+
run: |
113+
LOG_FILE="go_results.json"
114+
UPLOAD_FILE="cloudwatch_logs.json"
115+
TIMESTAMP=$(date +%s%3N)
116+
jq -c --arg ts "$(date +%s)000" '[.results[] as $result | .metadata as $meta | {timestamp: ($ts | tonumber), message: ({metadata: $meta, result: $result} | tostring)}]' $LOG_FILE > $UPLOAD_FILE
117+
118+
- name: Upload logs to CloudWatch
119+
working-directory: ./${{matrix.benchmark-dir}}/benchmarks/results/raw-data/
120+
run: |
121+
LOG_FILE="cloudwatch_logs.json"
122+
LOG_GROUP="aws-dbesdk-performance-benchmarks"
123+
LOG_STREAM="go/${{matrix.go-version}}/quick_benchmarks/${{ github.workflow }}"
124+
125+
# Create log stream (ignore if exists)
126+
aws logs create-log-stream \
127+
--log-group-name "$LOG_GROUP" \
128+
--log-stream-name "$LOG_STREAM" 2>/dev/null || true
129+
130+
aws logs put-log-events \
131+
--log-group-name "$LOG_GROUP" \
132+
--log-stream-name "$LOG_STREAM" \
133+
--log-events file://$LOG_FILE
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflow runs every day 09:00 UTC (1AM PST)
2+
name: Performance Benchmarks
3+
4+
permissions:
5+
id-token: write
6+
contents: read
7+
8+
on:
9+
pull_request:
10+
paths:
11+
- ".github/workflows/performance-benchmarks.yml"
12+
schedule:
13+
- cron: "00 16 * * *"
14+
15+
jobs:
16+
getVersion:
17+
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
18+
uses: ./.github/workflows/dafny_version.yml
19+
performance-benchmarks-go:
20+
needs: getVersion
21+
uses: ./.github/workflows/performance-benchmarks-go.yml
22+
with:
23+
dafny: ${{needs.getVersion.outputs.version}}
24+
notify:
25+
needs: [getVersion, performance-benchmarks-go]
26+
if: ${{ failure() }}
27+
uses: aws/aws-cryptographic-material-providers-library/.github/workflows/slack-notification.yml@main
28+
with:
29+
message: "Performance Benchmarks failed on `${{ github.repository }}`. View run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
30+
secrets:
31+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_CI }}

0 commit comments

Comments
 (0)