
Multi-tenant Java 8 VM in beta - SanderMak
http://www.ibm.com/developerworks/java/library/j-multitenant-java/index.html
======
rektide
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/K9seVudj...](https://plus.google.com/113218107235105855584/posts/K9seVudjaiU)
. Stack overflow q, [http://stackoverflow.com/questions/4692076/speed-up-
applicat...](http://stackoverflow.com/questions/4692076/speed-up-application-
start-by-adding-own-application-classes-to-classes-jsa)

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.

~~~
6ren
Fantastic 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-...](http://www.oracle.com/technetwork/jp/ondemand/java/20110519-java-a-1-greg-400531-ja.pdf;)
tools link:
[http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/tip/make/tools...](http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/tip/make/tools/src/build/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
Interesting 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?

~~~
jared314
For 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)

------
polskibus
Does anyone know if .NET runtime is multitenant? Would be great to know about
the alternatives (and their future plans).

~~~
rektide
I believe in Mono if one does Ahead-of-Time compilation the bytecode is just
mem mapped in and can be shared between runtimes, giving you much of the
advantage of this work.

~~~
pjmlp
There is no bytecode any longer when you do AOT, just plain pure native code.

------
mhaymo
> The main cost of using the multitenant JVM is that tenants are less isolated
> than multiple applications that run in separate JVMs. For example, a native
> crash in the multitenant JVM affects all tenants.

Does anyone know what exactly is meant by a "native crash"?

~~~
njs12345
For example, if a bug in the JVM or an external library causes a dereference
of a (C/C++) null pointer.

------
ramblerman
One permgen to kill them all

~~~
axelf
I think java 8 gets rid of permgen

~~~
chii
only to replace it with off heap memory iirc. Not sure what the benefit was
tbh.

------
raverbashing
Question: I had the impression that when you had several threads on a Java app
this would result in several VMs, is this currently so, was so or it's my
mistake and it was never like that?

~~~
SanderMak
It was never like that. Threads have their own stack, but that's about it.
They can access anything anywhere. Hence the current focus on concurrency
using immutable message passing mechanisms on the JVM (actors etc.)

~~~
raverbashing
Or, to be more specific, what are the differences between thread handling
under Linux and Windows regarding to the JVM?

Threads in Linux (in general) are separate process that share memory space, in
Windows it's different and they're "threads" being scheduled under a parent
process.

~~~
teraflop
What's the difference? In both cases, threads have their own stacks but share
the rest of their address space. Is there a distinction other than
terminology?

~~~
raverbashing
Ah apparently not so much [http://stackoverflow.com/questions/3237701/do-
threads-create...](http://stackoverflow.com/questions/3237701/do-threads-
created-in-java-behave-differently-on-windows-and-linux)

But I would say you would have definitely to watch for a) thread creation time
and b) thread priorities (but for most of the applications these are not a
problem)

