This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 5f43291f6ff4f0fe167ba1b448d93a4894242a9d
Author: Volkan Yazıcı <[email protected]>
AuthorDate: Thu Feb 3 16:47:32 2022 +0100

    Align benchmark workflow with release-2.x.
---
 .github/workflows/benchmark.yml | 89 ++++++++++++++++++++++-------------------
 1 file changed, 48 insertions(+), 41 deletions(-)

diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml
index 5dd8b01..6f9de13 100644
--- a/.github/workflows/benchmark.yml
+++ b/.github/workflows/benchmark.yml
@@ -15,21 +15,15 @@
 
 name: benchmark
 
-on: [workflow_dispatch]
+on: [ workflow_dispatch ]
 
 jobs:
 
-  run:
+  build:
 
     if: github.repository == 'apache/logging-log4j2'
 
-    runs-on: ${{ matrix.os }}
-
-    strategy:
-      matrix:
-        os: [macos-latest, ubuntu-latest, windows-latest]
-        jdk: [8, 11, 17]
-        concurrency: [1, 8]
+    runs-on: ubuntu-latest
 
     steps:
 
@@ -50,13 +44,43 @@ jobs:
         run: |
           ./mvnw \
             --show-version --batch-mode --errors --no-transfer-progress \
-            --global-toolchains .github/workflows/maven-toolchains.xml \
             -DskipTests=true \
             --projects log4j-perf \
             --also-make \
             package
 
-      # Switch to the target JDK for running benchmarks
+      - name: Upload built sources
+        uses: actions/upload-artifact@v2
+        with:
+          name: benchmarks.jar
+          path: log4j-perf/target/benchmarks.jar
+
+  run:
+
+    needs: build
+
+    runs-on: ${{ matrix.os }}
+
+    strategy:
+      matrix:
+        os: [ macos-latest, ubuntu-latest, windows-latest ]
+        jdk: [ 11, 17 ]
+        concurrency: [ 1, 8 ]
+        jmhCommand:
+          - "-t $CONCURRENCY -f 3 -wi 3 -w 10s -i 4 -r 20s -prof gc -rf json 
-rff results-layout-jtl.json '.*JsonTemplateLayoutBenchmark.*'"
+          - "-t $CONCURRENCY -f 3 -wi 3 -w 10s -i 4 -r 20s -prof gc -rf json 
-rff results-util-instant-format.json '.*InstantFormatBenchmark.*'"
+
+    steps:
+
+      - name: Checkout repository
+        uses: actions/checkout@v2
+
+      - name: Download built sources
+        uses: actions/download-artifact@v2
+        with:
+          name: benchmarks.jar
+          path: log4j-perf/target
+
       - name: Set up JDK ${{ matrix.jdk }}
         if: matrix.jdk != 11
         uses: actions/[email protected]
@@ -67,35 +91,14 @@ jobs:
           architecture: x64
           cache: maven
 
-      # 
------------------------------------------------------------------------
-      # BEGIN: Individual Benchmark Runs
-      #
-      # Add your benchmarks below.
-      # Make sure that your benchmark job
-      #
-      # - has a decent `timeout-minutes` property.
-      # - uses `bash` for shell.
-      #   `pwsh`, the default shell on Windows, hijacks certain keywords and 
results in unexpected ways.
-      # - generates a JSON-formatted result output to 
`log4j-perf/target/results-<name>.json`.
-      #   In `<name>`, prefer hierarchical and bash-friendly names.
-      #   For instance, `layout-pattern`, `layout-jtl`, `appender-file`, etc.
-
-      - name: Run JSON Template Layout benchmarks
-        timeout-minutes: 60
-        if: ${{ matrix.concurrency == 1 }}
+      - name: Run benchmarks
+        timeout-minutes: 120
         shell: bash
         run: |
+          export CONCURRENCY=${{ matrix.concurrency }}
           java \
             -jar log4j-perf/target/benchmarks.jar \
-            -f 2 \
-            -wi 3 -w 20s \
-            -i 5 -r 30s \
-            -prof gc \
-            -rf json -rff log4j-perf/target/results-layout-jtl.json \
-            ".*JsonTemplateLayoutBenchmark.*"
-
-      # END: Individual Benchmark Runs
-      # 
------------------------------------------------------------------------
+            ${{ matrix.jmhCommand }}
 
       - name: Stage benchmark results for commit
         shell: bash
@@ -119,8 +122,8 @@ jobs:
           export RUN_ID=$(printf "%020d" "$GITHUB_RUN_ID")
 
           # Move and stage the result files.
-          for SRC_FILEPATH in log4j-perf/target/results-*.json; do
-            export BENCHMARK_NAME=$(basename "$SRC_FILEPATH" | sed -r 
's/results-(.+)\.json$/\1/')
+          for SRC_FILEPATH in results-*.json; do
+            export BENCHMARK_NAME=$(basename "$SRC_FILEPATH" | sed 
's/^results-//g' | sed 's/\.json$//g')
             export 
DST_FILEPATH="benchmark/results/$REVISION/$BRANCH_NAME-$INSTANT-$RUN_ID/$BENCHMARK_NAME-O$OS_NAME-J${{
 matrix.jdk }}-C${{ matrix.concurrency }}.json"
             mkdir -v -p $(dirname "$DST_FILEPATH")
             mv -v "$SRC_FILEPATH" "$DST_FILEPATH"
@@ -196,6 +199,7 @@ jobs:
 
           # Push changes in a loop to allow concurrent repository 
modifications.
           export RETRY=0
+          export INDEX_FILEPATH=benchmark/results/index.json
           while [ 1 ]; do
 
             # Generate the index file.
@@ -206,11 +210,14 @@ jobs:
                       for filename in filenames]; \
               filepaths.remove("index.json"); \
               print(json.dumps(filepaths))' \
-            >benchmark/results/index.json
+            >"$INDEX_FILEPATH"
+
+            # Exit if there are no changes, that is, a concurrent job has 
indexed all results.
+            git diff --exit-code "$INDEX_FILEPATH" && exit 0
 
             # Commit the index file.
-            git add benchmark/results/index.json
-            git commit benchmark/results/index.json -m "Update benchmark 
results index."
+            git add "$INDEX_FILEPATH"
+            git commit "$INDEX_FILEPATH" -m "Update benchmark results index."
 
             # Push the index file.
             set +e

Reply via email to