Skip to content

Commit a53f032

Browse files
committed
Allow benchmark to disable zinc's APIExtract and Dependency phases
The scala-library corpus is known to be a tough one for Zinc, perhaps due to the inheritance heirarchy of the collections. These results confirm that enabling zinc increases compilation time by 1.4x for the full clean build. ``` sbt:zinc Root> zincBenchmarks/jmh:run -p _tempDir=/tmp/zinc-bench-baseline HotScalacBenchmark -penableZinc=false,true -wi 10 -i 6 -f1 [info] Benchmark (_tempDir) (zincEnabled) Mode Cnt Score Error Units [info] HotScalacBenchmark.compile /tmp/zinc-bench-baseline false sample 6 10463.390 ± 128.555 ms/op [info] HotScalacBenchmark.compile:compile·p0.00 /tmp/zinc-bench-baseline false sample 10401.874 ms/op [info] HotScalacBenchmark.compile:compile·p0.50 /tmp/zinc-bench-baseline false sample 10468.983 ms/op [info] HotScalacBenchmark.compile:compile·p0.90 /tmp/zinc-bench-baseline false sample 10519.314 ms/op [info] HotScalacBenchmark.compile:compile·p0.95 /tmp/zinc-bench-baseline false sample 10519.314 ms/op [info] HotScalacBenchmark.compile:compile·p0.99 /tmp/zinc-bench-baseline false sample 10519.314 ms/op [info] HotScalacBenchmark.compile:compile·p0.999 /tmp/zinc-bench-baseline false sample 10519.314 ms/op [info] HotScalacBenchmark.compile:compile·p0.9999 /tmp/zinc-bench-baseline false sample 10519.314 ms/op [info] HotScalacBenchmark.compile:compile·p1.00 /tmp/zinc-bench-baseline false sample 10519.314 ms/op [info] HotScalacBenchmark.compile /tmp/zinc-bench-baseline true sample 6 14610.159 ± 1392.898 ms/op [info] HotScalacBenchmark.compile:compile·p0.00 /tmp/zinc-bench-baseline true sample 14042.530 ms/op [info] HotScalacBenchmark.compile:compile·p0.50 /tmp/zinc-bench-baseline true sample 14554.235 ms/op [info] HotScalacBenchmark.compile:compile·p0.90 /tmp/zinc-bench-baseline true sample 15435.039 ms/op [info] HotScalacBenchmark.compile:compile·p0.95 /tmp/zinc-bench-baseline true sample 15435.039 ms/op [info] HotScalacBenchmark.compile:compile·p0.99 /tmp/zinc-bench-baseline true sample 15435.039 ms/op [info] HotScalacBenchmark.compile:compile·p0.999 /tmp/zinc-bench-baseline true sample 15435.039 ms/op [info] HotScalacBenchmark.compile:compile·p0.9999 /tmp/zinc-bench-baseline true sample 15435.039 ms/op [info] HotScalacBenchmark.compile:compile·p1.00 /tmp/zinc-bench-baseline true sample 15435.039 ms/op ```
1 parent 106b98b commit a53f032

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

internal/zinc-benchmarks/src/main/scala/xsbt/BenchmarkBase.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class BenchmarkBase {
1919
@Param(Array("")) var _tempDir: String = _
2020
var _project: BenchmarkProject = _
2121
var _subprojectToRun: String = _
22+
@Param(Array("true"))
23+
var zincEnabled: Boolean = _
2224

2325
/* Data filled in by the benchmark setup. */
2426
var _dir: File = _
@@ -39,7 +41,7 @@ class BenchmarkBase {
3941
_dir = new File(_tempDir)
4042
assert(_dir.exists(), s"Unexpected inexistent directory ${_tempDir}")
4143

42-
val compiler = new ZincBenchmark(_project)
44+
val compiler = new ZincBenchmark(_project, zincEnabled = this.zincEnabled)
4345
_subprojectsSetup = compiler.readSetup(_dir).getOrCrash
4446
assert(_subprojectsSetup.nonEmpty)
4547

internal/zinc-benchmarks/src/main/scala/xsbt/ZincBenchmark.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import sbt.internal.util.ConsoleLogger
1414
import sbt.io.{ IO, RichFile }
1515
import xsbt.ZincBenchmark.CompilationInfo
1616
import xsbti._
17-
import xsbti.compile.SingleOutput
17+
import xsbti.compile.{ IncOptions, SingleOutput }
1818

1919
import scala.util.Try
2020

@@ -49,7 +49,7 @@ case class ZincSetup(result: ZincBenchmark.Result[List[ProjectSetup]]) {
4949
/* Classes are defined `private[xsbt]` to avoid scoping issues w/ `CachedCompiler0`. */
5050

5151
/** Instantiate a `ZincBenchmark` from a given project. */
52-
private[xsbt] class ZincBenchmark(toCompile: BenchmarkProject) {
52+
private[xsbt] class ZincBenchmark(toCompile: BenchmarkProject, zincEnabled: Boolean = true) {
5353
import ZincBenchmark.WriteBuildInfo
5454

5555
def writeSetup(globalDir: File): WriteBuildInfo = {
@@ -74,7 +74,7 @@ private[xsbt] class ZincBenchmark(toCompile: BenchmarkProject) {
7474

7575
// Set up the compiler and store the current setup
7676
val javaFile = new RichFile(compilationDir) / "benchmark-target"
77-
val runGen = ZincBenchmark.setUpCompiler(buildInfo, javaFile)
77+
val runGen = ZincBenchmark.setUpCompiler(buildInfo, javaFile, zincEnabled)
7878
ProjectSetup(subproject, javaFile, buildInfo, runGen)
7979
}
8080

@@ -108,11 +108,14 @@ private[xsbt] object ZincBenchmark {
108108
/** Set up the compiler to compile `sources` with -cp `classpath` at `targetDir`. */
109109
def setUpCompiler(
110110
compilationInfo: CompilationInfo,
111-
targetDir: File
111+
targetDir: File,
112+
zincEnabled: Boolean
112113
): Generator = () => {
113114
IO.delete(targetDir)
114115
IO.createDirectory(targetDir)
115-
val callback = new xsbti.TestCallback
116+
val callback: xsbti.TestCallback = new xsbti.TestCallback {
117+
override def enabled: Boolean = zincEnabled
118+
}
116119
val compiler = prepareCompiler(targetDir, callback, compilationInfo)
117120
new compiler.Run
118121
}

0 commit comments

Comments
 (0)