The profiler#
Two things can be profiled: the compiler, and a program it produced.
Profiling the compiler#
alpha profile [--top N] [--json]
Measures a COLD check from inside the engine — the cache is disabled for the run, because a profile of cache hits measures the cache. It reports:
- phase totals: parse, check, interface encoding;
- the slowest modules, with their definition counts and interface sizes;
- the slowest declarations, in microseconds (a declaration is typically well under a millisecond, so milliseconds would round everything to zero).
On the 134-module application closure, one recorded run measured parse
3158 ms, check 1834 ms and interface 423 ms of 5415 ms cpu: parsing dominates a
cold check. alpha profile --top N on your own workspace gives the current
figures; --jobs N parses up to N modules at once.
The numbers are cross-checked rather than trusted: the phases sum to the
reported total, the cpu total is 0.75 of a real cold alpha check wall time,
and the slowest-module ranking repeats across runs.
Profiling a program#
alpha profile --program ARTIFACT [--runs N]
Reports the artifact by size and digest, every definition by the exact bytes its core encodes to, the ERASED program by node count and digest, and measured execution over several runs. For a program built through the direct lane, it also attributes the emitted bytes to source lines through the compiler's source map.
It does not read hardware counters, and says so: a machine whose
perf_event_paranoid forbids user-space events gives none.
GHC-level profiling#
debug/profile-build.sh FILE builds the compiler with cost centres into a
separate build directory and writes a .prof. Use it when the question is
about the compiler's own Haskell, not about the language.
Evidence#
debug/profile-check.py (5 checks) and debug/program-profile-check.py
(6 checks).