diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-04-23 22:20:36 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-04-23 23:06:56 +1000 |
commit | 8559e39c8dc2a597a210ebf9b4ee7ea2247e2d62 (patch) | |
tree | 61688f1ed6e14e2215b905a9060800259972ab22 /src | |
parent | d063dd32098f1dacdb13fb6bd750a75a444dcacd (diff) | |
download | scala-8559e39c8dc2a597a210ebf9b4ee7ea2247e2d62.tar.gz scala-8559e39c8dc2a597a210ebf9b4ee7ea2247e2d62.tar.bz2 scala-8559e39c8dc2a597a210ebf9b4ee7ea2247e2d62.zip |
SI-9279 Improve performance of bash runner script
In fbe897d16, the template for bash scripts (scala/scalac/etc) was
modified to fix processing of `-J`, `-bootcp`.
This involved looping through the argument array and filtering out
options like `-bootcp` that only influence the script, and shouldn't
be passed to the JVM.
However, the mechanism to do this uses an inefficient, erm,
"CanBuildFrom", and under the load of even a few hundred source
files takes half a second before the JVM starts. Throw 2000 files
at it, and you have to wait ten seconds!
This commit uses a more efficient array append operator. This requires
Bash 3 or above. Hopefully it is safe to presume this version these
days, it's been around for a decade.
Results:
```
% time ~/scala/2.11.6/bin/scalac -J-NOJVM abcdedfghijklmnopqrtsuvwxyv{1..2000} 2>&1
Unrecognized option: -NOJVM
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
real 0m7.765s
user 0m7.734s
sys 0m0.028s
% time ./build/quick/bin/scalac -J-NOJVM abcdedfghijklmnopqrtsuvwxyv{1..2000} 2>&1
Unrecognized option: -NOJVM
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
real 0m0.144s
user 0m0.124s
sys 0m0.022s
```
Thanks to Stephan Schmidt for pointing out the performance gulf.
Diffstat (limited to 'src')
-rwxr-xr-x | src/compiler/scala/tools/ant/templates/tool-unix.tmpl | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl index 9862ea7987..6e91a2a202 100755 --- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl @@ -137,8 +137,8 @@ while [[ $# -gt 0 ]]; do -D*) # pass to scala as well: otherwise we lose it sometimes when we # need it, e.g. communicating with a server compiler. - java_args=("${java_args[@@]}" "$1") - scala_args=("${scala_args[@@]}" "$1") + java_args+=("$1") + scala_args+=("$1") # respect user-supplied -Dscala.usejavacp case "$1" in -Dscala.usejavacp*) OVERRIDE_USEJAVACP="";; esac shift @@ -146,8 +146,8 @@ while [[ $# -gt 0 ]]; do -J*) # as with -D, pass to scala even though it will almost # never be used. - java_args=("${java_args[@@]}" "${1:2}") - scala_args=("${scala_args[@@]}" "$1") + java_args+=("${1:2}") + scala_args+=("$1") shift ;; -toolcp) @@ -167,7 +167,7 @@ while [[ $# -gt 0 ]]; do shift ;; *) - scala_args=("${scala_args[@@]}" "$1") + scala_args+=("$1") shift ;; esac |