atom feed25 messages in com.googlegroups.jvm-languagesRe: Using NailGun to defeat JVM start...
FromSent OnAttachments
Charles Oliver NutterNov 6, 2007 7:41 pm 
Charles Oliver NutterNov 6, 2007 7:55 pm 
Daniel SpiewakNov 6, 2007 9:05 pm 
Charles Oliver NutterNov 6, 2007 9:41 pm 
Patrick WrightNov 7, 2007 12:14 am 
Charles Oliver NutterNov 7, 2007 6:47 am 
Neil BartlettNov 7, 2007 7:27 am 
Patrick WrightNov 7, 2007 7:36 am 
Patrick WrightNov 7, 2007 7:42 am 
Jochen TheodorouNov 7, 2007 7:56 am 
Jochen TheodorouNov 7, 2007 8:03 am 
Patrick WrightNov 7, 2007 8:13 am 
Jochen TheodorouNov 7, 2007 8:22 am 
Jochen TheodorouNov 7, 2007 8:23 am 
Thomas E EneboNov 7, 2007 8:35 am 
Patrick WrightNov 7, 2007 8:37 am 
Patrick WrightNov 7, 2007 8:42 am 
Szegedi AttilaNov 7, 2007 9:35 am 
John CowanNov 7, 2007 9:42 am 
Jochen TheodorouNov 7, 2007 10:07 am 
Jochen TheodorouNov 7, 2007 10:12 am 
John CowanNov 7, 2007 11:58 am 
Charles Oliver NutterNov 7, 2007 4:43 pm 
John CowanNov 8, 2007 11:31 am 
Brian GoetzNov 13, 2007 11:32 am 
Subject:Re: Using NailGun to defeat JVM startup woes
From:Brian Goetz (br.@briangoetz.com)
Date:Nov 13, 2007 11:32:21 am
List:com.googlegroups.jvm-languages

Its worth noting that this is very much how Azul's VM works -- they provide a JVM stub that does little more than act as a server that loads the class files off the file system and pipes them up to the real VM.

Charles Oliver Nutter wrote:

It's become increasingly frustrating that JVM startup is still so much slower than most command-line programs.

In the JRuby world, we've now managed to convincingly pass the C implementation of Ruby 1.8 in performance. But even on the fastest systems, our startup time is a good couple seconds. At its worst, it can be as high as ten seconds. Our users are very tired of waiting.

http://www.martiansoftware.com/nailgun/index.html

Nailgun is a project that appears to be mostly dead since 2005, but it basically provides a simple "JVM server" on one end and a native client on the other. You call ng like you'd call java, with a class and arguments it should be passed. And it sends that class and arguments across a socket to the ng server, where the class is started up and the streams are all piped back and forth. When the class terminates, the client terminates.

Here's a sample of JRuby startup time on OS X Java 6, first normal and then with ng:

normal:

~/NetBeansProjects/jruby $ time jruby -e "puts 'hello'" hello

real 0m1.944s user 0m1.511s sys 0m0.138s

nailgun:

~/NetBeansProjects/jruby $ time jruby -e "puts 'hello'" hello

real 0m0.103s user 0m0.006s sys 0m0.009s

Obviously it's a substantial improvement.

Now there are a few issues with Nailgun that I've seen so far:

- it doesn't pass along CWD, so if I switch to another directory the launched class on the remote server doesn't pick that up. Of course the JVM only has one CWD anyway, but in JRuby we have one per JRuby runtime...so we could implement our own wrapper around the Nailgun server that's aware of this. But we'd still need to tweak the native client to send it across. - you obviously can't pass JVM flags across the wire, since the JVM is already started up. This also applies to classpath...but JRuby will generally use a runtime-dynamic classpath anyway, so that issue is lessened. - I had some trouble with one Ruby app that uses a readline library; it didn't appear to pipe correctly. The client needs better term support, I would guess.

I'm debating trying to get Nailgun running again as a project, so these issues can be resolved. In the absence of some other miracle, there's not going to be a better way to get native-like startup times for those of us implementing languages used heavily for small command-line utilities. Nailgun seems like a 75% solution that could become something pretty nice with a little work.

Thoughts on this? Other suggestions for defeating startup woes?

To try it out in JRuby:

1. check out JRuby trunk at http://svn.codehaus.org/jruby/trunk/jruby 1.5. build JRuby with "ant" 2. run 'make' from within bin/nailgun 3. start up a server with jruby-ng-server 4. instead of 'jruby' run 'jruby-ng'. -J options are not passed on.