Personal tools

Performance

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
Welcome to the Haskell Performance Resource, the collected wisdom on how to make your Haskell programs go faster. We have chosen to organise this resource first by Haskell construct (data types, pattern matching, integers), and then within each category to describe techniques that apply across implementations, and also techniques that are specific to a certain Haskell implementation (eg. GHC). There are some implementation-specific tecniques that apply in general - those are linked from the [[Haskell Performance Resource#General_Implementation-Specific_Techniques | General Implementation-Specific Techniques]] section below.
 
Welcome to the Haskell Performance Resource, the collected wisdom on how to make your Haskell programs go faster. We have chosen to organise this resource first by Haskell construct (data types, pattern matching, integers), and then within each category to describe techniques that apply across implementations, and also techniques that are specific to a certain Haskell implementation (eg. GHC). There are some implementation-specific tecniques that apply in general - those are linked from the [[Haskell Performance Resource#General_Implementation-Specific_Techniques | General Implementation-Specific Techniques]] section below.
  +
  +
The key tool to use in making your Haskell program run faster is ''profiling''. Profiling is provided by [[GHC]] and [[nhc98]]. There is ''no substitute'' for finding where your program's time/space is ''really'' going, as opposed to where you imagine it is going.
  +
  +
Another point to bear in mind: By far the best way to improve a program's performance ''dramatically'' is to use better algorithms. Once profiling has thrown the spotlight on the guilty time-consumer(s), it may be better to re-think your program than to try all the tweaks listed below.
  +
  +
Another extremely efficient way to make your program snappy is to use library code that has been Seriously Tuned By Someone Else. You ''might'' be able to write a better quicksort than the one in <tt>Data.List</tt> but it
  +
will take you much longer than typing <tt>import Data.List</tt>.
  +
   
 
== Haskell constructs ==
 
== Haskell constructs ==
Line 12: Line 20:
 
* [[Performance:IO | I/O ]]
 
* [[Performance:IO | I/O ]]
 
* [[Performance:Floating Point | Floating Point]]
 
* [[Performance:Floating Point | Floating Point]]
  +
  +
== Traps to avoid ==
  +
  +
* [[Performance:Space | Space Leaks]]
   
 
== General Implementation-Specific Techniques ==
 
== General Implementation-Specific Techniques ==

Revision as of 11:09, 10 January 2006

Welcome to the Haskell Performance Resource, the collected wisdom on how to make your Haskell programs go faster. We have chosen to organise this resource first by Haskell construct (data types, pattern matching, integers), and then within each category to describe techniques that apply across implementations, and also techniques that are specific to a certain Haskell implementation (eg. GHC). There are some implementation-specific tecniques that apply in general - those are linked from the General Implementation-Specific Techniques section below.

The key tool to use in making your Haskell program run faster is profiling. Profiling is provided by GHC and nhc98. There is no substitute for finding where your program's time/space is really going, as opposed to where you imagine it is going.

Another point to bear in mind: By far the best way to improve a program's performance dramatically is to use better algorithms. Once profiling has thrown the spotlight on the guilty time-consumer(s), it may be better to re-think your program than to try all the tweaks listed below.

Another extremely efficient way to make your program snappy is to use library code that has been Seriously Tuned By Someone Else. You might be able to write a better quicksort than the one in Data.List but it will take you much longer than typing import Data.List.


Contents

1 Haskell constructs

2 Traps to avoid

3 General Implementation-Specific Techniques

4 More Information