Re: Improving Clojure startup time with -Xbootclasspath

2009-11-23 Thread Dmitry Ulanov
Very interesting tip! Also, like vimclojure, you can run nailgun (
http://martiansoftware.com/nailgun/background.html) locally or on your
server via ssh.

On Mon, Nov 23, 2009 at 5:07 AM, Alex Osborne a...@meshy.org wrote:

 We were discussing Clojure startup time (in the context of Leiningen)
 and Phil Hagelberg asked some JRuby people about startup time.  They
 suggested using -Xbootclasspath.

 Check this out:

 % time (echo | java -client -cp clojure.jar clojure.main)
 0.84s user 0.04s system 96% cpu 0.908 total

 % time (echo | java -client -Xbootclasspath/a:clojure.jar clojure.main)
 0.42s user 0.04s system 106% cpu 0.431 total

 For the server VM:

 % time (echo | java -server -cp clojure.jar clojure.main)
 1.07s user 0.06s system 113% cpu 0.995 total

 % time (echo | java -server -Xbootclasspath/a:clojure.jar clojure.main)
 0.56s user 0.06s system 109% cpu 0.562 total

 For reference:

 % java -version
 java version 1.6.0_16
 Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
 Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode)

 Apparently on Dan Larkin's PC startup time went from a terrible 5.5s to
 a more bearable 1.9s.

 Looks like it's problematic to put Clojure libs in the bootclasspath
 though.  I get an NPE:

 Caused by: java.lang.NullPointerException
 at clojure.lang.RT.load(RT.java:377)
 at clojure.lang.RT.load(RT.java:371)

 Which is this line from RT.java:
 URL classURL = baseLoader().getResource(classfile);

 (clojure.lang.RT/baseLoader) isn't null, so I'm not sure what the deal
 is with that unless the class loading runs in a different thread where
 it is null or something.  But if you just put the Clojure jar itself in
 -Xbootclasspath and the rest of your libs as normal -cp you still get a
 nice fast start. :-)

 Charles Nutter has a nice list of JVM flags here:

 http://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html

 I don't get much of a benefit out of -XShare on my system but it might
 be worth trying as well.

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Improving Clojure startup time with -Xbootclasspath

2009-11-23 Thread Meikel Brandmeyer
Hi,

On Nov 23, 9:57 am, Dmitry Ulanov dula...@gmail.com wrote:

 Very interesting tip! Also, like vimclojure, you can run nailgun 
 (http://martiansoftware.com/nailgun/background.html) locally or on your
 server via ssh.

I'd also like to mention clj-server: http://github.com/Neronus/clj-server.

Sincerely
Meikel

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Improving Clojure startup time with -Xbootclasspath

2009-11-23 Thread Armando Blancas
I added the contrib lib expecting it to fail but it worked, and loaded
(in half the usual time) some code from the user.clj as well:

java -Xbootclasspath/a:clojure\clojure.jar;clojure-contrib\clojure-contrib.jar 
clojure.main
Clojure 1.1.0-alpha-SNAPSHOT
user=

I had been reading in this paper: 
http://www.tedneward.com/files/Papers/BootClasspath/BootClasspath.pdf
about the case below and how that could explain the NPE, but when I
added the lib to see it, the thing worked.

public class NewObjectLoader {
  public static void main (String args[]) {
NewObject no = new NewObject();
System.out.println(
  no.getClass().getName() +  was loaded by  +
 no.getClass().getClassLoader());
   }
}
Sure enough, the NewObject class is not only found at compile-time and
runtime, but it prints
NewObject was loaded by null, indicating it owes its existence to
the bootstrap ClassLoader.

Running on Vista
java -version
java version 1.6.0_13
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Improving Clojure startup time with -Xbootclasspath

2009-11-22 Thread Alex Osborne
We were discussing Clojure startup time (in the context of Leiningen) 
and Phil Hagelberg asked some JRuby people about startup time.  They 
suggested using -Xbootclasspath.

Check this out:

% time (echo | java -client -cp clojure.jar clojure.main)
0.84s user 0.04s system 96% cpu 0.908 total

% time (echo | java -client -Xbootclasspath/a:clojure.jar clojure.main)
0.42s user 0.04s system 106% cpu 0.431 total

For the server VM:

% time (echo | java -server -cp clojure.jar clojure.main)
1.07s user 0.06s system 113% cpu 0.995 total

% time (echo | java -server -Xbootclasspath/a:clojure.jar clojure.main)
0.56s user 0.06s system 109% cpu 0.562 total

For reference:

% java -version
java version 1.6.0_16
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode)

Apparently on Dan Larkin's PC startup time went from a terrible 5.5s to 
a more bearable 1.9s.

Looks like it's problematic to put Clojure libs in the bootclasspath 
though.  I get an NPE:

Caused by: java.lang.NullPointerException
 at clojure.lang.RT.load(RT.java:377)
 at clojure.lang.RT.load(RT.java:371)

Which is this line from RT.java:
 URL classURL = baseLoader().getResource(classfile);

(clojure.lang.RT/baseLoader) isn't null, so I'm not sure what the deal 
is with that unless the class loading runs in a different thread where 
it is null or something.  But if you just put the Clojure jar itself in 
-Xbootclasspath and the rest of your libs as normal -cp you still get a 
nice fast start. :-)

Charles Nutter has a nice list of JVM flags here:

http://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html

I don't get much of a benefit out of -XShare on my system but it might 
be worth trying as well.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en