Skip to content

Batch publishing #358

Description

@wawanbreton

Hi,
I have setup a benchmark using this action, on a repository that contains resource files. Each resource file is processed individually, and the result is published to a separate benchmark page. This does work very well, however now we have 200+ resource files that are processed, so the results publishing spawns 200+ jobs, that can't run in parallel because they do commit to the same repository. In the end, the publishing takes ~2h because spawning jobs and re-doing the whole publishing each time is not efficient.

I have seen this discussion: #69 which is solved by aggregating the data files, but in my case I don't want to end up with 1000 graphs on the same page 🙂
Is there a more efficient way to do this ?

Here is the workflow, simplified:

jobs:
  benchmark:
    name: Run benchmark
    outputs:
      benchmark_matrix: ${{ steps.prepare_publish_matrix.outputs.benchmark_matrix }}

    steps:
      - name: Run benchmark
        run: |
          mkdir analysis_results
          for file in assets/*; do
            analyzer "$file" --output "analysis_results/$file.json"
          done

      - name: Export benchmark results
        uses: actions/upload-artifact@v6
        with:
          name: analysis_results.zip
          path: analysis_results

      - name: Prepare benchmark publish matrix
        id: prepare_publish_matrix
        run: |
          python3 - <<'PY'
          import json
          import os
          from pathlib import Path

          analysis_results_dir = Path("analysis_results")
          benchmark_files = sorted(analysis_results_dir.glob("*.json"))
          matrix = {
              "include": [
                  {
                      "benchmark_name": benchmark_file.stem,
                      "result_file": str(benchmark_file),
                  }
                  for benchmark_file in benchmark_files
              ]
          }

          output_path = os.environ.get("GITHUB_OUTPUT")
          with open(Path(output_path), "a", encoding="utf-8") as output:
              output.write("benchmark_matrix<<EOF\n")
              output.write(json.dumps(matrix))
              output.write("\nEOF\n")
          PY

  publish-benchmark-results:
    name: Publish result (${{ matrix.benchmark_name }})
    needs: [benchmark]
    strategy:
      fail-fast: false
      max-parallel: 1
      matrix: ${{ fromJson(needs.benchmark.outputs.benchmark_matrix) }}

    steps:
      - name: Download benchmark results
        uses: actions/download-artifact@v7
        with:
          name: analysis_results.zip
          path: analysis_results

      - name: Store benchmark result
        uses: benchmark-action/github-action-benchmark@v1
        with:
          name: Benchmark ${{ matrix.benchmark_name }}
          output-file-path: ${{ matrix.result_file }}
          benchmark-data-dir-path: dev/multi_bench/${{ matrix.benchmark_name }}
          auto-push: true
          max-items-in-chart: 100

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions