GHC.Stats

base-4.9.1.0: Basic libraries

Safe Haskell | Trustworthy
Language | Haskell2010

GHC.Stats

Description

This module provides access to internal garbage collection and memory usage statistics. These statistics are not available unless a program is run with the `-T` RTS flag.

This module is GHC-only and should not be considered portable.

Since: 4.5.0.0

Synopsis

- data GCStats = GCStats {
  - bytesAllocated :: !Int64
  - numGcs :: !Int64
  - maxBytesUsed :: !Int64
  - numByteUsageSamples :: !Int64
  - cumulativeBytesUsed :: !Int64
  - bytesCopied :: !Int64
  - currentBytesUsed :: !Int64
  - currentBytesSlop :: !Int64
  - maxBytesSlop :: !Int64
  - peakMegabytesAllocated :: !Int64
  - mutatorCpuSeconds :: !Double
  - mutatorWallSeconds :: !Double
  - gcCpuSeconds :: !Double
  - gcWallSeconds :: !Double
  - cpuSeconds :: !Double
  - wallSeconds :: !Double
  - parTotBytesCopied :: !Int64
  - parMaxBytesCopied :: !Int64
  }
- getGCStats :: IO GCStats
- getGCStatsEnabled :: IO Bool

# Documentation

data GCStats Source #

Statistics about memory usage and the garbage collector. Apart from `currentBytesUsed` and `currentBytesSlop` all are cumulative values since the program started.

Since: 4.5.0.0

Constructors

GCStats |
Fields bytesAllocated :: !Int64 Total number of bytes allocated numGcs :: !Int64 Number of garbage collections performed (any generation, major and minor) maxBytesUsed :: !Int64 Maximum number of live bytes seen so far numByteUsageSamples :: !Int64 Number of byte usage samples taken, or equivalently the number of major GCs performed. cumulativeBytesUsed :: !Int64 Sum of all byte usage samples, can be used with `numByteUsageSamples` to calculate averages with arbitrary weighting (if you are sampling this record multiple times). bytesCopied :: !Int64 Number of bytes copied during GC currentBytesUsed :: !Int64 Number of live bytes at the end of the last major GC currentBytesSlop :: !Int64 Current number of bytes lost to slop maxBytesSlop :: !Int64 Maximum number of bytes lost to slop at any one time so far peakMegabytesAllocated :: !Int64 Maximum number of megabytes allocated mutatorCpuSeconds :: !Double CPU time spent running mutator threads. This does not include any profiling overhead or initialization. mutatorWallSeconds :: !Double Wall clock time spent running mutator threads. This does not include initialization. gcCpuSeconds :: !Double CPU time spent running GC gcWallSeconds :: !Double Wall clock time spent running GC cpuSeconds :: !Double Total CPU time elapsed since program start wallSeconds :: !Double Total wall clock time elapsed since start parTotBytesCopied :: !Int64 Number of bytes copied during GC, minus space held by mutable lists held by the capabilities. Can be used with `parMaxBytesCopied` to determine how well parallel GC utilized all cores. parMaxBytesCopied :: !Int64 Sum of number of bytes copied each GC by the most active GC thread each GC. The ratio of `parTotBytesCopied` divided by `parMaxBytesCopied` approaches 1 for a maximally sequential run and approaches the number of threads (set by the RTS flag `-N`) for a maximally parallel run.

Instances

Read GCStats # |
Methods readsPrec :: Int -> ReadS GCStats Source # readList :: ReadS [GCStats] Source # readPrec :: ReadPrec GCStats Source # readListPrec :: ReadPrec [GCStats] Source #
Show GCStats # |
Methods showsPrec :: Int -> GCStats -> ShowS Source # show :: GCStats -> String Source # showList :: [GCStats] -> ShowS Source #

getGCStats :: IO GCStats Source #

Retrieves garbage collection and memory statistics as of the last garbage collection. If you would like your statistics as recent as possible, first run a `performGC`.

Since: 4.5.0.0

getGCStatsEnabled :: IO Bool Source #

Returns whether GC stats have been enabled (with `+RTS -T`, for example).

Since: 4.6.0.0