Re: Composability of Clojure in math-heavy hot loops

2014-04-06 Thread Gary Trakhman
You can possibly get rid of the var dereference by dereferencing at compile-time. Of course this means you lose the benefits of vars, too. It's just super-easy when needed :-). (defn a [] 1) (defn b [] (dotimes [_ 10] (a))) (time (b)) "Elapsed time: 1097.082556 msecs" (time (b)) "Elap

Re: Composability of Clojure in math-heavy hot loops

2014-04-06 Thread Andy Fingerhut
I would not say "shame on you" -- it is reasonably common to find Clojure code from experienced Clojure developers that puts type hints in places where they do not have the desired effect. It isn't an error, so there are no error messages. Finding occurrences of such things while I have been test

Re: Composability of Clojure in math-heavy hot loops

2014-04-06 Thread Dmitry Groshev
Shame on me! Now the difference is around 10%. Much better! Case closed, I suppose :) On Sunday, April 6, 2014 11:24:05 PM UTC+4, Andy Fingerhut wrote: > > Sorry I am not taking the time to try out the change for you and see > whether it makes the desired difference in performance happen, but I

Re: Composability of Clojure in math-heavy hot loops

2014-04-06 Thread Andy Fingerhut
Sorry I am not taking the time to try out the change for you and see whether it makes the desired difference in performance happen, but I do know that the ^double type hint on return values should be on the argument vector, not on the var. So instead of your abs-diff, try this, and similarly for a

Composability of Clojure in math-heavy hot loops

2014-04-06 Thread Dmitry Groshev
For some time I had a suspicion that in Clojure we have a fundamental problem with efficient math and today I've tried to test it. Let's say we have a pretty simple function: (ns testapp.core (:require [criterium.core :as cr] [primitive-math :as p] [no.disassemble :as nd])) (set! *wa