Hi,

Since you are sending all actions to the same agent they are enqueued and
processed sequentially. That's why you are seeing only two active cores (one
for the main thread (repl) or GC and one for the agent).

On Tue, Oct 6, 2009 at 4:35 PM, MarkSwanson <mark.swanson...@gmail.com>wrote:

>
> Thanks John.
> I was curious about the details so I took a dive in to the source to
> see for myself.
> In case anyone else stumbles upon this here's what I found:
>
> In Agent.java, the number of worker threads for (send) are defined
> like this:
>
> final public static ExecutorService pooledExecutor =
>        Executors.newFixedThreadPool(2 + Runtime.getRuntime
> ().availableProcessors());
>
> The clojure (send) calls Java Agent dispatch(), which winds up using
> the pooledExecutor.
>
> Clojure (send-off) follows the same path but winds up using the
> soloExecutor - which can spawn (and temporarily cache) an unlimited
> number of threads as required:
>
>
> http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool()<http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool%28%29>
>
> Random thought: Let's test (send) vs (send-off). New results using
> (send):
> (the -server jvm produces some wild results for a bit then I get
> something crazy: 7.9ms):
>
> Clojure=> (agent-speed-test)
> "Elapsed time: 1164.702387 msecs"
> 20001
> Clojure=> (agent-speed-test)
> "Elapsed time: 1416.682837 msecs"
> 20001
> Clojure=> (agent-speed-test)
> "Elapsed time: 7.907515 msecs"   <------ ** ???? LOL **
>
> This happens infrequently, but it did happen more than once.
>
> Also, I note that only 2 cores are used on my quad core2 duo. Weird.
> It's as if
>  Runtime.getRuntime().availableProcessors()  fails (returns zero?)
>
>
>
>
> >
>


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
-~----------~----~----~----~------~----~------~--~---

Reply via email to