From b73ea2fde3949bcd1366cc8778c007619b627481 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 13 Nov 2014 17:18:53 +0100 Subject: [PATCH] Add option to optimize the JVM for short-runnning applications 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 --- bin/dotc | 3 +++ project/Build.scala | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/dotc b/bin/dotc index cafd80f03363..72ac3141a6ad 100755 --- a/bin/dotc +++ b/bin/dotc @@ -185,6 +185,9 @@ case "$1" in -d|-debug) debug=true && shift ;; -q|-quiet) quiet=true && shift ;; + # Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222 + -Oshort) addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;; + -repl) main_class=$ReplMain && shift ;; -compile) main_class=$CompilerMain && shift ;; -run) main_class=$ReplMain && shift ;; diff --git a/project/Build.scala b/project/Build.scala index 33a09a4f7224..9e2633136642 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -68,7 +68,14 @@ object DottyBuild extends Build { else List() - agentOptions ::: travis_build ::: fullpath + val tuning = + if (sys.props.isDefinedAt("Oshort")) + // Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222 + List("-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1") + else + List() + + tuning ::: agentOptions ::: travis_build ::: fullpath } )