From 2ef3dd981ed90eb30c1de1cd0bfb07f016acf432 Mon Sep 17 00:00:00 2001 From: friendseeker <66892505+Friendseeker@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:41:58 -0700 Subject: [PATCH] Run 3 AnalysisFormatBenchmark in Parallel --- .github/workflows/ci.yml | 43 ++++++++++++---- .../scala/xsbt/AnalysisFormatBenchmark.scala | 50 +++++++++++++------ 2 files changed, 70 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86b9faeec..3fad0d78d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,12 @@ jobs: - os: ubuntu-latest java: 21 jobtype: 6 + - os: ubuntu-latest + java: 21 + jobtype: 7 + - os: ubuntu-latest + java: 21 + jobtype: 8 runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -67,29 +73,48 @@ jobs: shell: bash run: | sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Shapeless.*" "runBenchmarks" - - name: Benchmark (AnalysisFormatBenchmark) (6) + - name: Benchmark (CompilerSerializationBenchmark) (6) if: ${{ matrix.jobtype == 6 }} shell: bash run: | - sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*AnalysisFormatBenchmark.*" "zincBenchmarks/Jmh/clean" "runBenchmarks" - - name: Checkout Target Branch (4, 5) - if: ${{ github.event_name == 'pull_request' && (matrix.jobtype == 4 || matrix.jobtype == 5) }} + sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Compiler.*" "runBenchmarks" + - name: Benchmark (LibrarySerializationBenchmark) (7) + if: ${{ matrix.jobtype == 7 }} + shell: bash + run: | + sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Library.*" "runBenchmarks" + - name: Benchmark (ReflectSerializationBenchmark) (8) + if: ${{ matrix.jobtype == 8 }} + shell: bash + run: | + sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Reflect.*" "runBenchmarks" + - name: Checkout Target Branch (4-8) + if: ${{ github.event_name == 'pull_request' && matrix.jobtype >= 4 && matrix.jobtype <= 8 }} uses: actions/checkout@v4 with: - clean: false ref: ${{ github.event.pull_request.base.ref }} - name: Benchmark (Scalac) against Target Branch (4) if: ${{ github.event_name == 'pull_request' && matrix.jobtype == 4 }} shell: bash run: | - sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Scalac.*" "zincBenchmarks/Jmh/clean" "runBenchmarks" + sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Scalac.*" "runBenchmarks" - name: Benchmark (Shapeless) against Target Branch (5) if: ${{ github.event_name == 'pull_request' && matrix.jobtype == 5 }} shell: bash run: | - sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Shapeless.*" "zincBenchmarks/Jmh/clean" "runBenchmarks" - - name: Benchmark (AnalysisFormatBenchmark) against Target Branch (6) + sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Shapeless.*" "runBenchmarks" + - name: Benchmark (CompilerSerializationBenchmark) against Target Branch (6) if: ${{ matrix.jobtype == 6 }} shell: bash run: | - sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*AnalysisFormatBenchmark.*" "zincBenchmarks/Jmh/clean" "runBenchmarks" + sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Compiler.*" "runBenchmarks" + - name: Benchmark (LibrarySerializationBenchmark) against Target Branch (7) + if: ${{ matrix.jobtype == 7 }} + shell: bash + run: | + sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Library.*" "runBenchmarks" + - name: Benchmark (ReflectSerializationBenchmark) against Target Branch (8) + if: ${{ matrix.jobtype == 8 }} + shell: bash + run: | + sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Reflect.*" "runBenchmarks" diff --git a/internal/zinc-benchmarks/src/test/scala/xsbt/AnalysisFormatBenchmark.scala b/internal/zinc-benchmarks/src/test/scala/xsbt/AnalysisFormatBenchmark.scala index 353a52eb3..a210b8170 100644 --- a/internal/zinc-benchmarks/src/test/scala/xsbt/AnalysisFormatBenchmark.scala +++ b/internal/zinc-benchmarks/src/test/scala/xsbt/AnalysisFormatBenchmark.scala @@ -12,29 +12,21 @@ import sbt.io.IO import xsbti.compile.analysis.ReadWriteMappers import xsbti.compile.{ AnalysisContents, AnalysisStore } -@BenchmarkMode(Array(Mode.AverageTime)) -@Fork(1) -@Threads(1) -@Warmup(iterations = 5) -@Measurement(iterations = 5) -@OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) class AnalysisFormatBenchmark { var temp: File = _ - val sets = IndexedSeq("compiler", "reflect", "library") + var binaryFileName: String = _ var cached: Map[String, AnalysisContents] = _ @Setup def setup(): Unit = { this.temp = IO.createTemporaryDirectory - sets.foreach { s => - val f = new File("../../../test-data", s"${s}.zip") - assert(f.exists()) - val f2 = new File(temp, f.getName) - IO.copyFile(f, f2) - assert(f2.exists()) - } + val f = new File("../../../test-data", s"${binaryFileName}.zip") + assert(f.exists()) + val f2 = new File(temp, f.getName) + IO.copyFile(f, f2) + assert(f2.exists()) this.cached = readAll("", FileAnalysisStore.binary(_)) writeAll("-ref-text", FileAnalysisStore.text(_), cached) // writeAll("-ref-ctext", ConsistentFileAnalysisStore.text(_, ReadWriteMappers.getEmptyMappers), cached) @@ -174,3 +166,33 @@ class NullSerializer extends Serializer { def long(l: Long): Unit = _count += 1 def end(): Unit = _count += 1 } + +@BenchmarkMode(Array(Mode.AverageTime)) +@Fork(1) +@Threads(1) +@Warmup(iterations = 5) +@Measurement(iterations = 5) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +class CompilerSerializationBenchmark extends AnalysisFormatBenchmark { + binaryFileName = "compiler" +} + +@BenchmarkMode(Array(Mode.AverageTime)) +@Fork(1) +@Threads(1) +@Warmup(iterations = 5) +@Measurement(iterations = 5) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +class LibrarySerializationBenchmark extends AnalysisFormatBenchmark { + binaryFileName = "library" +} + +@BenchmarkMode(Array(Mode.AverageTime)) +@Fork(1) +@Threads(1) +@Warmup(iterations = 5) +@Measurement(iterations = 5) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +class ReflectSerializationBenchmark extends AnalysisFormatBenchmark { + binaryFileName = "reflect" +}