On Aug 6, 11:51 am, John Harrop <jharrop...@gmail.com> wrote: > Cache misses are a possibility; try the integer version with long, so the > size of the data is the same as with double. > The other possibility I'd consider likely is that the JDK you were using > implements caching in Double.valueOf(double). This could be dealt with if > Clojure boxing directly called new Double(double). Caching in valueOf > methods has been known to cause trouble in other situations, involving Java, > primitive boxing, and performance. Besides the caching wrecking memory > access-pattern locality, causing CPU cache misses, it likely involves > acquiring and releasing a global lock on the Double cache, which will kill > multithreaded performance particularly.
Interesting how the caching can mess performance up, especially in multi-threaded situations. I don't know yet how to confirm whether my implementation uses that caching, but I did see a mention of it in some docs for Double.valueOf(double), and didn't think about the possibility of that introducing locking. In this particular test, I doubt it would increase non-locality much if at all, since we are always providing the same value (0.1) to the method, so the cache should have exactly 1 element in it the whole time. But if it were synchronized, that would definitely bring down the performance of this particular test, or in general any test with a significant number of float or double operations, down closer to that of a single core. If that is the performance bottleneck in this case, is there any way around it? Perhaps I could try locally changing my Clojure Java source to use new Double instead of Double.valueOf(double) and it might actually be faster. I'll try out some variations with different types like long and float, and report back when I've got them. Thanks, Andy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---