Experiment results :

I switched a program to num.
It was quite straightforward.
First I had to replace a few unchecked-add by +.
Has unchecked-add changed name? (I use it for indices when itering on a java
array, if there is an overflow, you will know it beforehand)

The only funny event is that it was much much much slower at first.
Mainly doing reflection stuff.
I used *warn-on-reflection* and found:


( < val 0) where val is a double. Ugly, bad and wrong. I am not proud.
(* some-int some-double), that I changed to (* (double some-int)
some-double)

Then, I had some results on the benchmark I use to test my change. (I remove
14 seconds to each, because it is the compilation time. As this program is
made to run for a long time and I want to test the stationary speed,I put a
very low threshold for the jit. I don't know if it is a good idea or not.)
Initial program :                           92 seconds - 14 = 78s
Corrected program with master :  86 seconds - 14 = 72s
Corrected program with num :     80 seconds - 14 = 66s

Note that it is quite heavy on the GC, so there is 5s gc in that, which
increase still more the difference.
Altogether, it is around 10% faster, without touching any annotation and
static function.
Moreover, it might be difficult to believe if you read the beginning of my
mail, but I spend a lot of time adding annotations where I thought it was
useful.
That's difficult, and still there is a nice speedup.
Most of all, I could start added annotations to function. The problem is I
use a lot of protocols.
Are there plans for support of prim in protocols?

Last thing, there is no single bottleneck that I could rewrite easily. This
10% is spread over the program.
Result of profiling:

  Interpreted + native   Method
  0.2%     2  +    10    clojure.core__init.load
  0.1%     8  +     0    distribution.FastProductWithinComp.non_local_draw
  0.1%     7  +     0    clojure.core$vector.invoke
  0.1%     7  +     0    java.util.WeakHashMap.get
...
2.8%   177  +    32    Total interpreted (including elided)

     Compiled + native   Method
  2.4%   183  +     0    clojure.lang.RT.seqFrom
  2.2%   164  +     1    distribution.FastProductWithinComp.non_local_draw
  1.9%    61  +    81    java.util.WeakHashMap.getTable
  1.4%   103  +     0    clojure.lang.RestFn.invoke
  0.8%    62  +     1    clojure.core.protocols$fn__5284.invoke
  0.7%    51  +     0    clojure.lang.RT.next
  0.4%    31  +     1    clojure.lang.Var.pushThreadBindings
....
14.8%  1019  +   100    Total compiled (including elided)

         Stub + native   Method
 81.3%     0  +  6154    java.lang.Object.hashCode

And yes, this 10% are obtained in a code that mainly use HashMaps to
retrieve already computed values (81.3% seems spent there).
So I would expect far better speed-up in a more typical program.

(Game : guess what the program does from its profile...)

-- 
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