3 ms·
Java has had Class Data Sharing (CDS) since jdk1.5, an archive of "standard libraries" shared between all instances. It can be rebuilt with additional libraries
by rektide 13y ago
Java has had Class Data Sharing (CDS) since jdk1.5, an archive of "standard libraries" shared between all instances. It can be rebuilt with additional libraries, speeding their load and reducing their footprint.
Links to notes on this, https://plus.google.com/113218107235105855584/posts/K9seVudjaiU https://plus.google.com/113218107235105855584/posts/K9seVudj... . Stack overflow q, http://stackoverflow.com/questions/4692076/speed-up-application-start-by-adding-own-application-classes-to-classes-jsa http://stackoverflow.com/questions/4692076/speed-up-applicat...
CDS is fantastically un-isolated and using it is going to be systemwide. You're still running many many java copies, and that is fat in size, ugly and busted in form. Containers like Tomcat exist to solve a near-like problem of being a many-application serving system. This virtualized virtual machine is definitely the first runtime that's oriented to multi-tenant, but if you look around, you can find some it's technical roots here and there.
- modsrm 13y agoNot sure it is the first one: http://www.waratek.com/product/cloudvm http://www.waratek.com/product/cloudvm
- eliasmacpherson 13y agoI came across CDS before when trying to get desktop java applications to start up faster. I also had hoped it would allow e.g. a constantly running fat server to run eclipse for multiple users more efficiently than each desktop duplicating work. http://lukas.zapletalovi.com/2012/11/want-faster-java-startups-in-fedora.html http://lukas.zapletalovi.com/2012/11/want-faster-java-startu... I had thought CDS was just for Sun and IBM implementations, but from the above I can infer it works on OpenJDK too. When you say, 'running many many java copies', do you mean java.exe?
- 6ren 13y agoFantastic for sharing, though the startup time improvement is minor (e.g. I saw 17% improvement). BTW: that SO comment references a pdf that shows how to include your own classes, on pages 61-62 http://www.oracle.com/technetwork/jp/ondemand/java/20110519-java-a-1-greg-400531-ja.pdf; http://www.oracle.com/technetwork/jp/ondemand/java/20110519-... tools link: http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/tip/make/tools/src/build/tools http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/tip/make/tools... IBM's multi-tenancy gives 3.3 speedup, for HelloWorld - worse for others (maybe if they combined it with CDS?) BTW: The only way to get instant Java startup is not to startup - use an already running JVM, with the classes already loaded. It's fast. Just leave it in the background til you need it - it's effectively a server. Especially good to invoke javac this way, for lightening compiles (if like me you don't use an IDE).
- greyboy 13y agoInteresting about keeping a JVM running for compilation. I'm curious about doing just this for my day job but can't seem to find a good explanation. Do you have any resources to point me to?
- 6ren 13y agojavac is itself written in java, so you can write a little program that does that in a loop, waiting for some trigger. I actually just had it in a shell, waiting for you to hit return, which also called my code after compilation. An unexpected benefit (unexpected to me, anyway) was that not only do you avoid the startup penalty, but you also benefit from JIT compilation of javac itself - every time it compiles, it gets faster! IIRC it's fairly substantial the first 10 times, but still improving at 50. Here's a working minimal starting point I just put together for you (check docs, google, stackoverflow etc): import javax.tools.*; import java.io.*; class Demo { public static void main(String args[]) throws IOException { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); int result = compiler.run(null, System.out, System.out, args); } } java Demo Foo.java # compiles Foo.java Here's a stackoverflow answer suggesting something similar http://stackoverflow.com/a/793913/50979 http://stackoverflow.com/a/793913/50979 BTW: I called out to a bash script to work out which source files had changed, because it's easier than writing that bit in java (and this compiler doesn't do that for you - it just compiles the explicitly listed source files). HTH - let me know if you need more info. I've been thinking of using Jnotify to watch for source files being written to, so it's 100% automatic - one issue is that I save quite often, and each will trigger a compile (I'm doing this with plain javac and inotify at the moment).
- jared314 13y agoFor a persistent JVM, take a look at Nailgun [1]. Additionally, the Drip project [2] uses a swapping strategy, by keeping an additional JVM spun up in the background. It was apparently built because the authors had trouble with persistent JVMs containing old dependencies. [1] http://www.martiansoftware.com/nailgun/ http://www.martiansoftware.com/nailgun/ [2] https://github.com/flatland/drip https://github.com/flatland/drip
- 13y ago
- trailfox 13y agoDidn't Sun have an experimental MVM about 10 years ago?