On 15/01/13 12:57, Marko Topolnik wrote:
The tasks are waiting in the queue, they are not being executed at
all. And the time they spend waiting cannot theoretically be a
function of the time they will take to execute, once they get their
chance.
aaaaa so Java Futures are not the same as Clojure futures then! A
Clojure future will fire up as soon as you define it yes? If what you
say is true, then Java Future objects are not the same! I was under the
impression that as soon as you submit the job and get the Future Object
back , the actual computation has started already! I was wrong then...
Hmmm... now everything you've said so far makes sense! So we can't have
our cake and eat it too? What if I grew the size of the pool to (count
coll) instead of cpu-no? Then there would be no futures waiting for
their turn but it could have a bad impact on thread-coordination.
However it seems to work as I previously described and a lot faster!
user=> (time (doall (pool-map #(do (Thread/sleep %) %) dummy-times)))
;;pool of size: (count coll)
"Elapsed time: 3005.827802 msecs"
(1 2 3 4 6 5 7 8 9 10 3000 3000 3000 3000 3000 3000 3000)
user=> (time (doall (pool-map #(do (Thread/sleep %) %) dummy-times)))
;;pool of size: cpu-no ->4
"Elapsed time: 12003.958141 msecs"
(3000 3000 3000 3000 3000 3000 10 9 8 7 6 5 4 3 2 1 3000)
Your version of pool-map behaves the same! It takes 4 times less!!! I
wasn't expecting that improvement at all!
Jim
--
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