Revision as of 13:06, 12 November 2012

ThreadScope is a tool for performance profiling of parallel Haskell programs.

The ThreadScope program allows us to debug the parallel performance of Haskell programs. Using ThreadScope we can check to see that work is well balanced across the available processors and spot performance issues relating to garbage collection or poor load balancing.

2 Features

ThreadScope is a graphical viewer for thread profile information generated by the Glasgow Haskell compiler (GHC). An example is shown below:

ThreadScope version 0.2.0 can be used to help debug performance issues with parallel and concurrent Haskell programs. The program has the following features.

The program displays the activity on each Haskell Execution Context (HEC) which roughly corresponds to an operating system thread. For each thread you can see whether it is running a Haskell thread or performing garbage collection. You can find out information about when Haskell threads are ready to run and information about why a Haskell thread was suspended.

An activity profile indicates the rough utilization of the HECs and when the number of HECs are greater than the number of processing cores this gives a rough guide to the overall utilization.

You can view the rate at which "par sparks" are created and evaluated during the program, and the size of the spark queue on each HEC. (This feature requires GHC-7.3 or later which is currently the development version.)

3 Using ThreadScope

To compile a program for parallel profiling use the -eventlog flag and you will also want to use the -threaded flag to compile with the multi-threaded runtime e.g.

ghc -threaded -eventlog -rtsopts --make Wombat.hs

To execute a program and generate a profile use the -ls flag after +RTS. Then pass the profile to ThreadScope:

The -N2 flag specifies the use of two Haskell Execution Contexts (i.e. cores). Once the program has been run it will produce a profile file called Wombat.eventlog or Wombat.exe.eventlog (depending on your operating system). You can now view this file with threadscope by specifying the eventlog filename as a command line argument or by navigating to it from the File menu of ThreadScope.