Haskell High Performance Code Profiling

I have a high-performance Haskell code - the inner loop is up to 6 build instructions. Changing the inner loop to be less efficient does not have a noticeable effect on performance, assuming that the inner loop is not a bottleneck. However, when I turn on profiling, the assembly code generated for the inner loop becomes much less efficient, and the profiler reports that the inner loop takes 85% of the time.

I suspect that something is not so slow, but when I use profiling to understand that, I suspect that profiling makes the inner loop slow enough than it dominates. What methods can I use to find out where the time is going? A sampler would be great if it existed for Haskell.

+46
assembly profiling haskell
Jan 02
source share
1 answer

You can use Linux perf events: https://ghc.haskell.org/trac/ghc/wiki/Debugging/LowLevelProfiling/Perf

This will give you a result that looks like this:

# Samples: 9161149923 # # Overhead Command Shared Object Symbol # ........ ....... ................. ...... # 30.65% queens queens [.] s1ql_info 18.67% queens queens [.] s1qj_info 12.17% queens queens [.] s1qi_info 9.94% queens queens [.] s1o9_info 5.85% queens queens [.] r1nI_info 5.33% queens queens [.] s1sF_info 5.18% queens queens [.] s1sG_info 3.69% queens queens [.] s1oP_info 1.68% queens queens [.] stg_upd_frame_info 0.88% queens queens [.] stg_ap_2_upd_info 0.62% queens queens [.] s1sE_info 0.56% queens [kernel] [k] read_hpet 0.39% queens queens [.] stg_ap_p_info 0.35% :2030 f76beb [.] 0x00000000f76beb 0.31% queens queens [.] s1oD_info 0.28% swapper [kernel] [k] mwait_idle_with_hints 0.25% queens queens [.] __stg_gc_enter_1 0.23% queens queens [.] evacuate 0.18% swapper [kernel] [k] read_hpet 0.12% queens queens [.] scavenge_block 

If you save the kernel during compilation, you can map these characters to functions in the kernel.

It hurts a little, but gives you more reliable results.

To do this, you need to do some work.

+22
Jan 06 '14 at 10:57 on
source share



All Articles