Thanks for the detailed reply ... exactly what I needed! On Mon, Jan 5, 2009 at 9:29 PM, Chouser <chou...@gmail.com> wrote: > > On Mon, Jan 5, 2009 at 10:10 PM, Mark Volkmann > <r.mark.volkm...@gmail.com> wrote: >> >> I think I read somewhere that the number of threads in the thread pool >> used by agents is based on the number of processors available. Is it >> exactly that number? > > Agents currently use one of two thread pools. 'send' uses > pooledExecutor and 'send-off' uses soloExecutor. Those are defined > here: > > http://code.google.com/p/clojure/source/browse/trunk/src/jvm/clojure/lang/Agent.java?r=1194#25 > > You can see that currently pooledExecutor is capped at number of CPUs > plus 2, but I wouldn't bet too heavily on that particular formula. > >> Is that the number of threads per agent of the total number of >> threads? > > I'll assume you mean "or" instead of "of". Each agent only executes > at most one action at a time, so having multiple threads per agent > doesn't make sense. If you send multiple actions to a single agent, > the actions queue up. If you 'send' lots of actions to more than > CPUs+2 agents, the agents queue up waiting for an available thread. > > This is why it's important not to block for IO or for other threads > while in a 'send' action, because it can cause other agents to wait > unnecessarily. In those cases you should instead use 'send-off'. > Each agent will still only do one action at a time, but the > soloExecutor pool will grow as needed to give a thread to every agent > that has an action queued.
-- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---