Is there any support for sbt 1.x ?

82 views
Skip to first unread message

raffaell...@gmail.com

unread,
May 6, 2019, 8:23:01 PM5/6/19
to ScalaMeter
Hi,

I tried to use Scalameter with SBT 1.2 and i have unexpected behavior running with a bench:test as reported in the example.

The error reported was: "unable to create a system terminal". 
Furthermore the computation is hanging on forever.... it should not last more than few seconds.

Is it something that i misconfigured? 

Looking at the source code, the examples are failing to pass CI and even the sbt version used is still 0.13.

Does Scalameter support SBT 1.x  and Scala 2.12.8  [and JVM 11]?



thanks

Aleksandar Prokopec

unread,
May 7, 2019, 7:58:18 AM5/7/19
to ScalaMeter
Hi,

Did you try the instructions for SBT from:


fork := true

outputStrategy := Some(StdoutOutput)

connectInput := true

This should enable the use of JLine when forking programs from SBT.

Thanks,
Alex


Raffaello Bertini

unread,
May 13, 2019, 5:35:49 PM5/13/19
to ScalaMeter
yes. 
I tried:
build.properties: sbt.version 1.2.7

benchmark test (like the example basic):
package benchmark

import org.scalameter.api._

object Array2dClone extends Bench.LocalTime {
val ranges = for {
size <- sizes
} yield 0 until size

performance of "Range" in {
measure method "map" in {
using(ranges) in {
r => r.map(_ + 1)
}
}
}
}


build.sbt
basic version in test folder: 
name := "tic-tac-toe"
version := "0.1"
scalaVersion := "2.12.8"

libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.5"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test"
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.14.0" % "test"
libraryDependencies += "com.typesafe" % "config" % "1.3.2"

// ---- scalameter
// see: https://github.com/scalameter/scalameter-examples/blob/master/basic-with-separate-config/build.sbt
resolvers ++= Seq(
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
"Sonatype OSS Releases" at "https://oss.sonatype.org/content/repositories/releases"
)

libraryDependencies += "com.storm-enroute" %% "scalameter" % "0.17"
testFrameworks += new TestFramework("org.scalameter.ScalaMeterFramework")
parallelExecution in Test := false
logBuffered := false
fork := true
outputStrategy := Some(StdoutOutput)
connectInput := true
// --- end - scalameter

OUTPUT:
Unable to create a system terminal
[error] Uncaught exception when running benchmark.Array2dClone: java.lang.RuntimeException: Cannot recognize classloader (not URLClassLoader): jdk.internal.loader.ClassLoaders$AppClassLoader@6e5e91e4
[error] sbt.ForkMain$ForkError: java.lang.RuntimeException: Cannot recognize classloader (not URLClassLoader): jdk.internal.loader.ClassLoaders$AppClassLoader@6e5e91e4
[error]         at scala.sys.package$.error(package.scala:30)
[error]         at org.scalameter.ScalaMeterFramework$$anon$1.$anonfun$computeClasspath$1(ScalaMeterFramework.scala:56)
[error]         at org.scalameter.utils.ClassPath$.extract(ClassPath.scala:77)
[error]         at org.scalameter.ScalaMeterFramework$$anon$1.computeClasspath(ScalaMeterFramework.scala:55)
[error]         at org.scalameter.ScalaMeterFramework$$anon$1.run(ScalaMeterFramework.scala:73)
[error]         at sbt.RunnerWrapper$1.runRunner2(FrameworkWrapper.java:230)
[error]         at sbt.RunnerWrapper$1.execute(FrameworkWrapper.java:243)
[error]         at sbt.ForkMain$Run.lambda$runTest$1(ForkMain.java:304)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error]         at java.base/java.lang.Thread.run(Thread.java:834)

---------------------------------------------------------------------------------------------------
with advanced sbt 1.x configuration:

lazy val Benchmark = config("bench") extend Test
lazy val root = (project in file("."))
.configs(Benchmark)
.settings(
inConfig(Benchmark)(Defaults.testSettings): _*
)

scalaVersion := "2.12.8"
scalacOptions += "-Ypartial-unification"
scalacOptions += "-Xdisable-assertions"
javacOptions += "--illegal-access=warn"

libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.5"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test"
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.14.0" % "test"
libraryDependencies += "com.typesafe" % "config" % "1.3.2"

// ---- scalameter
// see: https://github.com/scalameter/scalameter-examples/blob/master/basic-with-separate-config/build.sbt
resolvers ++= Seq(
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
"Sonatype OSS Releases" at "https://oss.sonatype.org/content/repositories/releases"
)

libraryDependencies += "com.storm-enroute" %% "scalameter" % "0.17" % "bench"
libraryDependencies += "com.storm-enroute" %% "scalameter-core" % "0.17" % "bench"
testFrameworks += new TestFramework("org.scalameter.ScalaMeterFramework")
parallelExecution in Benchmark := false
logBuffered := false
fork := true
outputStrategy := Some(StdoutOutput)
connectInput := true
// --- end - scalameter

OUTPUT (the same):

Unable to create a system terminal
[error] Uncaught exception when running benchmark.Array2dClone: java.lang.RuntimeException: Cannot recognize classloader (not URLClassLoader): jdk.internal.loader.ClassLoaders$AppClassLoader@6e5e91e4
[error] sbt.ForkMain$ForkError: java.lang.RuntimeException: Cannot recognize classloader (not URLClassLoader): jdk.internal.loader.ClassLoaders$AppClassLoader@6e5e91e4
[error]         at scala.sys.package$.error(package.scala:30)
[error]         at org.scalameter.ScalaMeterFramework$$anon$1.$anonfun$computeClasspath$1(ScalaMeterFramework.scala:56)
[error]         at org.scalameter.utils.ClassPath$.extract(ClassPath.scala:77)
[error]         at org.scalameter.ScalaMeterFramework$$anon$1.computeClasspath(ScalaMeterFramework.scala:55)
[error]         at org.scalameter.ScalaMeterFramework$$anon$1.run(ScalaMeterFramework.scala:73)
[error]         at sbt.RunnerWrapper$1.runRunner2(FrameworkWrapper.java:230)
[error]         at sbt.RunnerWrapper$1.execute(FrameworkWrapper.java:243)
[error]         at sbt.ForkMain$Run.lambda$runTest$1(ForkMain.java:304)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error]         at java.base/java.lang.Thread.run(Thread.java:834)

----
I have JDK 11, and i think it is an incompatibility probably due to the JVM HotSpot machine mainly:
https://community.oracle.com/thread/4011800 


----

Basically is failing in the extract method of scalameter in utils.ClassPath.scala file i guess.

----
i have done a small test with jdk8 and here the output of "bench:test" configuration:

[info] Done compiling.
Unable to create a system terminal
[info] ::Benchmark Range.map::
[info] cores: ***
[info] hostname: ******
[info] name: Java HotSpot(TM) 64-Bit Server VM
[info] osArch: amd64
[info] osName: Windows 10
[info] vendor: Oracle Corporation
[info] version: 25.211-b12
[info] Parameters(size -> 300000): 2.487 ms
[info] Parameters(size -> 600000): 4.9878 ms
[info] Parameters(size -> 900000): 7.4423 ms
[info] Parameters(size -> 1200000): 9.925 ms
[info] Parameters(size -> 1500000): 12.4131 ms
[info] ScalaTest
[info] Run completed in 4 seconds, 921 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[success] Total time: 7 s, completed May 11, 2019 4:30:51 PM

---

So i guess mainly is JDK11, but still i have that Unable to create a system terminal error.

Fyodor Fedorowicz

unread,
May 13, 2019, 8:33:27 PM5/13/19
to ScalaMeter
It seems that JLine is unable to create its terminal on your machine for some reason.
I think that ScalaMeter should just work fine without it, although there will be this error message.

Some information about getting rid of the message here:


Regarding the classloader-related exception, that seems to be a problem with running ScalaMeter on JDK 11. ScalaMeter was not tested on JDK 11 (Travis build runs on JDK 8), and perhaps we should start doing that.

Regards,
Fyodor
Reply all
Reply to author
Forward
0 new messages