patch applied (packages/containers): Change the worker/wrapper to explicitly pass arguments.

Simon Peyton-Jones simonpj at microsoft.com
Fri Nov 12 17:24:46 EST 2010


Milan

Thanks for doing this.

You've discovered some performance-related things described below.  I don't yet understand what they are.  Could you write an email or wiki page summarising what you learned?  Particularly:

* What is the w/w structure that benefitted 'lookup' and 'member'?

* What is the "don't pass f explicitly" thing that has such a huge benefit?

* What do you mean by creating closures?  

Can you describe the fast way and the slow way in each case?

Simon

|  Fri Oct 29 16:16:53 PDT 2010  Milan Straka <fox at ucw.cz>
|    * Settle performance issues in IntMap and IntSet.
|  
|    The worker-wrapper transformation is removed from
|    all functions but lookup and member. This is the
|    only place where it causes benefits -- a 10% to
|    15% speedup. It increases memory allocation
|    slightly (0-5%), but the effect on GHC is really
|    minor.
|  
|    Also INLINE/INLINABLE hints are not really needed,
|    GHC figures it all by itself. The explicit INLINE
|    were left on internal functions that are crutial
|    to INLINE because of performance.
|  
|      M ./Data/IntMap.hs -167 +140
|      M ./Data/IntSet.hs -54 +52

|  Tue Oct 19 13:20:43 PDT 2010  Milan Straka <fox at ucw.cz>
|    * Do not pass f explicitely for fold.
|  
|    Benchmarks shows this is a huge win (100% for (:) being
|    the function, 1000% for (+) being the function).
|  
|      M ./Data/IntMap.hs -5 +5
|      M ./Data/IntSet.hs -5 +5
|      M ./Data/Map.hs -6 +6
|      M ./Data/Set.hs -3 +3

|  Sat Oct 16 12:57:57 PDT 2010  Milan Straka <fox at ucw.cz>
|    * Change the worker/wrapper to explicitly pass arguments.
|  
|    As the benchmarking showed, it is not a good idea to create
|    closures in the worker/wrapper transformation, as the captured
|    arguments of the enclosing function have to be allocated on the
|    heap. It is better to explicitly pass the arguments on the stack.
|    This saves memory and add no time penalty if the arguments are
|    the first arguments of recursive function (GHC refrains from
|    needless copying).
|  
|    The worker is often strict in some arguments. I did not want
|    to use BangPatterns, so I used macros to indicate strictness.
|    If majority thinks BangPatters are fine, I will gladly change it.
|  
|      M ./Data/IntMap.hs -85 +101
|      M ./Data/IntSet.hs -34 +45
|      M ./Data/Map.hs -139 +165
|      M ./Data/Set.hs -45 +55
|  
|  View patch online:
|  http://darcs.haskell.org/cgi-
|  bin/darcsweb.cgi?r=packages/containers;a=darcs_commitdiff;h=20101016195757-
|  7b66e-8cc141a04c7747851758f1f133a05ebd30cd7de7.gz
|  _______________________________________________
|  Cvs-libraries mailing list
|  Cvs-libraries at haskell.org
|  http://www.haskell.org/mailman/listinfo/cvs-libraries



More information about the Cvs-libraries mailing list