Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Startup time #131

Open
dundalek opened this issue Apr 15, 2019 · 4 comments
Open

Startup time #131

dundalek opened this issue Apr 15, 2019 · 4 comments
Labels

Comments

@dundalek
Copy link
Owner

Explore ways to lower down the startup time.

Follow boot and see what they come up with: boot-clj/boot#106

Alternatives:

@dundalek dundalek added the jvm label Apr 15, 2019
@jeroenvandijk
Copy link
Contributor

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 oracle/graal#631
[2] https://gist.github.com/jeroenvandijk/dacb9867d61fe0abc320429be5b4fe0f

@dundalek
Copy link
Owner Author

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?

@jeroenvandijk
Copy link
Contributor

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.

@dundalek
Copy link
Owner Author

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants