Description
Problem description
scala-cli is a great enabler for writing python-like CLI apps. In some scenarios, where changes to the code are frequent enough, it is more convenient to rely on scala-cli run
and distribute the app as source code rather than distribute the app as a binary. It would be nice to have some sort of dedicated support for this use case.
Describe the solution you'd like
The bare minimum would be to have a documentation page describing best practices for optimizing scala-cli run
for startup time.
The things I have used so far:
- offline mode - so we don't do any network calls
-J -XX:TieredStopAtLevel=1
- so the JVM compiler doesn't do upfront optimisations
On top of that, I expect there are some further tweaks you can suggest?
Describe alternatives you've considered
- direct support for nailgun
Additional context
I've run a bit of very unscientific benchmarks using my app. Each run was repeated 20 times. I was running my app that doesn't do anything but had all my dependencies and did command parsing (so it's not really isolated). I was using the following command
scala-cli run --jvm myjvm myapp --power --offline -J myflag
And here are my results
* baseline (temurin:1.17.0.9) - ~2996 ms
* baseline (temurin:1.21.0.1) - ~3147 ms
* baseline (graalvm-java21:21.0.1) - ~3281 ms
* baseline (graalvm-java17:22.3.3) - ~2900 ms
* -Xshare:on (temurin:1.17.0.9) - ~2805 ms
* -XX:TieredStopAtLevel=1 (temurin:1.17.0.9) - ~2205 ms
* -XX:CICompilerCount=2 (temurin:1.17.0.9) - ~2623 ms
* -Xmx128m (temurin:1.17.0.9) - ~2642 ms
* all the 4 flags above (temurin:1.17.0.9) - ~2238 ms
* -XX:TieredStopAtLevel=1 -Xmx128m (temurin:1.17.0.9) - ~2244 ms
* CDS (-XX:AutoCreateSharedArchive) (temurin:1.21.0.1) - ~2511 ms
* CDS (-XX:AutoCreateSharedArchive) + -XX:TieredStopAtLevel=1 -Xmx128m (temurin:1.21.0.1) - ~2252 ms
* -XX:TieredStopAtLevel=1 (temurin:1.21.0.1) - ~2232 ms