I am hoping to determine what are reasonable expectations for performance after parallelizing an application, especially when using clojure's reference types. I'm aware of Amdahl's law (http:// en.wikipedia.org/wiki/Amdahl's_law) but I'm still getting disappointing performance scaling in the number of processors even on highly parallel applications. Various people have reported similar results (e.g. http://groups.google.com/group/clojure/search?q=parallel+performance&start=0&scoring=d&).
Following is some code to illustrate this. It is an abstraction of a parallel genetic algorithm where a population of individuals is maintained and the following process is iterated in parallel: 1. Randomly select a subset of the population 2. Of this subset replace the lowest fitness individual with the highest fitness individual. In the code below (templated from the test-stm example at clojure.org/ concurrent_programming) I create a vector of atoms holding integers, and then spool a variable number of threads running a similar iteration to that above, where a random subset of the atom-integers are selected and the lowest number is replaced by the highest. Contention should be low since we are selecting 10 atoms per thread iteration out of 1,000,000 atoms in the vector. On my six core machine running six threads results in a ~4x speedup using atoms and ~2x speedup using refs over the single threaded version. Is this a result that should be expected or is something going wrong? I haven't had a chance to try an analogous java implementation (plus not sure what would fill in for the atom). The code and some output results are here: https://gist.github.com/770352 -- 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