You need the (System/exit 0) when using a higher optimization setting and
this is explicitly mentioned in the Quick Start. This is an upstream bug in
Closure Compiler. They create a thread to increase the stack size for Java
6, this is legitimately a bug though as Closure Compiler only supports Java
7.

David

On Wed, Mar 18, 2015 at 12:48 PM, Caspar Hasenclever <[email protected]>
wrote:

> Following the current Quick Start document at
> https://github.com/clojure/clojurescript/wiki/Quick-Start, I found that
> there is a roughly one minute long extra wait after closure optimizations
> have been applied before the JVM exits.
>
> My setup: hello word example as on the Quick Start guide, build.clj is:
>
>   (require 'cljs.closure)
>
>   (cljs.closure/build "src"
>     {:output-to "out/main.js"
>      :verbose true})
>
> With this build call (no optimizations), compile from cold is under 3s.
> Adding simple optimizations to the above call:
>
>   (cljs.closure/build "src"
>     {:output-to "out/main.js"
>      :optimizations :simple
>      :verbose true})
>
> makes the process take over a minute. The CPU is only active for a few
> seconds at the beginning, for the remainder of the time nothing appears
> to be happening (the output file is done and remains unchanged after the
> first few seconds). Looking at the process in jvisualvm shows threads
> called jscompiler that are also idle after a bit of activity at the
> beginning. My suspicion is that there is a timeout somewhere but I have
> not found exactly where. It looks as if it is in Google Closure as I can't
> find
> any reference to threads called jscompiler in the ClojureScript sources.
>
> A Thread dump during the wait time shows a jscompiler thread to be waiting:
>
>    "jscompiler" #16 prio=5 os_prio=0 tid=0x00007f2304efb800 nid=0x5032
> waiting on condition [0x00007f22e4713000]
>       java.lang.Thread.State: TIMED_WAITING (parking)
>       at sun.misc.Unsafe.park(Native Method)
>       - parking to wait for  <0x000000008725e6f8> (a
> java.util.concurrent.SynchronousQueue$TransferStack)
>       at
> java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
>       at
> java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
>       at
> java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:362)
>       at
> java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:941)
>       at
> java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1066)
>       at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
>       at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>       at java.lang.Thread.run(Thread.java:745)
>
>       Locked ownable synchronizers:
>       - None
>
> Adding a simple:
>
>   (System/exit 0)
>
> after the cljs.closure/build call reduces compilation by almost exactly
> a minute back down to 8 seconds with {:optimizations :simple}.
>
> System is Debian Linux (testing), Oracle JDK 8, java -version:
>
>   java version "1.8.0_40"
>   Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
>   Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
>
> Compilation command line is:
>
>   java -cp cljs.jar:src clojure.main build.clj
>
> Has anybody else experienced this? Is there a way to reduce the wait?
>
> Regards,
>
> Caspar
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to