In that case isn't context switching dominating your test?

.isArray isn't expensive enough to warrant the use of pmap

Leonardo Borges
www.leonardoborges.com
On Dec 29, 2012 10:29 AM, "cameron" <cdor...@gmail.com> wrote:

> Hi Lee,
>   I've done some more digging and seem to have found the root of the
> problem,
> it seems that java native methods are much slower when called in parallel.
> The following code illustrates the problem:
>
> (letfn [(time-native [f]
>          (let [c (class [])]
>            (time (dorun (f
>                          (fn [_] (.isArray c))
>                          (range 10000000))))))]
>   (println "Sequential Test:")
>   (time-native map)
>   (println "Parallel Test:")
>   (time-native pmap))
>
> On a dual quad-core xeon box I get the following results:
>   Sequential Test:
>    "Elapsed time: 1054.807725 msecs"
>   Parallel Test:
>    "Elapsed time: 15302.605697 msecs"
>
> ie. the code executed in parallel was 15 times slower than the sequential
> version.
> The same can be seen with isInstance and isArray members of
> java.lang.Class.
>
> I'm not sure where to go from here, these functions are frequently used by
> clojure.core
> Perhaps someone with more JVM implementation knowledge can help?
>
> Cameron.
>
> --
> 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 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