OCamlPro/opam-repository — pull request #470 by avsm (2013-02-28 18:02:55+00:00)
Title: add mshinwell's allocation profiling branch

From Mark:
```
1. Use -allocation-tracing to ocamlopt.

2. Run with OCAMLRUNPARAM=T

3. Either:

external decode : unit -> unit
= "caml_dump_allocation_tracing_arrays"
...
Pervasives.at_exit decode

or: run under gdb, break on [exit] or similar, then run:
call caml_dump_allocation_tracing_arrays(0)

4. Copy and paste the output into two files, one for minor, one for
major, and strip off the first column which says "minor" or "major".

5. Run through the decoding script (below). Syntax:
./decode.sh

--

#!/bin/bash

set -eu -o pipefail

exe="$1"
allocs="$2"

commands=$(mktemp)
lines=$(mktemp)
nums=$(mktemp)
addrs=$(mktemp)

cat $allocs | sed 's/,.*//' > $addrs
cat $addrs | sed 's/^/inf line */' > $commands
paste <(sed -e 's/.*,//' $allocs) <(gdb $exe -batch -x $commands) | \
sed 's/__/./g' | \
sed 's//' | \
sort -k 1 -n -r
```