Skip to content

Commit

Permalink
Merge pull request #27 from potsrevennil/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
potsrevennil authored Nov 19, 2024
2 parents 75f52dc + be8720b commit 81ed54f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 19 deletions.
20 changes: 5 additions & 15 deletions .github/actions/bench/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,15 @@ runs:
- name: Run benchmark
shell: ${{ env.SHELL }}
run: |
./scripts/tests bench -c ${{ inputs.perf }} --cross-prefix="${{ inputs.cross_prefix }}" \
--cflags="${{ inputs.cflags }}" --arch-flags="${{ inputs.archflags }}" \
--opt=$([[ ${{ inputs.opt }} == "false" ]] && echo "no_opt" || echo "opt") \
-v --output=output.json ${{ inputs.bench_extra_args }}
./scripts/tests bench --components -c ${{ inputs.perf }} --cross-prefix="${{ inputs.cross_prefix }}" \
--cflags="${{ inputs.cflags }}" --arch-flags="${{ inputs.archflags }}" \
--opt=$([[ ${{ inputs.opt }} == "false" ]] && echo "no_opt" || echo "opt") \
-v --output=output.json ${{ inputs.bench_extra_args }}
- name: Check namespace
shell: ${{ env.SHELL }}
run: |
check-namespace
./scripts/bench
- name: Store benchmark result
if: ${{ inputs.store_results == 'true' }}
uses: benchmark-action/github-action-benchmark@v1
with:
name: ${{ inputs.name }}
tool: "customSmallerIsBetter"
output-file-path: output.json
github-token: ${{ inputs.gh_token }}
auto-push: true
auto-push: ${{ inputs.store_results == 'true' }}
comment-on-alert: true
summary-always: true
alert-threshold: 103%
22 changes: 18 additions & 4 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
# SPDX-License-Identifier: Apache-2.0

name: Bench
permissions:
contents: read
on:
workflow_dispatch:
push:
branches: ["main"]
pull_request:
branches: ["main"]
types: [ "labeled" ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
bench-test:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ./.github/actions/bench
with:
nix-shell: ''
name: test
archflags: -mavx2 -mbmi2 -mpopcnt -maes
cflags: -DFORCE_X86_64
perf: PMU
store_results: ${{ github.ref == 'refs/heads/main' }}
gh_token: ${{ secrets.GITHUB_TOKEN }}
opt: true
bench:
name: ${{ matrix.target.name }}
strategy:
Expand Down Expand Up @@ -56,7 +70,7 @@ jobs:
ec2_all:
name: ${{ matrix.target.name }} ${{ matrix.opt.name }}
permissions:
contents: 'read'
contents: 'write'
id-token: 'write'
strategy:
fail-fast: false
Expand Down
37 changes: 37 additions & 0 deletions scripts/bench
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0

import json
from enum import IntEnum

output = "output.json"


class SCHEME(IntEnum):
MLKEM512 = 1
MLKEM768 = 2
MLKEM1024 = 3

def __str__(self):
match self:
case SCHEME.MLKEM512:
return "ML-KEM-512"
case SCHEME.MLKEM768:
return "ML-KEM-768"
case SCHEME.MLKEM1024:
return "ML-KEM-1024"


with open(output, "w") as f:
v = []
for scheme in SCHEME:
for primitive in ["keypair", "encaps", "decaps"]:
v.append(
{
"name": f"{str(scheme)} {primitive}",
"unit": "cycles",
"value": 1234567,
}
)

f.write(json.dumps(v))

1 comment on commit 81ed54f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'test'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.03.

Benchmark suite Current: 81ed54f Previous: 2989913 Ratio
ML-KEM-512 keypair 1234567 cycles 12345 cycles 100.01
ML-KEM-512 encaps 1234567 cycles 12345 cycles 100.01
ML-KEM-512 decaps 1234567 cycles 12345 cycles 100.01
ML-KEM-768 keypair 1234567 cycles 12345 cycles 100.01
ML-KEM-768 encaps 1234567 cycles 12345 cycles 100.01
ML-KEM-768 decaps 1234567 cycles 12345 cycles 100.01
ML-KEM-1024 keypair 1234567 cycles 12345 cycles 100.01
ML-KEM-1024 encaps 1234567 cycles 12345 cycles 100.01
ML-KEM-1024 decaps 1234567 cycles 12345 cycles 100.01

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.