Difference between revisions of "ThreadScope Tour/Profile"

From HaskellWiki
Jump to navigation Jump to search
(paste from pandoc)
 
 
(3 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
Examine a ThreadScope profile on a realistic program
 
Examine a ThreadScope profile on a realistic program
   
[[Image:ThreadScope-sudoku2.png|frame|none|alt=Threadscope on Sudoku2]]
+
[[Image:ThreadScope-sudoku2.png|600px|Threadscope on Sudoku2]]
   
 
== Concepts ==
 
== Concepts ==
   
# HEC - Haskell Execution Context; basically there is one HEC for each core you enable with the RTS option <tt>-N</tt>
+
* HEC - Haskell Execution Context; basically there is one HEC for each core you enable with the RTS option <tt>-N</tt>
   
 
== Steps ==
 
== Steps ==
Line 17: Line 17:
 
./sudoku2 sudoku17.1000.txt +RTS -N2 -ls
 
./sudoku2 sudoku17.1000.txt +RTS -N2 -ls
 
threadscope sudoku2.eventlog</pre></li>
 
threadscope sudoku2.eventlog</pre></li>
<li><p>Examine the activity graph. The dashed horizontal lines provide hints About the amount of activity you might expect. Here for example we are using two cores, which is reflected the line dividing the graph into two pieces.</p>
+
<li><p>Examine the activity graph. The dashed horizontal lines provide hints about the amount of activity you might expect. Here for example we are using two cores, which is reflected the line dividing the graph into two pieces.</p>
[[Image:ThreadScope-sudoku2-activity.png|frame|none|alt=Threadscope activity]]
+
[[Image:ThreadScope-sudoku2-activity.png|Threadscope activity]]
   
 
<p>In the example above, we can see both cores nearly maxed out until around 1.85s at which point the amount of activity drops down to half.</p></li>
 
<p>In the example above, we can see both cores nearly maxed out until around 1.85s at which point the amount of activity drops down to half.</p></li>
 
<li><p>To see how this activity is distributed between cores, have a look at the HECs just below.</p>
 
<li><p>To see how this activity is distributed between cores, have a look at the HECs just below.</p>
[[Image:ThreadScope-sudoku2-hec.png|frame|none|alt=One of the cores stopped working]]
+
[[Image:ThreadScope-sudoku2-hec.png|One of the cores stopped working]]
   
 
<p>It so happens that the reason the activity dropped in half is that one of the cores stopped working.</p></li>
 
<p>It so happens that the reason the activity dropped in half is that one of the cores stopped working.</p></li>
 
</ol>
<li><p>Observe the link between activity and garbage collection.</p>
 
[[Image:ThreadScope-sudoku2-gc.png|frame|none|alt=Activity ceased during garbage collection]]
 
</li></ol>
 
   
 
== Questions and exercises ==
 
== Questions and exercises ==

Latest revision as of 18:09, 9 December 2011

Objectives

Examine a ThreadScope profile on a realistic program

Threadscope on Sudoku2

Concepts

  • HEC - Haskell Execution Context; basically there is one HEC for each core you enable with the RTS option -N

Steps

  1. Build sudoku2 and view its eventlog in ThreadScope

    rm sudoku2
    ghc -O2 sudoku2.hs -threaded -rtsopts -eventlog
    ./sudoku2 sudoku17.1000.txt +RTS -N2 -ls
    threadscope sudoku2.eventlog
  2. Examine the activity graph. The dashed horizontal lines provide hints about the amount of activity you might expect. Here for example we are using two cores, which is reflected the line dividing the graph into two pieces.

    Threadscope activity

    In the example above, we can see both cores nearly maxed out until around 1.85s at which point the amount of activity drops down to half.

  3. To see how this activity is distributed between cores, have a look at the HECs just below.

    One of the cores stopped working

    It so happens that the reason the activity dropped in half is that one of the cores stopped working.

Questions and exercises

  1. What do you think is causing the uneven division between the 2 cores?
  2. If you have more than 2 course available, what happened when you enable them?
  3. Try profiling the k-means example and studying the profile.