Re: Faster application startup for rapid development

2012-05-15 Thread Sergey Didenko
 Also discovered I can prefix `java -cp ...` with `rlwrap` to get back a nice
 REPL experience.

If you want to use rlwrap, check out its options like --remember,
-c, -b and -f. Here is the script I use to run repl from the
root of the lein project:


breakchars=(){}[],^%$#@\\;:''|\\
CLOJURE_DIR=~/javalibs/clojure
LIBS=`printf %s: lib/*.jar | sed s/:$//`:.

if [ $# -eq 0 ]; then
 exec rlwrap --remember -c -b $breakchars \
-f $CLOJURE_DIR/.clj_completions \
 java -cp $LIBS:src clojure.main
else
 exec java -cp $LIBS:src:classes clojure.main $1 -- $@
fi

-- 
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: Faster application startup for rapid development

2012-05-15 Thread Michael Gardner
There's also nailgun: it keeps a JVM running in the background that Java 
programs can connect to, eliminating JVM startup time completely. It's totally 
insecure on multi-user machines and hasn't been updated in a while, but it may 
be sufficient to ease the pain on developer machines.

-- 
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: Faster application startup for rapid development

2012-05-15 Thread MarkSwanson
 reloading code at the REPL, because old background threads may still be
 running with old code. So I end up restarting the process many times per
 day.

I usually create a 'restart fn that closes down the background threads
and services and restarts them.
This might require you to add a 'shutdown' command to your services
but I've found this to be a small price to pay.

Also, it's some extra code to have threads loop/block on some
condition for 100ms (in debug mode) instead of forever, but this gives
the thread a chance to clean up and terminate every 100ms based on
some condition (set by your restart fn).

Every time you restart your repl you'll wish you had taken the time to
do something like this :-)

-- 
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: Faster application startup for rapid development

2012-05-14 Thread Stuart Sierra
Also discovered I can prefix `java -cp ...` with `rlwrap` to get back a 
nice REPL experience.
-S

-- 
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: Faster application startup for rapid development

2012-05-14 Thread blais
On Friday, May 11, 2012 5:33:22 PM UTC-4, Stuart Sierra wrote:



 What other tricks do you have for speeding up your development cycle with 
 Clojure?


I have a similar situation, where I've had to restart a repl a *lot* for a 
particular program (several times a day, like 10-20 times and sometimes 
more).  Also, I've always found the startup time of Leiningen to be too 
long to be usable--I'm very, very impatient--so I stopped using it a while 
back for startup; most of the time is due to itself being written in 
Clojure, which is awesome, but one thing about Clojure/JVM that just isn't 
awesome is precisely its startup time. Using an ugly shell script worked 
fine for a while, but then I wanted some more niceties, basically to run a 
script with just a few directory arguments and have it figure it all out, 
hunt the jars anywhere in the path, use only the latest versions of two 
colliding jars for the same package, and find .clj files and corresponding 
roots to add to the classpath and start my VM.  So I wrote one; it also 
provides startup options for swank, the vanilla repl, nrepl, and to just 
run as a main program.

Basically I just clone all the projects I need in a single directory and 
then I run:

  streamlined --swank [DIR]

and it pretty much works.  You can still use lein deps on projects to 
fetch their dependencies (only once). You can also specify a number of 
directories, and add explicit classpaths with -c (I do this in a Makefile 
these days).  Also, -v or -vv will output lots of juicy info about what it 
does so you can debug issues very easily.

You can find the latest version here if that makes your life simpler (it's 
a single Python script):
http://furius.ca/pubcode/pub/conf/bin/streamlined.html


-- 
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

Faster application startup for rapid development

2012-05-11 Thread Stuart Sierra
I have a large-ish Clojure project that involves a lot of network servers 
and background threads. It's difficult to work on a program like this by 
reloading code at the REPL, because old background threads may still be 
running with old code. So I end up restarting the process many times per 
day.

I'm using Leiningen 2.0.0-preview3 and Apple's JDK 1.6.0_29 on Mac OS X 
10.6.8.

My Leiningen project is configured to load my app in the REPL:

:repl-options {:init-ns my-project.main}

From a clean start, `lein repl` takes 25 seconds to get to the first 
prompt. That's a long time during development.

I tried pre-compiling everything by adding AOT-compilation:

:aot [my-project.main]

This is reasonable, because I'm usually only working on one source file, 
trying to fix a bug, and the Clojure loader will prefer .clj files that are 
more recent than their corresponding .class files.

After `lein compile`, I'm down to 14 seconds to start a REPL. Better, but 
still not fast enough.

What if I omit Leiningen altogether? First, generate the classpath:

lein classpath  target/classpath

Then call Java directly:

java -cp `cat target/classpath` clojure.main -i src/my_project/main.clj 
-r

This cuts startup time down to 6 seconds, but I lose all the niceties of 
the Leiningen REPL.

Running Java with '-XX:+TieredCompilation' took off another half second. 
Adding '-client' had no visible effect. 

What other tricks do you have for speeding up your development cycle with 
Clojure?

-S

-- 
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: Faster application startup for rapid development

2012-05-11 Thread Phil Hagelberg
On Fri, May 11, 2012 at 2:33 PM, Stuart Sierra
the.stuart.sie...@gmail.com wrote:
 I have a large-ish Clojure project that involves a lot of network servers
 and background threads. It's difficult to work on a program like this by
 reloading code at the REPL, because old background threads may still be
 running with old code.

Don't the ^:dynamic changes in 1.3 also include code to
forward-propagate recompiled defns to call sites that use them? So I
think restarting should only be necessary if AOT'd code has changed or
if you want to ensure you don't have any stray defns that don't exist
on disk any more. Though I suppose this is not true of HOFs. I wonder
if a macro would be helpful here to check the value of a system
property like clojure.interactive and go through a var if it's true
but use a direct function reference if not. (Dynamicity knobs in
action again?)

 From a clean start, `lein repl` takes 25 seconds to get to the first prompt.
 That's a long time during development.

Do you know if it takes about the same amount of time on Linux? I've
heard Mac users complain about slowdowns that I have been unable to
reproduce myself before, though that was a long time ago.

 What if I omit Leiningen altogether? First, generate the classpath:

     lein classpath  target/classpath

 Then call Java directly:

     java -cp `cat target/classpath` clojure.main -i src/my_project/main.clj -r

Leiningen 2 is using nrepl, so some of the overhead could come from
there. How long does `lein trampoline run -m clojure.main/main` take?
Have you tried swank-clojure?

 Running Java with '-XX:+TieredCompilation' took off another half second.
 Adding '-client' had no visible effect.

For what it's worth, tiered compilation should have the same effect as
-client; the latter is still there only for JVMs that are too old to
support tiered compilation. I did just realize that we currently only
apply tiered compilation to Leiningen's own JVM and not the project's,
so thanks for bringing that up; this will be rectified in preview4.

Thinking this over, I had another idea for a way in which launch could
be sped up using the trampoline task. Not sure if it's feasible, but I
will investigate it for the preview5 release:
https://github.com/technomancy/leiningen/issues/573

-Phil

-- 
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: Faster application startup for rapid development

2012-05-11 Thread Softaddicts
You are using an SSD drive I assume ? When you say large, how many
servers/threads ?

Luc


 I have a large-ish Clojure project that involves a lot of network servers 
 and background threads. It's difficult to work on a program like this by 
 reloading code at the REPL, because old background threads may still be 
 running with old code. So I end up restarting the process many times per 
 day.
 
 I'm using Leiningen 2.0.0-preview3 and Apple's JDK 1.6.0_29 on Mac OS X 
 10.6.8.
 
 My Leiningen project is configured to load my app in the REPL:
 
 :repl-options {:init-ns my-project.main}
 
 From a clean start, `lein repl` takes 25 seconds to get to the first 
 prompt. That's a long time during development.
 
 I tried pre-compiling everything by adding AOT-compilation:
 
 :aot [my-project.main]
 
 This is reasonable, because I'm usually only working on one source file, 
 trying to fix a bug, and the Clojure loader will prefer .clj files that are 
 more recent than their corresponding .class files.
 
 After `lein compile`, I'm down to 14 seconds to start a REPL. Better, but 
 still not fast enough.
 
 What if I omit Leiningen altogether? First, generate the classpath:
 
 lein classpath  target/classpath
 
 Then call Java directly:
 
 java -cp `cat target/classpath` clojure.main -i src/my_project/main.clj 
 -r
 
 This cuts startup time down to 6 seconds, but I lose all the niceties of 
 the Leiningen REPL.
 
 Running Java with '-XX:+TieredCompilation' took off another half second. 
 Adding '-client' had no visible effect. 
 
 What other tricks do you have for speeding up your development cycle with 
 Clojure?
 
 -S
 
 -- 
 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
--
Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad!

-- 
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: Faster application startup for rapid development

2012-05-11 Thread Moritz Ulrich
Are you on 32 or 64 bit Java? Startup is much faster on my machine
(2008 Macbook, Core2Duo) when I use a 32bit vm.

On Fri, May 11, 2012 at 11:33 PM, Stuart Sierra
the.stuart.sie...@gmail.com wrote:
 I have a large-ish Clojure project that involves a lot of network servers
 and background threads. It's difficult to work on a program like this by
 reloading code at the REPL, because old background threads may still be
 running with old code. So I end up restarting the process many times per
 day.

 I'm using Leiningen 2.0.0-preview3 and Apple's JDK 1.6.0_29 on Mac OS X
 10.6.8.

 My Leiningen project is configured to load my app in the REPL:

     :repl-options {:init-ns my-project.main}

 From a clean start, `lein repl` takes 25 seconds to get to the first prompt.
 That's a long time during development.

 I tried pre-compiling everything by adding AOT-compilation:

     :aot [my-project.main]

 This is reasonable, because I'm usually only working on one source file,
 trying to fix a bug, and the Clojure loader will prefer .clj files that are
 more recent than their corresponding .class files.

 After `lein compile`, I'm down to 14 seconds to start a REPL. Better, but
 still not fast enough.

 What if I omit Leiningen altogether? First, generate the classpath:

     lein classpath  target/classpath

 Then call Java directly:

     java -cp `cat target/classpath` clojure.main -i src/my_project/main.clj
 -r

 This cuts startup time down to 6 seconds, but I lose all the niceties of the
 Leiningen REPL.

 Running Java with '-XX:+TieredCompilation' took off another half second.
 Adding '-client' had no visible effect.

 What other tricks do you have for speeding up your development cycle with
 Clojure?

 -S

 --
 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



-- 
Moritz Ulrich

-- 
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: Faster application startup for rapid development

2012-05-11 Thread Softaddicts
I use ubuntu with an SSD and I hardly notice the lein repl  startup time.
Even in Eclipse the repl starts within a couple of seconds.

I am in the same situation, multiple processes, oracle,  About 80 
dependencies total.
I7 HT, 8 gig of ram

Before using an SSD, I used to copy the most used tools (jdk, tomcat, ...) to a
Ram drive at boot time (asynchronously obviously) and this cut the
start-crash-edit fix-restart by a significant factor.

Presently, I am on the verge of switching to ubuntu 64-bits. Just waiting for a
window to work on it.

Luc

 I have a large-ish Clojure project that involves a lot of network servers 
 and background threads. It's difficult to work on a program like this by 
 reloading code at the REPL, because old background threads may still be 
 running with old code. So I end up restarting the process many times per 
 day.
 
 I'm using Leiningen 2.0.0-preview3 and Apple's JDK 1.6.0_29 on Mac OS X 
 10.6.8.
 
 My Leiningen project is configured to load my app in the REPL:
 
 :repl-options {:init-ns my-project.main}
 
 From a clean start, `lein repl` takes 25 seconds to get to the first 
 prompt. That's a long time during development.
 
 I tried pre-compiling everything by adding AOT-compilation:
 
 :aot [my-project.main]
 
 This is reasonable, because I'm usually only working on one source file, 
 trying to fix a bug, and the Clojure loader will prefer .clj files that are 
 more recent than their corresponding .class files.
 
 After `lein compile`, I'm down to 14 seconds to start a REPL. Better, but 
 still not fast enough.
 
 What if I omit Leiningen altogether? First, generate the classpath:
 
 lein classpath  target/classpath
 
 Then call Java directly:
 
 java -cp `cat target/classpath` clojure.main -i src/my_project/main.clj 
 -r
 
 This cuts startup time down to 6 seconds, but I lose all the niceties of 
 the Leiningen REPL.
 
 Running Java with '-XX:+TieredCompilation' took off another half second. 
 Adding '-client' had no visible effect. 
 
 What other tricks do you have for speeding up your development cycle with 
 Clojure?
 
 -S
 
 -- 
 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
--
Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad!

-- 
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: Faster application startup for rapid development

2012-05-11 Thread Phil Hagelberg
On Fri, May 11, 2012 at 3:58 PM, Moritz Ulrich
ulrich.mor...@googlemail.com wrote:
 Are you on 32 or 64 bit Java? Startup is much faster on my machine
 (2008 Macbook, Core2Duo) when I use a 32bit vm.

If you have a newish JVM (hotspot 20+ IIRC) then TieredCompilation
will allow the 64-bit JVM to boot as fast as the 32-bit one.

-Phil

-- 
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