Skip to content

Revert JMH runner update #14082

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

Merged
merged 3 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 15 additions & 15 deletions bench/profiles/ci.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
scripts:

re2s:
- measure -wi 1 -i 1 -f 1 -- $(find $PROG_HOME/tests/re2s/src -name *.scala)
- measure 1 1 1 $(find $PROG_HOME/tests/re2s/src -name *.scala)

implicit-cache:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/implicit_cache.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/implicit_cache.scala

implicit-cache-from-tasty:
- source $PROG_HOME/dotty/bench/scripts/implicit-cache-from-tasty

implicit-scope-loop:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/implicit-scope-loop.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/implicit-scope-loop.scala

i1535:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/i1535.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/i1535.scala

i1687:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/i1687.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/i1687.scala

empty-class:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/empty-class.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/empty-class.scala

empty-object:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/empty-object.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/empty-object.scala

empty-file:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/empty-file.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/empty-file.scala

patmatexhaust:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/patmatexhaust.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/patmatexhaust.scala

exhaustivity-I:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/exhaustivity-I.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/exhaustivity-I.scala

exhaustivity-S:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/exhaustivity-S.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/exhaustivity-S.scala

exhaustivity-T:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/exhaustivity-T.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/exhaustivity-T.scala

exhaustivity-V:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/exhaustivity-V.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/exhaustivity-V.scala

implicitNums:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/implicitNums.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/implicitNums.scala

implicitNums-from-tasty:
- source $PROG_HOME/dotty/bench/scripts/implicitNums-from-tasty

inductive-implicits:
- measure -wi 1 -i 1 -f 1 -- $PROG_HOME/dotty/tests/bench/inductive-implicits.scala
- measure 1 1 1 $PROG_HOME/dotty/tests/bench/inductive-implicits.scala

scalap:
- source $PROG_HOME/dotty/bench/scripts/scalap
Expand Down
6 changes: 3 additions & 3 deletions bench/profiles/empty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ charts:
scripts:

empty-class:
- measure -- $PROG_HOME/dotty/tests/bench/empty-class.scala
- measure $PROG_HOME/dotty/tests/bench/empty-class.scala

empty-object:
- measure -- $PROG_HOME/dotty/tests/bench/empty-object.scala
- measure $PROG_HOME/dotty/tests/bench/empty-object.scala

empty-file:
- measure -- $PROG_HOME/dotty/tests/bench/empty-file.scala
- measure $PROG_HOME/dotty/tests/bench/empty-file.scala

config:
pr_base_url: "https://github.com/lampepfl/dotty/pull/"
16 changes: 8 additions & 8 deletions bench/profiles/exhaustivity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,28 @@ charts:
scripts:

patmatexhaust:
- measure -wi 20 -i 40 -f 3 -- $PROG_HOME/dotty/tests/bench/patmatexhaust.scala
- measure 20 40 3 $PROG_HOME/dotty/tests/bench/patmatexhaust.scala

exhaustivity-I:
- measure -wi 20 -i 40 -f 3 -- $PROG_HOME/dotty/tests/bench/exhaustivity-I.scala
- measure 20 40 3 $PROG_HOME/dotty/tests/bench/exhaustivity-I.scala

exhaustivity-S:
- measure -wi 20 -i 40 -f 3 -- $PROG_HOME/dotty/tests/bench/exhaustivity-S.scala
- measure 20 40 3 $PROG_HOME/dotty/tests/bench/exhaustivity-S.scala

exhaustivity-T:
- measure -wi 20 -i 40 -f 3 -- $PROG_HOME/dotty/tests/bench/exhaustivity-T.scala
- measure 20 40 3 $PROG_HOME/dotty/tests/bench/exhaustivity-T.scala

exhaustivity-V:
- measure -wi 20 -i 40 -f 3 -- $PROG_HOME/dotty/tests/bench/exhaustivity-V.scala
- measure 20 40 3 $PROG_HOME/dotty/tests/bench/exhaustivity-V.scala

exhaustivity-mips:
- measure -wi 20 -i 40 -f 3 -- $PROG_HOME/dotty/tests/patmat/i7186.scala
- measure 20 40 3 $PROG_HOME/dotty/tests/patmat/i7186.scala

exhaustivity-i12241:
- measure -wi 20 -i 40 -f 3 -- $PROG_HOME/dotty/tests/patmat/i12241.scala
- measure 20 40 3 $PROG_HOME/dotty/tests/patmat/i12241.scala

exhaustivity-i12358:
- measure -wi 20 -i 40 -f 3 -- $PROG_HOME/dotty/tests/patmat/i12358.scala
- measure 20 40 3 $PROG_HOME/dotty/tests/patmat/i12358.scala

exhaustivity-i13565:
- measure 20 40 3 $PROG_HOME/dotty/tests/pos/i13565.scala
Expand Down
8 changes: 4 additions & 4 deletions bench/profiles/implicits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ charts:
scripts:

implicit-cache:
- measure -- $PROG_HOME/dotty/tests/bench/implicit_cache.scala
- measure $PROG_HOME/dotty/tests/bench/implicit_cache.scala

implicit-cache-from-tasty:
- source $PROG_HOME/dotty/bench/scripts/implicit-cache-from-tasty

implicit-scope-loop:
- measure -- $PROG_HOME/dotty/tests/bench/implicit-scope-loop.scala
- measure $PROG_HOME/dotty/tests/bench/implicit-scope-loop.scala

inductive-implicits:
- measure -- $PROG_HOME/dotty/tests/bench/inductive-implicits.scala
- measure $PROG_HOME/dotty/tests/bench/inductive-implicits.scala

implicitNums:
- measure -- $PROG_HOME/dotty/tests/bench/implicitNums.scala
- measure $PROG_HOME/dotty/tests/bench/implicitNums.scala

implicitNums-from-tasty:
- source $PROG_HOME/dotty/bench/scripts/implicitNums-from-tasty
Expand Down
4 changes: 2 additions & 2 deletions bench/profiles/misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ charts:
scripts:

i1535:
- measure -- $PROG_HOME/dotty/tests/bench/i1535.scala
- measure $PROG_HOME/dotty/tests/bench/i1535.scala

i1687:
- measure -- $PROG_HOME/dotty/tests/bench/i1687.scala
- measure $PROG_HOME/dotty/tests/bench/i1687.scala
4 changes: 2 additions & 2 deletions bench/profiles/projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ charts:

scripts:
dotty:
- measure -- -with-compiler $(find $PROG_HOME/dotty/compiler/src/dotty -name *.scala -o -name *.java)
- measure -with-compiler $(find $PROG_HOME/dotty/compiler/src/dotty -name *.scala -o -name *.java)

re2s:
- measure -- $(find $PROG_HOME/tests/re2s/src -name *.scala)
- measure $(find $PROG_HOME/tests/re2s/src -name *.scala)

# scalapb:
# - source $PROG_HOME/dotty/bench/scripts/scalapb
Expand Down
2 changes: 1 addition & 1 deletion bench/profiles/sbt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ charts:

scripts:
dotty-sbt:
- measure -- -with-compiler -Yforce-sbt-phases -with-dotty $(find $PROG_HOME/dotty/compiler/src/dotty -name *.scala -o -name *.java)
- measure -with-compiler -Yforce-sbt-phases -with-dotty $(find $PROG_HOME/dotty/compiler/src/dotty -name *.scala -o -name *.java)

config:
pr_base_url: "https://github.com/lampepfl/dotty/pull/"
10 changes: 5 additions & 5 deletions bench/profiles/tuples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ charts:
scripts:

tuple22-creation-apply:
- measure -- $PROG_HOME/dotty/tests/bench/tuple22-creation-apply.scala
- measure $PROG_HOME/dotty/tests/bench/tuple22-creation-apply.scala

tuple22-creation-cons:
- measure -- $PROG_HOME/dotty/tests/bench/tuple22-creation-cons.scala
- measure $PROG_HOME/dotty/tests/bench/tuple22-creation-cons.scala

tuple22-tails:
- measure -- $PROG_HOME/dotty/tests/bench/tuple22-tails.scala
- measure $PROG_HOME/dotty/tests/bench/tuple22-tails.scala

tuple22-apply:
- measure -- $PROG_HOME/dotty/tests/bench/tuple22-apply.scala
- measure $PROG_HOME/dotty/tests/bench/tuple22-apply.scala

tuple22-size:
- measure -- $PROG_HOME/dotty/tests/bench/tuple22-size.scala
- measure $PROG_HOME/dotty/tests/bench/tuple22-size.scala

tuple-reverse:
- measure-run TupleOps.reverse
Expand Down
2 changes: 1 addition & 1 deletion bench/profiles/typing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ charts:
scripts:

find-ref:
- measure -- $PROG_HOME/dotty/tests/bench/FindRef.scala
- measure $PROG_HOME/dotty/tests/bench/FindRef.scala

config:
pr_base_url: "https://github.com/lampepfl/dotty/pull/"
2 changes: 1 addition & 1 deletion bench/scripts/collection-vector.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
sbt "dotty-bench-bootstrapped/jmh:run -wi 40 -i 40 -f 3 -- bench/tests/Vector.scala"
sbt "dotty-bench-bootstrapped/jmh:run 40 40 3 bench/tests/Vector.scala"
2 changes: 1 addition & 1 deletion bench/scripts/compiler-cold.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
find compiler/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench-bootstrapped/jmh:run -wi 0 -i 1 -f 10 -- " {} + | sbt
find compiler/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench-bootstrapped/jmh:run 0 1 10" {} + | sbt
2 changes: 1 addition & 1 deletion bench/scripts/compiler.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
find compiler/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench-bootstrapped/jmh:run -wi 5 -i 10 -- " {} + | sbt
find compiler/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench-bootstrapped/jmh:run 5 10" {} + | sbt
2 changes: 1 addition & 1 deletion bench/scripts/library-cold.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
find library/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench-bootstrapped/jmh:run -wi 0 -i 1 -f 10 -- " {} + | sbt
find library/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench-bootstrapped/jmh:run 0 1 10" {} + | sbt
2 changes: 1 addition & 1 deletion bench/scripts/library.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
find library/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench-bootstrapped/jmh:run -wi 40 -i 30 -- " {} + | sbt
find library/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench-bootstrapped/jmh:run 40 30" {} + | sbt
66 changes: 26 additions & 40 deletions bench/src/main/scala/Benchmarks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import reporting._

import org.openjdk.jmh.results.RunResult
import org.openjdk.jmh.runner.Runner
import org.openjdk.jmh.runner.options.{OptionsBuilder, CommandLineOptions}
import org.openjdk.jmh.runner.options.OptionsBuilder
import org.openjdk.jmh.annotations._
import org.openjdk.jmh.results.format._
import java.util.concurrent.TimeUnit
Expand All @@ -22,47 +22,37 @@ import dotty.tools.io.AbstractFile
object Bench {
val COMPILE_OPTS_FILE = "compile.txt"

def printUsage() =
println("Usage (from SBT): scala3-bench/jmh:run <JMH arguments> -- <scalac arguments>")
println("Display JMH help: scala3-bench/jmh:run -h")
println("Our default JMH options: -wi 30 -i 20 -f 3 -tu ms -bm AverageTime -jvmArgs \"-Xms2G -Xmx2G\"")

def main(args: Array[String]): Unit = {
if (args.isEmpty) {
println("Missing arguments.")
printUsage()
println("Missing <args>")
return
}
val (intArgs, args1) = args.span(x => try { x.toInt; true } catch { case _: Throwable => false } )

val (jmhArgs, _scalacArgs) = args.span(_ != "--")
val scalacArgs = _scalacArgs.drop(1)

storeCompileOptions(scalacArgs)

val jmhCliOps = new CommandLineOptions(jmhArgs:_*)
val jmhOps = new OptionsBuilder().parent(jmhCliOps)

// set our own default options
if !jmhCliOps.shouldFailOnError().hasValue() then jmhOps.shouldFailOnError(true)
if !jmhCliOps.getWarmupIterations().hasValue() then jmhOps.warmupIterations(30)
if !jmhCliOps.getMeasurementIterations().hasValue() then jmhOps.measurementIterations(20)
if !jmhCliOps.getForkCount().hasValue() then jmhOps.forks(1)
if jmhCliOps.getBenchModes().isEmpty() then jmhOps.mode(Mode.AverageTime)
if !jmhCliOps.getTimeUnit().hasValue() then jmhOps.timeUnit(TimeUnit.MILLISECONDS)
if !jmhCliOps.getJvmArgs().hasValue() then jmhOps.jvmArgs("-Xms2G", "-Xmx2G")
val warmup = if (intArgs.length > 0) intArgs(0).toInt else 30
val iterations = if (intArgs.length > 1) intArgs(1).toInt else 20
val forks = if (intArgs.length > 2) intArgs(2).toInt else 1

val runner = new Runner(jmhOps.build())

if jmhCliOps.shouldHelp() then
printUsage()
println("Following is the JMH options documentation.")
println("-------------------------------------------")
return jmhCliOps.showHelp()
if jmhCliOps.shouldList() then return runner.list()
if jmhCliOps.shouldListWithParams() then return runner.listWithParams(jmhCliOps)
if jmhCliOps.shouldListProfilers() then return jmhCliOps.listProfilers()
if jmhCliOps.shouldListResultFormats() then return jmhCliOps.listResultFormats()
import File.{ separator => sep }

val args2 = args1.map { arg =>
if ((arg.endsWith(".scala") || arg.endsWith(".java")) && !(new File(arg)).isAbsolute) ".." + sep + arg
else arg
}
storeCompileOptions(args2)

val opts = new OptionsBuilder()
.shouldFailOnError(true)
.jvmArgs("-Xms2G", "-Xmx2G")
.mode(Mode.AverageTime)
.timeUnit(TimeUnit.MILLISECONDS)
.warmupIterations(warmup)
.measurementIterations(iterations)
.forks(forks)
.build

val runner = new Runner(opts) // full access to all JMH features, you can also provide a custom output Format here
runner.run() // actually run the benchmarks

removeCompileOptions
Expand All @@ -71,17 +61,13 @@ object Bench {
def removeCompileOptions: Unit = new File(COMPILE_OPTS_FILE).delete()

def storeCompileOptions(args: Array[String]): Unit = {
import File.{ separator => sep }

val standard_libs = System.getProperty("BENCH_CLASS_PATH")
val compiler_libs = System.getProperty("BENCH_COMPILER_CLASS_PATH")

val libs = if (args.contains("-with-compiler")) compiler_libs else standard_libs
var argsNorm = args.filter(_ != "-with-compiler").map { arg =>
if ((arg.endsWith(".scala") || arg.endsWith(".java")) && !(new File(arg)).isAbsolute) ".." + sep + arg
else arg
}
var argsNorm = args.filter(_ != "-with-compiler")

import File.{ pathSeparator => sep }
var cpIndex = argsNorm.indexOf("-classpath")
if (cpIndex == -1) cpIndex = argsNorm.indexOf("-cp")
if (cpIndex != -1) argsNorm(cpIndex + 1) = argsNorm(cpIndex + 1) + sep + libs
Expand Down
6 changes: 3 additions & 3 deletions project/scripts/bootstrapCmdTests
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ set -e
source $(dirname $0)/cmdTestsCommon.inc.sh

# check that benchmarks can run
"$SBT" "scala3-bench/jmh:run -wi 1 -i 1 -- tests/pos/alias.scala"
"$SBT" "scala3-bench/jmh:run 1 1 tests/pos/alias.scala"
# The above is here as it relies on the bootstrapped library.
"$SBT" "scala3-bench-bootstrapped/jmh:run -wi 1 -i 1 -- tests/pos/alias.scala"
"$SBT" "scala3-bench-bootstrapped/jmh:run -wi 1 -i 1 -- -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala"
"$SBT" "scala3-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala"
"$SBT" "scala3-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala"

echo "testing scala.quoted.Expr.run from sbt scala"
"$SBT" ";scala3-compiler-bootstrapped/scalac -with-compiler tests/run-staging/quote-run.scala; scala3-compiler-bootstrapped/scala -with-compiler Test" > "$tmp"
Expand Down