From 75257e759b455552c3007df1ec13c351ff1db2f5 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 19 Oct 2020 15:13:23 -0400 Subject: [PATCH] Fix sbt --client slowness Before: ``` $ time sbt --client exit [info] entering *experimental* thin client - BEEP WHIRR [info] terminate the server with `shutdown` sbt --client exit 0.16s user 0.15s system 101% cpu 0.303 total ``` sbt --client was running around 303ms (median out of 5) on my machine. ``` $ time sbtn exit [info] entering *experimental* thin client - BEEP WHIRR [info] terminate the server with `shutdown` sbtn exit 0.05s user 0.05s system 112% cpu 0.085 total ``` On the other hand, sbtn ran in 85ms (median out of 5). After: ``` $ time ~/work/sbt-modules/sbt-launcher-package/target/universal/stage/bin/sbt --client exit [info] entering *experimental* thin client - BEEP WHIRR [info] terminate the server with `shutdown` ~/work/sbt-modules/sbt-launcher-package/target/universal/stage/bin/sbt exit 0.06s user 0.08s system 111% cpu 0.127 total ``` By delaying the java version detection, I got it down to 127ms. --- src/universal/bin/sbt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 1a046a9d6..a2ded2146 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -563,9 +563,6 @@ process_args () { residual_args=() process_my_args "${myargs[@]}" } - - java_version="$(jdk_version)" - vlog "[process_args] java_version = '$java_version'" } loadConfigFile() { @@ -671,7 +668,14 @@ set -- "${residual_args[@]}" argumentCount=$# if [[ "$(isRunNativeClient)" == "true" ]]; then + set -- "${residual_args[@]}" + argumentCount=$# runNativeClient else + java_version="$(jdk_version)" + vlog "[process_args] java_version = '$java_version'" + addDefaultMemory + set -- "${residual_args[@]}" + argumentCount=$# run fi