Jose,

This is an old thread, and whatever problems you might be dealing with now, 
they're probably not the same ones as when the thread was active.  However, 
I think that if parallel code uses the built-in Clojure random number 
functions, there is probably a bottleneck in access to the RNG.  With 
Criterium's bench function on an 8-core machine:

(def ones (doall (repeat 1000 1)))
(bench (def _ (doall (map rand ones))))   ; 189 microseconds average time
(bench (def _ (doall (pmap rand ones))))  ; 948 microseconds average time

One solution that doesn't involve generating the numbers in advance is to 
create separate RNGs, as discussed in this thread 
<https://groups.google.com/forum/#!searchin/clojure/random/clojure/cRVS19PB06E/8FsmtsYx6SkJ>.
  
This is a strategy that I am starting to explore.

Related notes for anyone interested:

As of Incanter 1.5.5 at least some functions such as sample are based on 
Clojure's bult-in rand, so they would have this problem as well.

clojure.data.generators allows rebinding the RNG, and provides 
reservoir-sample and a replacement for the default rand-nth.

The bigml/sampling 
<https://github.com/bigmlcom/sampling/tree/master/src/bigml/sampling> 
library provides sampling and random number functions with optional 
generation of a new RNG.

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to