Personal tools

ThreadScope Tour/Profile2

From HaskellWiki

< ThreadScope Tour(Difference between revisions)
Jump to: navigation, search
m (Steps)
(Steps)
 
(One intermediate revision by one user not shown)
Line 6: Line 6:
   
 
<ol style="list-style-type: decimal;">
 
<ol style="list-style-type: decimal;">
<li><p>Build [[sudoku3|Downloads]], generating statistics and a ThreadScope profile</p>
+
<li><p>Build [[ThreadScope_Tour/Downloads|sudoku3]], generating statistics and a ThreadScope profile</p>
 
<pre>rm sudoku3
 
<pre>rm sudoku3
 
ghc -O2 sudoku3.hs -threaded -rtsopts -eventlog
 
ghc -O2 sudoku3.hs -threaded -rtsopts -eventlog
 
./sudoku3 sudoku17.1000.txt +RTS -s -N2 -ls</pre></li>
 
./sudoku3 sudoku17.1000.txt +RTS -s -N2 -ls</pre></li>
<li><p>Examine the statistics, againg focusing on the sparks and timing block</p>
+
<li><p>Examine the statistics, again focusing on the sparks and timing block</p>
 
<pre>SPARKS: 1000 (1000 converted, 0 pruned)
 
<pre>SPARKS: 1000 (1000 converted, 0 pruned)
   

Latest revision as of 15:06, 9 December 2011

[edit] 1 Objectives

Use GHC statistics and ThreadScope to see how changes to code affect performance.

[edit] 2 Steps

  1. Build sudoku3, generating statistics and a ThreadScope profile

    rm sudoku3
    ghc -O2 sudoku3.hs -threaded -rtsopts -eventlog
    ./sudoku3 sudoku17.1000.txt +RTS -s -N2 -ls
  2. Examine the statistics, again focusing on the sparks and timing block

    SPARKS: 1000 (1000 converted, 0 pruned)
    
    INIT  time    0.00s  (  0.01s elapsed)
    MUT   time    3.61s  (  2.17s elapsed)
    GC    time    0.62s  (  0.14s elapsed)
    EXIT  time    0.00s  (  0.00s elapsed)
    Total time    4.23s  (  2.31s elapsed)

    Note the change in total time and notice also that we are now generating a lot more sparks than before (see Parallel and Concurrent Programming in Haskell for details on why)

  3. Now examine the ThreadScope profile for the improved sudoku

    threadscope ./sudoku3.eventlog
  4. At the same time, open the ThreadScope profile for the older sudoku and compare the two profiles. You may need to resize the windows or maybe just switch back and forth one window and another.

    More even distribution of work

[edit] 3 Notes and exercises

  1. Future versions of ThreadScope will allow you to directly compare event logs for two different runs of the same program
  2. If you have more than 2 cores available, what happened when you enable them?