Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run zinc benchmarks in parallel #1323

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
- os: ubuntu-latest
java: 21
jobtype: 4
- os: ubuntu-latest
java: 21
jobtype: 5
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand All @@ -50,9 +53,14 @@ jobs:
if: ${{ matrix.jobtype == 3 }}
shell: bash
run: |
sbt -v -Dfile.encoding=UTF-8 "runBenchmarks"
- name: Build and test (4)
sbt -v -Dfile.encoding=UTF-8 scalafmtCheckAll scalafmtSbtCheck
- name: Benchmark (Scalac) (4)
if: ${{ matrix.jobtype == 4 }}
shell: bash
run: |
sbt -v -Dfile.encoding=UTF-8 scalafmtCheckAll scalafmtSbtCheck
sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Scalac.*" "runBenchmarks"
- name: Benchmark (Shapeless) (5)
if: ${{ matrix.jobtype == 5 }}
shell: bash
run: |
sbt -v -Dfile.encoding=UTF-8 "-Dbenchmark.pattern=.*Shapeless.*" "runBenchmarks"
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -697,11 +697,12 @@ crossTestBridges := (compilerBridgeTest.jvm(scala213) / Test / test).dependsOn(p
addCommandAlias(
"runBenchmarks", {
val dir = IO.createTemporaryDirectory.getAbsolutePath
val pattern = sys.props.getOrElse("benchmark.pattern", "")
Seq(
s"${compilerBridge213.id}/packageBin",
s"${compilerBridge212.id}/packageBin",
s"${zincBenchmarks.jvm(scala212).id}/Test/run $dir",
s"${zincBenchmarks.jvm(scala212).id}/jmh:run -p _tempDir=$dir -prof gc -foe true",
s"${zincBenchmarks.jvm(scala212).id}/Test/run $dir $pattern",
s"${zincBenchmarks.jvm(scala212).id}/jmh:run -p _tempDir=$dir -prof gc -foe true $pattern",
s"""eval IO.delete(file("$dir"))""",
).mkString(";", ";", "")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ import xsbt.BenchmarkProjects.{ Scalac, Shapeless }
object GlobalBenchmarkSetup {

/** Update this list every time you add a new benchmark. */
val projects = List(Scalac, Shapeless)
val projects = Map("Scalac" -> Scalac, "Shapeless" -> Shapeless)

def runSetup(setupDir: File): (Int, String) = {
val projectsPreparation = projects.map { project =>
val benchmark = new ZincBenchmark(project)
project -> benchmark.writeSetup(new File(setupDir, project.repo))
}
def runSetup(setupDir: File, pattern: String): (Int, String) = {
val projectsPreparation = projects
.filterKeys { _.matches(pattern) }
.map { case (_, project) =>
val benchmark = new ZincBenchmark(project)
project -> benchmark.writeSetup(new File(setupDir, project.repo))
}

val failedToPrepare = projectsPreparation.filter(_._2.isLeft)
if (failedToPrepare.isEmpty)
Expand All @@ -43,11 +45,12 @@ object GlobalBenchmarkSetup {

if (args.isEmpty)
fail("Missing directory to host project setups.")
else if (args.length > 1)
else if (args.length > 2)
fail("Too many arguments. Pass the directory to host project setups.")
else {
val setupDir = new File(args(0))
val (exitCode, status) = runSetup(setupDir)
val pattern = if (args.length == 1) ".*" else args(1)
val (exitCode, status) = runSetup(setupDir, pattern)
println(status)
println("The benchmark setup has finished.")
System.exit(exitCode)
Expand Down