1.3. The Checklist¶
Here is a checklist of things you might try to improve the performance of your program.
[ ] Are you compiling with
-O2
,-Wall
?[ ] Have you checked for memory leaks on the heap?
[ ] Have you checked for stack leaks?
[ ] Have you weighed your data structures?
[ ] Do you understand the memory footprints of your data types?
[ ] Can you reduce the memory footprint of you data types?
[ ] Are you using data structures that have a low impedence to your problem?
[ ] Have you set up benchmarks? Are they realistic? Do the exercise the full data space?
[ ] Are your data types strict? Can you unpack them?
[ ] Have you removed excessive polymorphism?
[ ] Are you using
Text
orByteString
instead ofString
?[ ] Can you inline and monomorphise critical functions, especially in hot loops?
[ ] Are you accidentally allocating in a hot loop?
[ ] Are any functions in a hot loop taking more than five arguments? Can you reduce the number of arguments?
[ ] Can you defunctionalize critical functions? Is GHC defunctionalizing for you?
[ ] Are you using a left fold over a list?
[ ] Are your datatypes definitions ordered such that the most common constructor is first?
[ ] Are you using explicit export lists?
[ ] Have you checked for missed specializations?
[ ] Have you checked the ratio of known to unknown function calls?
[ ] Have you inspected the Core?
[ ] Have you inspected the STG?
[ ] Would your program benefit from compiling with
LLVM
?[ ] Are you shotgun parsing? Can you lift information into the type system to avoid subsequent checks over the same data?
[ ] Are you grouping things that need the same processing together?
[ ] Could your program benefit for concurrency of parallelism?
[ ] Could your program benefit from the one-shot monad trick?
[ ] Have you unrolled your monad transformers?
[ ] Have you inspected the cache behavior?
Todo
Each item should have a concomitant link.