Open dundalek opened 5 years ago
Another wild idea (similar to planck), generate a binary via GraalVM that can 1) evaluate ClojureScript by evaluating it in self-hosted Clojurescript in Graal's ScriptEngineManager 2) and precompile it with self-hosted clojurescript + closh.
Part 1) works and gives fast boot times (30ms) for a small javascript file. Step 2) doesn't work [1] . Without precompiling it and evalling ClojureScript during runtime this is slower than starting a JVM.
[1] because of this I think https://github.com/oracle/graal/issues/631 [2] https://gist.github.com/jeroenvandijk/dacb9867d61fe0abc320429be5b4fe0f
That is a really interesting idea. I don't understand too much details of step 2) but at the end of [1] it seems they have a working solution? What is the issue with running a self-hosted clojurescript in GraalJS?
Sorry I wasn't clear.
1) Yes, so we can have a stand alone js engine of around 74mb. This thing can run any javascript file (I assume). The full example is here https://github.com/jeroenvandijk/clojure-scripting/blob/self-hosting/self-hosted1/src/clojure/scripting/client.clj
2) having a standalone js engine alone isn't good enough if we are interested in fast clojure(script) boottime. We have to load a js engine with clojurescript in it. a) I've tested with slurping and evalling the 7.4mb self hosted clojurescript, but that by itself takes more than a second (obviously?). b) The other option i could think of is that GraalVM compiles the javascript clojurescript context in advance and makes this context available during runtime (somehow). I didn't get this to work. Also serializing (java.io.Serializable) of the context isn't supported atm. This test is here https://github.com/jeroenvandijk/clojure-scripting/blob/self-hosting/self-hosted2/src/clojure/scripting/client.clj
3) The option I didn't explore is the use of the NPM and NodeJS compatible GraalJS. This would be similar to Lumo and it's pros/cons i suppose. This could be a feasible option too if it gives you tools for packaging.
Not a priority now that sci with graalvm port is coming, but it might be possible to use class data sharing to improve startup time.
https://ask.clojure.org/index.php/8353/can-we-use-appcds-to-speed-up-app-start https://blog.codefx.org/java/application-class-data-sharing/
Explore ways to lower down the startup time.
Follow boot and see what they come up with: https://github.com/boot-clj/boot/issues/106
Alternatives: