- jruby --ng-server starts up a server. You can manage it however you like
- jruby --ng uses the Nailgun client instead of launching a new JVM for the command you run. You'll just need to run make in tool/nailgun to build the ng executable (already built for you on Windows).
Heres a sample session:
~/projects/jruby ➔ cd tool/nailgun/ ; make ; cd -
Building ng client. To build a Windows binary, type 'make ng.exe'
gcc -Wall -pedantic -s -O3 -o ng src/c/ng.c
ld warning: option -s is obsolete and being ignored
/Users/headius/projects/jruby
~/projects/jruby ➔ jruby --ng-server
NGServer started on all interfaces, port 2113.
^Z
[1]+ Stopped jruby --ng-server
~/projects/jruby ➔ bg
[1]+ jruby --ng-server &
~/projects/jruby ➔ jruby --ng -e "puts 1"
1
~/projects/jruby ➔ time jruby -e "puts 1"
1
real 0m0.609s
user 0m0.482s
sys 0m0.119s
~/projects/jruby ➔ time jruby --ng -e "puts 1"
1
real 0m0.073s
user 0m0.010s
sys 0m0.018s
Update: For those not familiar, "NailGun is a client, protocol, and server for running Java programs from the command line without incurring the JVM startup overhead. Programs run in the server (implemented in java), triggered by the client (written in C), which handles all I/O."
For comparison when not using NG:
ReplyDelete$ time jruby -e "puts 1"
1
real 0m5.357s
user 0m0.504s
sys 0m0.191s
That's a huge difference, and it should make JRuby web app deployments much better.
Thanks guys!
- Matt
I'm still dreaming of someone to build a comprehensive Java command line toolkit.
ReplyDeleteNailgun, a fixed version of JLine, a reasonable command line options parser (all the ones out there are unmaintained and/or crap...).
Martin: I'm an admin on Jline now, so if there's fixes you think need to get in jump on the ML and say so. We can put out a release.
ReplyDeleteThis will make running JRuby from non-Java-based editors much easier, since the plugin writers won't have to manually wire up Nailgun. Thanks!
ReplyDeleteAre there any known input/stdin problems? I can't get irb to run appropriately.
ReplyDeleteMernen: Yes, it appears that jirb does not work at the moment. We'll have to track down exactly what's wrong with it. When I try it, I see it launching stty (part of JRuby startup I think) and never getting any further...
ReplyDeleteCan you file a bug for it please?
Charles: that is very good news that JLine is maintained again. I'll file some bugs with SourceForge if you don't mind.
ReplyDeleteCharles/Mernen:
About the blocking stty call: I guess I ran into that bug here, too. The issue (at least the one I had) is that JLine is calling stty when initializing a terminal.
Now the issue is that in your nailgun setup, or in the case where you pipe input to a command ("cat foo | jruby --ng"), the input stream is not really terminal, and stty thus blocks. I can't quite find the correct man pages etc now, but I think that was the issue. On some UNICes (Linux in particular if I remember correctly), it is possible to give stty a parameter telling it not to block, but I can't quite find the reference.
Tried this with loading a rails environment.
ReplyDeleteWith NG:
time jruby --ng -e 'require "config/environment"'
real 0m26.159s
user 0m0.011s
sys 0m0.021s
Without NG:
time jruby -e 'require "config/environment"'
real 0m16.967s
user 0m14.659s
sys 0m1.176s
(the simple puts example worked as shown in the blog post)
On sourceforge? Really?
ReplyDeleteSee http://jira.codehaus.org/browse/JRUBY-3867 for a required patch of the windows batch files (patch included JRuby 1.4).
ReplyDelete