> There are two pools of threads servicing agent actions. The send pool  
> is fixed in size and based on the number of available cores. The send-
> off pool is variable in size and grows as needed to accommodate the  
> largest number of simultaneous pending send-off calls that your  
> program produces.
>
> If you use send-off when you could have used send, your send-off  
> thread pool may grow larger than it needed to grow.
>
> If you use send when you should have used send-off, other actions sent  
> to other agents may be delayed. Where the expected to run very soon,  
> they may now have to wait behind a blocking operation which could  
> easily increase the wait time from tens of microseconds or less to  
> tens of milliseconds or more--a huge factor.

I think that quote verbatim should be added to
http://clojure.org/agents
Well said :)


Back to Boris' problem though... I am now in front of a dual core
laptop and able to reproduce his strange result under a number of
different circumstances, which really puzzles me.

Even more confusing is when I tried a function using loop:
(defn fac3 [n]
  (loop [cnt n acc 1]
    (if (zero? cnt)
      acc
      (recur (dec cnt) (* acc cnt)))))

threads:  1
"Elapsed time: 1880.83262 msecs"
"Elapsed time: 2238.489249 msecs"
"Elapsed time: 1716.185717 msecs"
threads:  2
"Elapsed time: 2261.544134 msecs"
"Elapsed time: 2244.013415 msecs"
"Elapsed time: 1441.044881 msecs"
threads:  3
"Elapsed time: 3469.122751 msecs"
"Elapsed time: 2681.029014 msecs"
"Elapsed time: 2122.677044 msecs"

Now I have 2 CPUs, the 1st line is the loopmult... it  goes up by
about 15% when going from 1 thread to 2... I would expect it to remain
constant.

The 2nd test is loopfib... it remains constant from 1 thread to 2, and
goes up by only %15 for 3 threads... I would expect it to go up by %50

The 3rd test is loopfac3... (the loop) it actually finishes about 15%
earlier with 2 threads?????? remember it is doing twice the work -
that should be impossible). With 3 threads it is only 15% slower than
1.

Can anyone else come up with a theory?
I've uploaded my horribly bastardized version of Boris' original code
at
http://groups.google.com/group/clojure/web/mt2.clj
I put lots of stinky stuff in there fiddling with different ways of
calling the same scenario to try to explain it to myself and well they
all behaved as described.


Regards,
Tim.


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

Reply via email to