Skip to content

rts stats: bytes copied during GC appears broken

@sgraf812 notes in #21741 the following program shows an unreasonably low value for "bytes copied during GC".

Program
{-# LANGUAGE BangPatterns #-}

import System.Environment

f :: [Int] -> Int
f xs = g (length xs) (even $ mySum xs)
{-# NOINLINE f #-}

g :: Int -> Bool -> Int
g 0 _ = 0
g n !b = length xs + mySum xs + if b then 0 else 1
  where
    xs = [0..n]
{-# NOINLINE g #-}

mySum :: [Int] -> Int
mySum = go 0
  where
    go acc (x:xs) = go (x+acc) xs
    go acc _      = acc

main = do
  (n:_) <- map read <$> getArgs
  print $ f [0..n]
RTS stats output
./simpl 10000000 +RTS -s
50000025000003
   1,440,058,976 bytes allocated in the heap
           8,368 bytes copied during GC
     497,755,080 bytes maximum residency (9 sample(s))
      85,244,984 bytes maximum slop
            1133 MiB total memory in use (0 MB lost due to fragmentation)

                                     Tot time (elapsed)  Avg pause  Max pause
  Gen  0       340 colls,     0 par    0.386s   0.386s     0.0011s    0.0038s
  Gen  1         9 colls,     0 par    0.903s   0.903s     0.1004s    0.3653s

  INIT    time    0.000s  (  0.000s elapsed)
  MUT     time    0.198s  (  0.196s elapsed)
  GC      time    1.289s  (  1.289s elapsed)
  EXIT    time    0.000s  (  0.004s elapsed)
  Total   time    1.488s  (  1.490s elapsed)

  %GC     time       0.0%  (0.0% elapsed)

  Alloc rate    7,255,512,961 bytes per MUT second

  Productivity  13.3% of total user, 13.2% of total elapsed
Edited by Sebastian Graf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information