enso-org / enso

Hybrid visual and textual functional programming.
https://ensoanalytics.com
Apache License 2.0
7.36k stars 323 forks source link

Investigate Instant Startup of the Engine #5464

Open wdanilo opened 1 year ago

wdanilo commented 1 year ago

This task is automatically imported from the old Task Issue Board and it was originally created by jaroslavtulach. Original issue is here.


Why

As Enso User I want the engine start and work fast So that opening a project doesn't take five seconds or more

Acceptance Criteria

Scenario: 
Given newly created project
When it is opened
Then the engine shall work immediatelly without typical _java-like_ warm up.

Notes:

GraalVM offers AOT - native image - compilation which is the recommended way for Truffle languages to offer almost instant startup and better user experience.

Tasks:

Blockers:

#183260380 resolved #183136313 resolved #183374932 resolved #183802194 resolved #184256209 blocked

Comments:

@hubertplociniczak , if you can take a look at `build.sbt` and modify it to create a new task to invoke native image with proper engine (probably `runtime.jar` and `runner.jar`) class path, that'd be great. Compilation may fail, but it'll be easier for me to take over when we have the `sbt` task. (jaroslavtulach - Aug 5, 2022)

I tried to use Hubert's sbt changes, but the NI compilation was crashing. As such I had to create something simpler. Branch SimpleLauncher shows the instant startup benefits of using Native Image for compilation & execution. Follow the readme and you will see that executing simple helloworld takes 40ms:

time ./target/simplelauncher fac.enso 
3628800

real    0m0,038s
user    0m0,021s
sys     0m0,017s

which is hundred times faster than traditional 4s needed to boot the Enso engine in JVM mode. (jaroslavtulach - Aug 19, 2022)


With the help and guidance of Chris Seaton I managed to compile the launcher with sbt engine-runner/buildNativeImage when I gave the process enough memory (22GB was enough). E.g. the next milestone has been reached. Next goal: make the sbt engine-runner/buildNativeImage goal part of the CI run to verify all the necessary @TruffleBoundary annotations are in place. (jaroslavtulach - Aug 22, 2022)


Status summary as of Aug 23, 2022: https://docs.google.com/document/d/1yZmj4y-mOswTUHFzYkV7FM6Vh9P9LLXj-plAW3bVzbI + will be discussed at 15:00 CET (jaroslavtulach - Aug 23, 2022)


JaroslavTulach commented 1 year ago