-
Notifications
You must be signed in to change notification settings - Fork 0
/
cheatsheet.tex
121 lines (99 loc) · 3.65 KB
/
cheatsheet.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
\documentclass[10pt,landscape]{article}
\usepackage{multicol}
\usepackage{calc}
\usepackage{ifthen}
\usepackage[landscape]{geometry}
\usepackage{amsmath,amsthm,amsfonts,amssymb}
\usepackage{color,graphicx,overpic}
\usepackage{hyperref}
% Define a TODO command
\usepackage{ifthen}
\usepackage{color}
\definecolor{Orange}{rgb}{1,0.5,0}
\newcommand{\todo}[1][0]{%
\textsf{\textbf{\textcolor{Orange}{%
[[TODO\ifthenelse{\equal{#1}{0}}{}{: #1}]]}}}%
}
\pdfinfo{
/Title (GHC Memory Profiling Cheat Sheat)
/Creator (pdflatex)
/Producer (pdfTeX 1.40.0)
/Author (Rogan Creswick)
/Subject (Haskell)
/Keywords (Haskell, ghc, memory, cheatsheet, quickreference, quickref)}
% This sets page margins to .5 inch if using letter paper, and to 1cm
% if using A4 paper. (This probably isn't strictly necessary.)
% If using another size paper, use default 1cm margins.
\ifthenelse{\lengthtest { \paperwidth = 11in}}
{ \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }
{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
}
% Turn off header and footer
\pagestyle{empty}
% Redefine section commands to use less space
\makeatletter
\renewcommand{\section}{\@startsection{section}{1}{0mm}%
{-1ex plus -.5ex minus -.2ex}%
{0.5ex plus .2ex}%x
{\normalfont\large\bfseries}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}%
{-1explus -.5ex minus -.2ex}%
{0.5ex plus .2ex}%
{\normalfont\normalsize\bfseries}}
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}%
{-1ex plus -.5ex minus -.2ex}%
{1ex plus .2ex}%
{\normalfont\small\bfseries}}
\makeatother
% Define BibTeX command
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
% Don't print section numbers
\setcounter{secnumdepth}{0}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt plus 0.5ex}
%My Environments
\newtheorem{example}[section]{Example}
% -----------------------------------------------------------------------
\begin{document}
\raggedright
\footnotesize
\begin{multicols}{3}
% multicol parameters
% These lengths are set only within the two main columns
%\setlength{\columnseprule}{0.25pt}
\setlength{\premulticols}{1pt}
\setlength{\postmulticols}{1pt}
\setlength{\multicolsep}{1pt}
\setlength{\columnsep}{2pt}
\begin{center}
\Large{\underline{GHC Memory Profiling/Debugging}} \\
\end{center}
\section{First steps}
\subsection{Enable profiling}
\subsection{No build system}
\verb+ghc -prof+ \todo{is that right?}
\subsection{cabal}
Add GHC options:
\verb+ghc-options: -O2 -rtsopts -prof+
\subsection{cabal-dev}
Follow the ghc options steps for cabal, then, if you haven't been
building with profiling, clear the sandbox:
\verb+$ mv cabal-dev cabal-dev-no-prof+
Rebuild with profiling enabled:
\verb+$ cabal install --enable-library-profiling --enable-executable-profiling+
\subsection{Run with +RTS -RTS}
\verb|$ ./my-binary <params> +RTS -p -pomyProfile -RTS|
\section{RTS Options}
\verb|$ ./my-binary <params> +RTS -hc -RTS|
Generates a \verb|my-binary.hp| file, to use this, run hp2ps on it:
\verb|$ hp2ps -c my-binary.hp|
Then look at my-binary.ps.
\verb|-hc| Cost-center allocations.
\verb|-hy| Per-type allocations.
\verb|-po<name>| change the prefix of the output filenames
\section{Heap Profiles}
\end{multicols}
\end{document}