Skip to content

Add option to optimize the JVM for short-runnning applications #234

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 1 commit into from
Nov 17, 2014

Conversation

smarter
Copy link
Member

@smarter smarter commented Nov 17, 2014

Ideally, dotc should reuse a resident compiler and we should not fork sbt
for every task. Until this happens, this option is useful for
development. Fixes #222.

Usage:
$ sbt -DOshort=""
$ ./bin/dotc -Oshort foo.scala

Review by @DarkDimius @odersky @namin .

Ideally, dotc should reuse a resident compiler and we should not fork sbt
for every task. Until this happens, this option is useful for
development. Fixes scala#222.

Usage:
$ sbt -DOshort=""
$ ./bin/dotc -Oshort foo.scala
@DarkDimius
Copy link
Contributor

LGTM.
FYI: we are forking JVM just to use a different classpath. Dotty inherited classpath managing from scalac and the later requires to be able to find itself on the bootclasspath. I don't see reason for this to be required and I guess this is just an implementation detail. If you are interested on speeding up test suite even more you could try to find how to fix dotty so that it could run on normal classpath.

DarkDimius added a commit that referenced this pull request Nov 17, 2014
Add option to optimize the JVM for short-runnning applications
@DarkDimius DarkDimius merged commit 2cc2c86 into scala:master Nov 17, 2014
@retronym
Copy link
Member

See retronym/dotty@7d91b5d for code that extracts the paths of the JARs that SBT has added to the classpath of the test run, using a secret handshake.

@retronym
Copy link
Member

I notice a bug in that code, I forgot a call to getLines.

 ~/code/dotty sbt console
[info] Loading global plugins from /Users/jason/.sbt/0.13/plugins
[info] Loading project definition from /Users/jason/code/dotty/project
[info] Set current project to dotty (in build file:/Users/jason/code/dotty/)
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.11.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_25).
Type in expressions to have them evaluated.
Type :help for more information.

scala> Option(classOf[dotty.tools.dotc.config.PathResolver].getClassLoader.getResource("app.class.path")).map(cp => scala.io.Source.fromURL(cp).getLines.mkString(java.io.File.pathSeparator))
res1: Option[String] = Some(/Users/jason/code/dotty/target/scala-2.11/classes:/Users/jason/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.1.jar:/Users/jason/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.11.1.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-xml_2.11/bundles/scala-xml_2.11-1.0.1.jar:/Users/jason/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.1.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-xml_2.11/bundles/scala-xml_2.11-1.0.2.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-parser-combinators_2.11/bundles/scala-parser-combinators_2.11-1.0.1.jar:/Users/jason/.ivy2/cache/jline/jline/jars/jline-2.11.jar)

scala> Option(classOf[dotty.tools.dotc.config.PathResolver].getClassLoader.getResource("boot.class.path")).map(cp => scala.io.Source.fromURL(cp).getLines.mkString(java.io.File.pathSeparator))
res2: Option[String] = Some(/Users/jason/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.1.jar:/Users/jason/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.1.jar:/Users/jason/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.11.1.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-xml_2.11/bundles/scala-xml_2.11-1.0.2.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-parser-combinators_2.11/bundles/scala-parser-combinators_2.11-1.0.1.jar:/Users/jason/.ivy2/cache/jline/jline/jars/jline-2.11.jar)

@smarter
Copy link
Member Author

smarter commented Nov 18, 2014

retronym/dotty@7d91b5d returns an error 404, I think you meant retronym@7d91b5d

@retronym
Copy link
Member

Oops, that repo was private. I've just made it public.

WojciechMazur pushed a commit to WojciechMazur/dotty that referenced this pull request May 8, 2025
Backport "Backport from Metals" to 3.3 LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider using -XX:TieredStopAtLevel=1 to make the compiler faster
3 participants