Personal tools

Performance/Modules

From HaskellWiki

< Performance(Difference between revisions)
Jump to: navigation, search
m (Performance:Modules moved to Performance/Modules)
(fix info about jhc)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{Performance infobox}}
 
{{Performance infobox}}
  +
[[Category:Performance|Modules]]
 
== Use an explicit export list ==
 
== Use an explicit export list ==
 
(note: this only applies to compilers based on separate compilation like [[GHC]], not to those based on whole-program compilation like [[JHC]]).
 
   
 
If you do not have an explicit export list in a module, the compiler must assume that everything in that module will be exported. This disables various useful optimisations:
 
If you do not have an explicit export list in a module, the compiler must assume that everything in that module will be exported. This disables various useful optimisations:
Line 11: Line 10:
   
 
* The compiler has more flexibility regarding calling conventions and the like for functions that are not visible beyond the current compilation unit.
 
* The compiler has more flexibility regarding calling conventions and the like for functions that are not visible beyond the current compilation unit.
  +
  +
* Even though jhc does a final full optimization pass, explicit export lists still greatly help expose other optimization opprotunities that might not be available later and can greatly speed up the time it takes to compile a program.
  +
  +
== Manual whole program compilation ==
  +
  +
For compilers with separate module compilation, a whole-program compilation and optimization can be achieved semi-automatically
  +
by merging a bundle of modules using [http://www.cs.utah.edu/~hal/HAllInOne/ Haskell All-In-One].

Latest revision as of 01:41, 6 March 2008

Haskell Performance Resource

Constructs:
Data Types - Functions
Overloading - FFI - Arrays
Strings - Integers - I/O
Floating point - Concurrency
Modules - Monads

Techniques:
Strictness - Laziness
Avoiding space leaks
Accumulating parameter

Implementation-Specific:
GHC - nhc98 - Hugs
Yhc - JHC

[edit] 1 Use an explicit export list

If you do not have an explicit export list in a module, the compiler must assume that everything in that module will be exported. This disables various useful optimisations:

  • If a function is used only once in the current module, and not exported, there is no penalty for inlining the function at its single use point.
  • If a function is not used at all, and not exported, its definition can be discarded.
  • The compiler has more flexibility regarding calling conventions and the like for functions that are not visible beyond the current compilation unit.
  • Even though jhc does a final full optimization pass, explicit export lists still greatly help expose other optimization opprotunities that might not be available later and can greatly speed up the time it takes to compile a program.

[edit] 2 Manual whole program compilation

For compilers with separate module compilation, a whole-program compilation and optimization can be achieved semi-automatically by merging a bundle of modules using Haskell All-In-One.