|
| 1 | +# This workflow runs every day 16:00 UTC (8PM 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 | + |
| 27 | +jobs: |
| 28 | + testRust: |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + library: [DynamoDbEncryption] |
| 33 | + benchmark-dir: [db-esdk-performance-testing] |
| 34 | + # removed windows-latest because somehow it can't build aws-lc in CI |
| 35 | + os: [ubuntu-22.04, macos-15-intel] |
| 36 | + runs-on: ${{ matrix.os }} |
| 37 | + permissions: |
| 38 | + id-token: write |
| 39 | + contents: read |
| 40 | + env: |
| 41 | + RUST_MIN_STACK: 838860800 |
| 42 | + steps: |
| 43 | + - name: Configure AWS Credentials |
| 44 | + uses: aws-actions/configure-aws-credentials@v5 |
| 45 | + with: |
| 46 | + aws-region: us-west-2 |
| 47 | + role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2 |
| 48 | + role-session-name: DDBEC-Dafny-Rust-Tests |
| 49 | + |
| 50 | + - name: Setup Docker |
| 51 | + if: matrix.os == 'macos-15-intel' && matrix.library == 'TestVectors' |
| 52 | + uses: douglascamata/setup-docker-macos-action@v1.0.2 |
| 53 | + |
| 54 | + - name: Support longpaths on Git checkout |
| 55 | + run: | |
| 56 | + git config --global core.longpaths true |
| 57 | + - uses: actions/checkout@v5 |
| 58 | + - name: Init Submodules |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + git submodule update --init --recursive submodules/smithy-dafny |
| 62 | + git submodule update --init --recursive submodules/MaterialProviders |
| 63 | +
|
| 64 | + - name: Setup Rust Toolchain for GitHub CI |
| 65 | + uses: actions-rust-lang/setup-rust-toolchain@v1 |
| 66 | + with: |
| 67 | + components: rustfmt |
| 68 | + |
| 69 | + - name: Setup Dafny |
| 70 | + uses: ./submodules/MaterialProviders/.github/actions/setup_dafny/ |
| 71 | + with: |
| 72 | + dafny-version: 4.10.0 |
| 73 | + |
| 74 | + - name: Update MPL submodule if using MPL HEAD |
| 75 | + if: ${{ inputs.mpl-head == true }} |
| 76 | + working-directory: submodules/MaterialProviders |
| 77 | + run: | |
| 78 | + git checkout main |
| 79 | + git pull |
| 80 | + git submodule update --init --recursive |
| 81 | + git rev-parse HEAD |
| 82 | +
|
| 83 | + - name: Setup Java 17 for codegen |
| 84 | + uses: actions/setup-java@v5 |
| 85 | + with: |
| 86 | + distribution: "corretto" |
| 87 | + java-version: "17" |
| 88 | + |
| 89 | + - name: Install Smithy-Dafny codegen dependencies |
| 90 | + uses: ./.github/actions/install_smithy_dafny_codegen_dependencies |
| 91 | + |
| 92 | + - name: Run make polymorph_rust |
| 93 | + shell: bash |
| 94 | + working-directory: ./${{ matrix.library }} |
| 95 | + run: | |
| 96 | + make polymorph_rust |
| 97 | +
|
| 98 | + - name: Compile ${{ matrix.library }} implementation |
| 99 | + shell: bash |
| 100 | + working-directory: ./${{ matrix.library }} |
| 101 | + run: | |
| 102 | + # This works because `node` is installed by default on GHA runners |
| 103 | + CORES=$(node -e 'console.log(os.cpus().length)') |
| 104 | + make transpile_rust TRANSPILE_TESTS_IN_RUST=1 CORES=$CORES |
| 105 | +
|
| 106 | + - name: Run Performance Benchmarks - Quick Mode |
| 107 | + shell: bash |
| 108 | + working-directory: ./${{matrix.benchmark-dir}}/benchmarks/rust |
| 109 | + run: | |
| 110 | + cargo run --release -- --quick |
| 111 | +
|
| 112 | + - name: Parse and Format Logs |
| 113 | + working-directory: ./${{matrix.benchmark-dir}}/benchmarks/results/raw-data/ |
| 114 | + run: | |
| 115 | + LOG_FILE="rust_results.json" |
| 116 | + UPLOAD_FILE="cloudwatch_logs.json" |
| 117 | + TIMESTAMP=$(date +%s%3N) |
| 118 | + 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 |
| 119 | +
|
| 120 | + - name: Upload logs to CloudWatch |
| 121 | + working-directory: ./${{matrix.benchmark-dir}}/benchmarks/results/raw-data/ |
| 122 | + run: | |
| 123 | + LOG_FILE="cloudwatch_logs.json" |
| 124 | + LOG_GROUP="aws-dbesdk-performance-benchmarks" |
| 125 | + LOG_STREAM="rust/quick_benchmarks/${{ github.workflow }}" |
| 126 | +
|
| 127 | + # Create log stream (ignore if exists) |
| 128 | + aws logs create-log-stream \ |
| 129 | + --log-group-name "$LOG_GROUP" \ |
| 130 | + --log-stream-name "$LOG_STREAM" 2>/dev/null || true |
| 131 | +
|
| 132 | + aws logs put-log-events \ |
| 133 | + --log-group-name "$LOG_GROUP" \ |
| 134 | + --log-stream-name "$LOG_STREAM" \ |
| 135 | + --log-events file://$LOG_FILE |
0 commit comments