[Internal] Micro-optimisation: Reuse previously calculated java.langSystem.nanoTime
#2382
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired by Flavio W. Brasil's work on Kyo: https://github.com/fwbrasil/kyo | |
name: Benchs | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
types: [ opened, reopened, synchronize ] | |
branches-ignore: | |
- gh-pages | |
# Prevent multiple builds at the same time from the same branch (except for 'master'). | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.run_id || github.ref }} | |
cancel-in-progress: true | |
permissions: | |
# deployments permission to deploy GitHub pages website | |
deployments: write | |
# contents permission to update benchmark contents in gh-pages branch | |
contents: write | |
jobs: | |
benchmark: # See https://github.com/marketplace/actions/continuous-benchmark | |
name: Run benchmark | |
runs-on: ubuntu-latest | |
if: ${{ !github.event.pull_request.head.repo.fork }} # comes from https://github.com/orgs/community/discussions/25217#discussioncomment-3246904 | |
steps: | |
- name: Checkout current branch | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
check-latest: true | |
- uses: VirtusLab/scala-cli-setup@main | |
- name: Use CI sbt jvmopts | |
shell: bash | |
run: | | |
mv .jvmopts .jvmopts_old | |
mv .jvmopts-ci .jvmopts | |
cat .jvmopts | |
- name: compile | |
run: sbt compile | |
- name: run benchmarks | |
# To list all possible options and understand these configurations, see run `sbt "zioKafkaBench/Jmh/run -h"` | |
# | |
# Used options meaning: | |
# - "-wi 5": 5 warmup iterations | |
# - "-i 5": 5 benchmark iterations | |
# - "-r 1": Minimum time to spend at each measurement iteration. 1 second | |
# - "-w 1": Minimum time to spend at each warmup iteration. 1 second | |
# - "-t 1": Number of worker threads to run with. 1 thread | |
# - "-rf json": Format type for machine-readable results. JSON | |
# - "-foe true": Should JMH fail immediately if any benchmark had experienced an unrecoverable error?. True | |
# - "-to 60": 1 minute timeout per iteration | |
run: sbt "zioKafkaBench/Jmh/run -wi 5 -i 5 -r 1 -w 1 -t 1 -to 120 -rf json -foe true" | |
- name: Download previous benchmark data | |
uses: actions/cache@v3 | |
with: | |
path: ./cache | |
key: ${{ runner.os }}-benchmark | |
- name: Rollback - Use CI sbt jvmopts | |
shell: bash | |
run: | | |
mv .jvmopts .jvmopts-ci | |
mv .jvmopts_old .jvmopts | |
cat .jvmopts | |
- name: Store benchmark result | |
uses: benchmark-action/github-action-benchmark@v1 | |
with: | |
name: JMH Benchmark | |
tool: 'jmh' | |
output-file-path: zio-kafka-bench/jmh-result.json | |
# Access token to deploy GitHub Pages branch | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
# Push and deploy GitHub pages branch automatically | |
auto-push: true | |
alert-threshold: '200%' | |
comment-on-alert: true | |
fail-on-alert: true | |
# Mention these maintainers in the commit comment | |
alert-comment-cc-users: '@svroonland,@guizmaii,@erikvanoosten' | |
- name: Prune benchmark history | |
if: ${{ github.event_name != 'pull_request' }} | |
run: | | |
echo "::group::Checkout gh-pages branch" | |
git clean -fdx | |
git checkout gh-pages | |
git branch --set-upstream-to=origin/gh-pages gh-pages | |
git pull --rebase | |
git config --global user.name "zio-kafka CI" | |
git config --global user.email "[email protected]" | |
echo "::endgroup::" | |
echo "Prune benchmark history" | |
scala-cli scripts/prune-benchmark-history.sc | |
git push |