Fast JVM launching without the hassle of persistent JVMs
github.com
github.com
I wonder how many other "obvious" solutions I'm missing like this?
EDIT for the code I tried, user time is almost 3 times faster, but real time is only around 10% better... I don't understand linux well enough to know why - anyone care to explain please? EDIT Yes, drip had already run. (I picked typical times from about 10 runs each).
$ time java...
real 0m1.466s
user 0m1.216s
sys 0m0.180s
$ time drip...
real 0m1.378s
user 0m0.412s
sys 0m0.260s
BTW: For server-like workloads, an advantage of a persistent JVM is that it gets dramatically faster over repeated runs of the same code, as it improves its hotspot-style adaptive optimisations.I really like his quickstart "standalone" installation.
WARNING "drip kill" crashed my system. The kill functions are kill_jvms and kill_jvm (https://github.com/flatland/drip/blob/develop/bin/drip). I'm using an older ubuntu 10.04 LTS.
$ time java -jar clojure-1.3.0.jar add_1_and_1.clj
real 0m0.690s
user 0m0.827s
sys 0m0.030s
$ time drip -jar clojure-1.3.0.jar add_1_and_1.clj
real 0m0.879s
user 0m1.020s
sys 0m0.040s
$ time drip -jar clojure-1.3.0.jar add_1_and_1.clj
real 0m0.177s
user 0m0.033s
sys 0m0.020s
$ time drip -jar clojure-1.3.0.jar add_1_and_1.clj
real 0m0.176s
user 0m0.050s
sys 0m0.017s- Working on multiple projects who need different JVMs running at the same time can be a hassle in clove (you have to create a service for each), so it can be fixed by doing that the same way drip does.
- Running scripts and having a persistent JVM is still very useful, and clove (albeit I haven't cleaned up its code properly) gives a terminal into the JVM, really fast. So, drip can use the same technique (passing capabilities; a *nix feature) to let you hook into a JVM very quickly. [see the "screenshot" part at the bottom of http://hovel.ca/clove]
You'd just need to convert all your .jars and that's it. I haven't heard of any other incompatibilities with standard Java.
Edit: Is there a port of Dalvik to amd64? A cursory search did not find one.
Ah, good to know. I've mostly just had to bring in things like a database library, and in one case LuaJ. None of those did need to do bytecode generation.
Also it's really hard to express how much slower Dalvik is than HotSpot in the general case, too. It seems faster with the Android 4.2 version (by about 30%, in my highly unofficial testing) but it's still pretty agonizingly slow.
time java -jar /home/user/research/jruby-complete-1.6.0.RC3.jar --1.9 -e 'a=1;puts a' 1 java -jar /home/user/research/jruby-complete-1.6.0.RC3.jar --1.9 -e 3.65s user 0.12s system 183% cpu 2.056 total
Interesting!! if it runs rails effectively, this could be awesome for jruby.
I recently moved one of my project to jruby and the startup time is the only thing I'm complaining about.
I prefer swank over nailgun, even with Vim.
So I assume it doesn't help if you are launching JVMs very rapidly (like, scripting stuff in a tight loop). Slow JVM launching has pretty much killed languages such as Groovy for scripting for me, because once I start using them in loops things get horribly slow.
It's not like the stuff inside the script can't be standalone classes of the "do one thing and do it well" variety --they just don't get to be processes.
$ JAVA_CMD=drip lein ... export JAVA_CMD=drip
into your ~/.profile (etc) file to have it affect all future Java launches from leiningen.https://github.com/flatland/drip/issues/36
Here's my workaround to use drip to start up lein repls instantly:
https://gist.github.com/4103370
Should work with lein1 & lein2.
Does anyone know what kind of errors the author is referring to? Does any long running JVM instance run into these issues?
EDIT: Hmm, I encountered this: "Could not connect to compilation daemon after 300 attempts." but re-running it ("scala") works.
I meant AOT to native code.
Although OpenJDK/Oracle JVM don't offer this option, other vendors do.