Personal tools

ThreadScope

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m (Using ThreadScope: fix example)
m (Installing ThreadScope: add link to windows binary)
(17 intermediate revisions by 5 users not shown)
Line 3: Line 3:
 
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.
 
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.
   
== Overview ==
+
== Getting Started ==
  +
  +
Have gtk on your machine? (Note that you don't need all of gtk and gtk2hs, e.g., libxml is unneeded.) See the gtk2hs install instructions <span style="font-size:8pt">([[Gtk2Hs/Windows|Windows]] ∙ [[Gtk2Hs/Mac|Mac]] ∙ [[Gtk2Hs/Linux|Linux]])</span> and then
  +
  +
cabal update
  +
gtk-demo
  +
cabal install gtk
  +
cabal install threadscope
  +
  +
Next, check out the user guide. We call it the [[ThreadScope Tour]].
  +
  +
== Features ==
   
 
ThreadScope is a graphical viewer for thread profile information generated by the Glasgow Haskell compiler (GHC). An example is shown below:
 
ThreadScope is a graphical viewer for thread profile information generated by the Glasgow Haskell compiler (GHC). An example is shown below:
Line 14: Line 14:
   
 
* 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.
 
* 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 place bookmarks at various points in the time profile to help with navigation. Bookmarks can be emitted from Haskell code using the `traceEvent` action.
 
   
 
* 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 [http://hackage.haskell.org/trac/ghc/wiki/Building development version].)
 
* 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 [http://hackage.haskell.org/trac/ghc/wiki/Building development version].)
Line 25: Line 23:
 
ghc -threaded -eventlog -rtsopts --make Wombat.hs
 
ghc -threaded -eventlog -rtsopts --make Wombat.hs
   
To execute a program and generate a profile use the -ls flag after +RTS:
+
To execute a program and generate a profile use the -ls flag after +RTS. Then pass the profile to ThreadScope:
   
 
./Wombat +RTS -ls -N2
 
./Wombat +RTS -ls -N2
  +
threadscope Wombat.eventlog # on Windows: Wombat.exe.eventlog
   
 
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.
 
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.
  +
  +
For more detailed instructions, have a look at the [[ThreadScope Tour]].
   
 
== Installing ThreadScope ==
 
== Installing ThreadScope ==
Line 35: Line 36:
 
The recommendation is to use the [http://hackage.haskell.org/platform/ Haskell Platform]. This includes GHC and the cabal package tool. At minimum you need GHC-6.12.
 
The recommendation is to use the [http://hackage.haskell.org/platform/ Haskell Platform]. This includes GHC and the cabal package tool. At minimum you need GHC-6.12.
   
Threadscope itself is [http://hackage.haskell.org/package/threadscope available from hackage].
+
ThreadScope itself is [http://hackage.haskell.org/package/threadscope available from hackage].
   
It has a dependency on the Haskell Gtk+ binding (Gtk2Hs) which involves a bit of manual work on Windows and Mac OS X to install the Gtk+ C libraries.
+
For Windows there is a binary release available: [http://projects.haskell.org/ThreadScope/threadscope-0.2.2.zip threadscope-0.2.2.zip].
  +
  +
ThreadScope has a dependency on the Haskell Gtk+ binding (Gtk2Hs) which involves a bit of manual work on Windows and Mac OS X to install the Gtk+ C libraries.
   
 
See the Gtk2Hs installation instructions for details:
 
See the Gtk2Hs installation instructions for details:
Line 52: Line 53:
   
 
threadscope --test ch8
 
threadscope --test ch8
  +
  +
You should see something like
  +
[[Image:ThreadScope-ch8.png|600px]]
   
 
== More Information ==
 
== More Information ==
Line 75: Line 79:
 
== People ==
 
== People ==
   
Donnie Jones, donnie@darthik.com
+
* Donnie Jones, donnie@darthik.com
Simon Marlow, simonmar@microsoft.com, http://www.haskell.org/~simonmar/
+
* Simon Marlow, simonmar@microsoft.com, http://www.haskell.org/~simonmar/
Satnam Singh, satnams@microsoft.com, http://research.microsoft.com/~satnams
+
* Satnam Singh, s.singh@acm.org, http://cs.bham.ac.uk/~singhsu/
Duncan Coutts, duncan@well-typed.com, http://www.well-typed.com/who_we_are
+
* Duncan Coutts, duncan@well-typed.com, http://www.well-typed.com/who_we_are
Mikolaj Konarski, mikolaj@well-typed.com
+
* Mikolaj Konarski, mikolaj@well-typed.com
  +
* Nicolas Wu, nick@well-typed.com
  +
* Eric Kow, eric@well-typed.com
   
== Publications ==
+
== Publications and Talks ==
   
 
Simon Marlow, Simon Peyton Jones, and Satnam Singh, [http://research.microsoft.com/apps/pubs/default.aspx?id=79856 Runtime Support for Multicore Haskell], in ''ICFP 2009'', Association for Computing Machinery, Inc., 5 September 2009
 
Simon Marlow, Simon Peyton Jones, and Satnam Singh, [http://research.microsoft.com/apps/pubs/default.aspx?id=79856 Runtime Support for Multicore Haskell], in ''ICFP 2009'', Association for Computing Machinery, Inc., 5 September 2009
Line 87: Line 91:
 
Don Jones Jr., Simon Marlow, and Satnam Singh, [http://research.microsoft.com/apps/pubs/default.aspx?id=80976 Parallel Performance Tuning for Haskell], in ''ACM SIGPLAN 2009 Haskell Symposium'', Association for Computing Machinery, Inc., 3 September 2009
 
Don Jones Jr., Simon Marlow, and Satnam Singh, [http://research.microsoft.com/apps/pubs/default.aspx?id=80976 Parallel Performance Tuning for Haskell], in ''ACM SIGPLAN 2009 Haskell Symposium'', Association for Computing Machinery, Inc., 3 September 2009
   
'''Upcoming:''' Duncan Coutts, Mikolaj Konarski and Andres Loeh, [[HaskellImplementorsWorkshop/2011/Coutts|Spark Visualization in ThreadScope]], Haskell Implementors Workshop 2011
+
Duncan Coutts, Mikolaj Konarski and Andres Loeh, [[HaskellImplementorsWorkshop/2011/Coutts|Spark Visualization in ThreadScope]], Haskell Implementors Workshop 2011
  +
  +
[[Category:ThreadScope]]

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.

Contents

1 Getting Started

Have gtk on your machine? (Note that you don't need all of gtk and gtk2hs, e.g., libxml is unneeded.) See the gtk2hs install instructions (WindowsMacLinux) and then

   cabal update
   gtk-demo
   cabal install gtk
   cabal install threadscope

Next, check out the user guide. We call it the ThreadScope Tour.

2 Features

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

ThreadScope-Screenshot1.png

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:

 ./Wombat +RTS -ls -N2
 threadscope Wombat.eventlog # on Windows: Wombat.exe.eventlog 

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.

For more detailed instructions, have a look at the ThreadScope Tour.

4 Installing ThreadScope

The recommendation is to use the Haskell Platform. This includes GHC and the cabal package tool. At minimum you need GHC-6.12.

ThreadScope itself is available from hackage.

For Windows there is a binary release available: threadscope-0.2.2.zip.

ThreadScope has a dependency on the Haskell Gtk+ binding (Gtk2Hs) which involves a bit of manual work on Windows and Mac OS X to install the Gtk+ C libraries.

See the Gtk2Hs installation instructions for details:

Once you have the Gtk+ C libraries installed it is just a matter of running:

 cabal install threadscope

You can now try to run ThreadScope to make sure it built correctly by viewing a built-in sample trace:

 threadscope --test ch8

You should see something like ThreadScope-ch8.png

5 More Information

Please send comments, corrections etc. to satnams@microsoft.com

You may also wish to join the parallel-haskell google group.

6 Development and reporting bugs

There is a bug tracker and developer wiki.

The source for ghc-events and threadscope is available:

   darcs get http://code.haskell.org/ghc-events/
   darcs get http://code.haskell.org/ThreadScope/

7 People

8 Publications and Talks

Simon Marlow, Simon Peyton Jones, and Satnam Singh, Runtime Support for Multicore Haskell, in ICFP 2009, Association for Computing Machinery, Inc., 5 September 2009

Don Jones Jr., Simon Marlow, and Satnam Singh, Parallel Performance Tuning for Haskell, in ACM SIGPLAN 2009 Haskell Symposium, Association for Computing Machinery, Inc., 3 September 2009

Duncan Coutts, Mikolaj Konarski and Andres Loeh, Spark Visualization in ThreadScope, Haskell Implementors Workshop 2011