Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to interpret Haskell +RTS -s summary output

Tags:

haskell

I've been doing some performance tests on code and found the +RTS -s flag which shows a bunch of metrics on what the program did. But I haven't been able to find a full explanation of how to interpret the output.

I've found some resources on sparks and explaining how they're tasks for the thread pool.

What does Tasks mean?

How do I read the table with INIT, MUT etc?

What does Productivity mean in this context?

10:23:12 decision-tree-haskell $ stack exec -- performance-test +RTS -A200M -N -s
   4,952,803,088 bytes allocated in the heap
       5,277,992 bytes copied during GC
       1,438,264 bytes maximum residency (2 sample(s))
          70,552 bytes maximum slop
             816 MB total memory in use (0 MB lost due to fragmentation)

                                     Tot time (elapsed)  Avg pause  Max pause
  Gen  0        22 colls,    22 par    0.036s   0.011s     0.0005s    0.0058s
  Gen  1         2 colls,     1 par    0.004s   0.001s     0.0006s    0.0010s

  Parallel GC work balance: 8.43% (serial 0%, perfect 100%)

  TASKS: 10 (1 bound, 9 peak workers (9 total), using -N4)

  SPARKS: 48 (48 converted, 0 overflowed, 0 dud, 0 GC'd, 0 fizzled)

  INIT    time    0.009s  (  0.009s elapsed)
  MUT     time    9.846s  (  9.895s elapsed)
  GC      time    0.040s  (  0.013s elapsed)
  EXIT    time    0.001s  (  0.000s elapsed)
  Total   time    9.963s  (  9.916s elapsed)

  Alloc rate    503,030,959 bytes per MUT second

  Productivity  99.5% of total user, 99.8% of total elapsed

gc_alloc_block_sync: 808
whitehole_spin: 0
gen[0].sync: 9
gen[1].sync: 0
like image 705
The Hoff Avatar asked Oct 21 '25 14:10

The Hoff


1 Answers

Have you looked at the GHC user manual?

https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/runtime_control.html#rts-options-to-produce-runtime-statistics

[...] Next there is the CPU time and wall clock time elapsed broken down by what the runtime system was doing at the time. INIT is the runtime system initialisation. MUT is the mutator time, i.e. the time spent actually running your code. GC is the time spent doing garbage collection. RP is the time spent doing retainer profiling. PROF is the time spent doing other profiling. EXIT is the runtime system shutdown time. And finally, Total is, of course, the total.

%GC time tells you what percentage GC is of Total. “Alloc rate” tells you the “bytes allocated in the heap” divided by the MUT CPU time. “Productivity” tells you what percentage of the Total CPU and wall clock elapsed times are spent in the mutator (MUT).

So INIT is how long it took to start up the GHC runtime system, EXIT is how long it took to shut it down, GC is how long the garbage collector ran for, and MUT is how long your actual program was doing useful work.

The "elapsed" time is actual wall-clock time, whereas the first number is CPU time. (If you have, e.g., a 4-core CPU, CPU time might be quite a bit longer than wall time. Unsure how time spent waiting for I/O factors into this.)

For some reason I can't seem to find a quote from the manual, but I believe "productivity" is the percentage of wall-time spent running your code (as opposed to running the garbage collector, waiting for I/O, etc).

like image 126
MathematicalOrchid Avatar answered Oct 23 '25 08:10

MathematicalOrchid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!