I am trying to understand the meaning of the GHC profiler. There is a fairly simple application that uses the werq and lens-aeson , and while studying GHC profiling, I decided to play a little with it.
Using various parameters ( time tool, +RTS -p -RTS and +RTS -p -h ), I acquired completely different amounts of memory usage. Having all these numbers, Iβm now completely lost, trying to understand what is happening and how much memory the application actually uses.
This situation reminds me of Arthur Blochβs phrase: βA man with a clock knows what it is. A man with a two clock is never sure.β
Can you please suggest me how I can read all these numbers and what is the meaning of each of them.
Here are the numbers:
time -l reports 19M
#/usr/bin/time -l ./simple-wreq ... 3.02 real 0.39 user 0.17 sys 19070976 maximum resident set size 0 average shared memory size 0 average unshared data size 0 average unshared stack size 21040 page reclaims 0 page faults 0 swaps 0 block input operations 0 block output operations 71 messages sent 71 messages received 2991 signals received 43 voluntary context switches 6490 involuntary context switches
Using the +RTS -p -RTS flag +RTS -p -RTS reports 92M . Although he says "total alloc", it seems strange to me that a simple application like this can allocate and release 91M
# ./simple-wreq +RTS -p -RTS
+RTS -p -h and hp2ps show me the following image and two numbers: 114K in the header and something around 1.8Mb on the graph. 
And, just in case, here is the application:
module Main where import Network.Wreq import Control.Lens import Data.Aeson.Lens import Control.Monad main :: IO () main = replicateM_ 10 g where g = do r <- get "http://httpbin.org/get" print $ r ^. responseBody . key "headers" . key "User-Agent" . _String
UPDATE 1: Thanks everyone for the incredible good reviews. As suggested, I add +RTS -s output, so the whole picture is created for everyone who reads it.
#./simple-wreq +RTS -s ... 128,875,432 bytes allocated in the heap 32,414,616 bytes copied during GC 2,394,888 bytes maximum residency (16 sample(s)) 355,192 bytes maximum slop 7 MB total memory in use (0 MB lost due to fragmentation) Tot time (elapsed) Avg pause Max pause Gen 0 194 colls, 0 par 0.018s 0.022s 0.0001s 0.0022s Gen 1 16 colls, 0 par 0.027s 0.031s 0.0019s 0.0042s
UPDATE 2 : executable file size: