Haskell High Performance Programming
上QQ阅读APP看书,第一时间看更新

Summary

We started this chapter by profiling programs by cost centres, which can be set automatically (-fprof-auto) or manually (SCC-annotations). We learned that there is overhead in profiling, which is why execution times are an inaccurate metric when profiling. Allocations remained a good measure of performance in any case. We used the heap profiler to produce informative graphs about memory usage over time, and to spot unwanted allocations and retainers.

We explored different options in the GHC heap profiler: break-downs and subset selections, both of which draw more or less from the same pool of parameters. The default break-down was by cost not yet finished.

Finally, we looked at two additional libraries, criterion for benchmarking and ekg for monitoring. In discussing criterion, we stumbled upon the concept of normal form, which will also come up later on when we discuss parallelism. Adding real-time graphical garbage garbage collector monitoring via HTTP to a Haskell application was a real breeze with ekg, and the library fully supports custom metrics and extending the monitoring system.

In the next chapter, we will pull everything together from these first three chapters and discuss some of the fine details of developing Haskell at scale: structuring bigger projects using cabal and stack. We will look at some less common performance tricks such as lazy patterns and rewrite rules, revisit and introduce some concepts such as inlining and specializing, and briefly discuss practical type-level programming.