JESUS CHRIST!
What the hell just happened? I used clojure 1.5 alpha 3 that has the new reducers and now i get back the same result in 3 seconds!!!! HOW ON EARTH IS THAT POSSIBLE? I mean i've watched the videos but i would never expect so much performance increase!!! what is happening? Is my algorithm completely wrong? this is scary stuff...

the bad news is that i always get the same answer regardless of the depth...also something suspicious is the fact the no matter the depth the r/map returns in constant time! something smells here!


Jim












On 18/08/12 19:24, Jim - FooBar(); wrote:
On 18/08/12 13:57, Michael Gardner wrote:
Until the reducers library is ready, you could try something like this (no guarantees that this is an optimal implementation!):

(defn with-thread-pool* [num-threads f]
(let [pool (java.util.concurrent.Executors/newFixedThreadPool num-threads)]
     (try (f pool)
       (finally
         (when pool (.shutdown pool))))))

(defmacro with-thread-pool [[name num-threads] & body]
   `(with-thread-pool* ~num-threads (fn [~name] ~@body)))

(defn pmap-pool [f coll]
   (with-thread-pool [pool (.. Runtime getRuntime availableProcessors)]
     (doall
       (map #(.get %)
         (.invokeAll pool
           (map (partial partial f)
             coll))))))


Hi Michael,

Unfortunately I get exactly the same performance with pmap when using the above code... and again 2 of my cpus are sitting around waiting! If use pmap or map-pool on all levels i get almost 100% utilisation of cpu but nothing useful happens!!! anyway, I'll have a look at reducers!
thanks for the snippet anyway!

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

Reply via email to