I'm working on improving performance of Kotlin scr...
# scripting
p
I'm working on improving performance of Kotlin scripts on GitHub Actions. Even such simple script
Copy code
#!/usr/bin/env kotlin
println("Hello from Kotlin!")
(see here) took 13 seconds. I tried running the script through
kotlinc
instead of the shebang, and passing
-verbose
, but I didn't notice anything interesting. Could you hint me how I can learn what takes so much time? Is it compilation, or something else? I'm also going to create a ticket on the Kotlin side, IMO worth addressing for the sake of making Kotlin scripting a viable alternative to e.g. Python.
my concrete use case is https://github.com/typesafegithub/github-workflows-kt - the library, when generates a YAML from a Kotlin script, calls the script to ensure that it's in sync with the resulting YAML. This is called a consistency check job (ref). It effectively adds an overhead of 10-20 s for each job that the user runs, and since the jobs can be very quick, the consistency check can sometimes dominate the running time.
e
As for now kotlin script runs on top of jvm. So start of jvm adds the time to run it. In addition if your script uses some dependency and they are not cached - they will be redownloaded every time.
v
Also the script compilation result is not cached. (Which can be good as it otherwise would trigger one of the issues we reported when using import)
p
@Eugen Martynov JVM warmup time is probably within 1 s. My first example shows a script with no deps. Still it takes 13 s. Regarding compilation result caching, as Björn mentioned, it's broken so I don't want to rely on it.
I'm wondering how we could measure these things, without adding extra logging to the Kotlin script engine