> Johann, if you are still following this thread, could you try running > this Clojure program on your 8 core machine? > > http://github.com/jafingerhut/clojure-benchmarks/blob/3e45bd8f6c3eba4... > > These first set of parameters below will do 8 jobs sequentially, each > doing 10^10 (inc c)'s, where c is a double primitive. The second will > do the 8 jobs in parallel, hopefully finishing about 8 times faster on > your machine: > > java -cp <your_class_path> clojure.main pmap-testing.clj double2 8 > 10000000000 1 > java -cp <your_class_path> clojure.main pmap-testing.clj double2 8 > 10000000000 8
Ok these are the results on my machine ((*) denotes the value of the last parameter): sequential (1) : "Elapsed time: 112843.711514 msecs" parallel (8) : "Elapsed time: 28347.267593 msecs" while using 800% CPU in case of parallel (8). I tried with changing the last parameter and these are the results: parallel (2) : "Elapsed time: 75269.155776 msecs" parallel (3) : "Elapsed time: 47145.931658 msecs" parallel (4) : "Elapsed time: 37715.217599 msecs" parallel (5) : "Elapsed time: 37839.950079 msecs" parallel (6) : "Elapsed time: 38357.797175 msecs" parallel (7) : "Elapsed time: 37756.190205 msecs" >From 4 to 7 there is no speedup at all. > If you replace double2 with double1, it should reproduce your initial > test case with (inc 0.1) in the inner loop -- the one that started > this thread about why there wasn't much speedup. Results for double1: sequential (1) : "Elapsed time: 776338.624798 msecs" parallel (8) : "Elapsed time: 578037.874598 msecs" > I created some Clojure and Java functions that are as similar as I > know how to make them, but frankly I don't really know whether my JVM > implementation (Apple's java 1.6.0_13) is using 'new Double', or a > cache as mentioned by John Harrop earlier in this discussion, in its > implementation of Double.valueOf(double). I've found that the > performance is very similar to a Java program that uses 'new Double' > explicitly in its inner loop. I changed my example for Java threads to just do a new Double and a new Integer in the loop. In this case there is both times no speedup at all. So I think Java does not parallelize well with lots of objects handled by each thread. So this is really a Java problem, but I did not find a discussion about this issue in Java forums. But there remains an open issue for Clojure: If I do my pmaptest with a very large Integer (inc 2000000000) instead of (inc 0), it is as slow as the double version. My question is, whether Clojure may has a special handling for small integers? Like using primitives for small ints and doing a new Integer for larger ones? By the way GC is running periodically, but while profiling it does not report more than 1 sec of total runtime. -- Johann --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---