# scripting

Piotr Krzemiński

11/11/2023, 9:15 AM
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
instead of the shebang, and passing
, 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 - 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.

Eugen Martynov

11/11/2023, 9:48 AM
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.


11/11/2023, 10:21 AM
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)

Piotr Krzemiński

11/11/2023, 11:05 AM
@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