base-4.18.1.0: Basic libraries

Safe Haskell | Trustworthy
Language | Haskell2010

GHC.Stats

Contents

- Runtime statistics

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: base-4.5.0.0

Synopsis

- data RTSStats = RTSStats {
  - gcs :: Word32
  - major_gcs :: Word32
  - allocated_bytes :: Word64
  - max_live_bytes :: Word64
  - max_large_objects_bytes :: Word64
  - max_compact_bytes :: Word64
  - max_slop_bytes :: Word64
  - max_mem_in_use_bytes :: Word64
  - cumulative_live_bytes :: Word64
  - copied_bytes :: Word64
  - par_copied_bytes :: Word64
  - cumulative_par_max_copied_bytes :: Word64
  - cumulative_par_balanced_copied_bytes :: Word64
  - init_cpu_ns :: RtsTime
  - init_elapsed_ns :: RtsTime
  - mutator_cpu_ns :: RtsTime
  - mutator_elapsed_ns :: RtsTime
  - gc_cpu_ns :: RtsTime
  - gc_elapsed_ns :: RtsTime
  - cpu_ns :: RtsTime
  - elapsed_ns :: RtsTime
  - nonmoving_gc_sync_cpu_ns :: RtsTime
  - nonmoving_gc_sync_elapsed_ns :: RtsTime
  - nonmoving_gc_sync_max_elapsed_ns :: RtsTime
  - nonmoving_gc_cpu_ns :: RtsTime
  - nonmoving_gc_elapsed_ns :: RtsTime
  - nonmoving_gc_max_elapsed_ns :: RtsTime
  - gc :: GCDetails
  }
- data GCDetails = GCDetails {
  - gcdetails_gen :: Word32
  - gcdetails_threads :: Word32
  - gcdetails_allocated_bytes :: Word64
  - gcdetails_live_bytes :: Word64
  - gcdetails_large_objects_bytes :: Word64
  - gcdetails_compact_bytes :: Word64
  - gcdetails_slop_bytes :: Word64
  - gcdetails_mem_in_use_bytes :: Word64
  - gcdetails_copied_bytes :: Word64
  - gcdetails_par_max_copied_bytes :: Word64
  - gcdetails_par_balanced_copied_bytes :: Word64
  - gcdetails_block_fragmentation_bytes :: Word64
  - gcdetails_sync_elapsed_ns :: RtsTime
  - gcdetails_cpu_ns :: RtsTime
  - gcdetails_elapsed_ns :: RtsTime
  - gcdetails_nonmoving_gc_sync_cpu_ns :: RtsTime
  - gcdetails_nonmoving_gc_sync_elapsed_ns :: RtsTime
  }
- type RtsTime = Int64
- getRTSStats :: IO RTSStats
- getRTSStatsEnabled :: IO Bool

# Runtime statistics

data RTSStats Source #

Statistics about runtime activity since the start of the program. This is a mirror of the C `struct RTSStats` in `RtsAPI.h`

Since: base-4.10.0.0

Constructors

RTSStats |

Fields

- gcs :: Word32

  Total number of GCs

- major_gcs :: Word32

  Total number of major (oldest generation) GCs

- allocated_bytes :: Word64

  Total bytes allocated

- max_live_bytes :: Word64

  Maximum live data (including large objects + compact regions) in the heap. Updated after a major GC.

- max_large_objects_bytes :: Word64

  Maximum live data in large objects

- max_compact_bytes :: Word64

  Maximum live data in compact regions

- max_slop_bytes :: Word64

  Maximum slop

- max_mem_in_use_bytes :: Word64

  Maximum memory in use by the RTS

- cumulative_live_bytes :: Word64

  Sum of live bytes across all major GCs. Divided by major_gcs gives the average live data over the lifetime of the program.

- copied_bytes :: Word64

  Sum of copied_bytes across all GCs

- par_copied_bytes :: Word64

  Sum of copied_bytes across all parallel GCs

- cumulative_par_max_copied_bytes :: Word64

  Sum of par_max_copied_bytes across all parallel GCs. Deprecated.

- cumulative_par_balanced_copied_bytes :: Word64

  Sum of par_balanced_copied bytes across all parallel GCs

- init_cpu_ns :: RtsTime

  Total CPU time used by the init phase @since 4.12.0.0

- init_elapsed_ns :: RtsTime

  Total elapsed time used by the init phase @since 4.12.0.0

- mutator_cpu_ns :: RtsTime

  Total CPU time used by the mutator

- mutator_elapsed_ns :: RtsTime

  Total elapsed time used by the mutator

- gc_cpu_ns :: RtsTime

  Total CPU time used by the GC

- gc_elapsed_ns :: RtsTime

  Total elapsed time used by the GC

- cpu_ns :: RtsTime

  Total CPU time (at the previous GC)

- elapsed_ns :: RtsTime

  Total elapsed time (at the previous GC)

- nonmoving_gc_sync_cpu_ns :: RtsTime

  The total CPU time used during the post-mark pause phase of the concurrent nonmoving GC.

- nonmoving_gc_sync_elapsed_ns :: RtsTime

  The total time elapsed during the post-mark pause phase of the concurrent nonmoving GC.

- nonmoving_gc_sync_max_elapsed_ns :: RtsTime

  The maximum elapsed length of any post-mark pause phase of the concurrent nonmoving GC.

- nonmoving_gc_cpu_ns :: RtsTime

  The total CPU time used by the nonmoving GC.

- nonmoving_gc_elapsed_ns :: RtsTime

  The total time elapsed during which there is a nonmoving GC active.

- nonmoving_gc_max_elapsed_ns :: RtsTime

  The maximum time elapsed during any nonmoving GC cycle.

- gc :: GCDetails

  Details about the most recent GC

#### Instances

Instances details

Generic RTSStats Source # |
Instance details Defined in GHC.Stats Associated Types type Rep RTSStats :: Type -> Type Source # Methods from :: RTSStats -> Rep RTSStats x Source # to :: Rep RTSStats x -> RTSStats Source #
Read RTSStats Source # | Since: base-4.10.0.0
Instance details Defined in GHC.Stats Methods readsPrec :: Int -> ReadS RTSStats Source # readList :: ReadS [RTSStats] Source # readPrec :: ReadPrec RTSStats Source # readListPrec :: ReadPrec [RTSStats] Source #
Show RTSStats Source # | Since: base-4.10.0.0
Instance details Defined in GHC.Stats Methods showsPrec :: Int -> RTSStats -> ShowS Source # show :: RTSStats -> String Source # showList :: [RTSStats] -> ShowS Source #
type Rep RTSStats Source # | Since: base-4.15.0.0

Instance details

Defined in GHC.Stats

type Rep RTSStats = D1 ('MetaData "RTSStats" "GHC.Stats" "base" 'False) (C1 ('MetaCons "RTSStats" 'PrefixI 'True) ((((S1 ('MetaSel ('Just "gcs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32) :*: (S1 ('MetaSel ('Just "major_gcs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32) :*: S1 ('MetaSel ('Just "allocated_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) :*: ((S1 ('MetaSel ('Just "max_live_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "max_large_objects_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "max_compact_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "max_slop_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)))) :*: ((S1 ('MetaSel ('Just "max_mem_in_use_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: (S1 ('MetaSel ('Just "cumulative_live_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "copied_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) :*: ((S1 ('MetaSel ('Just "par_copied_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "cumulative_par_max_copied_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "cumulative_par_balanced_copied_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "init_cpu_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime))))) :*: (((S1 ('MetaSel ('Just "init_elapsed_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime) :*: (S1 ('MetaSel ('Just "mutator_cpu_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime) :*: S1 ('MetaSel ('Just "mutator_elapsed_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime))) :*: ((S1 ('MetaSel ('Just "gc_cpu_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime) :*: S1 ('MetaSel ('Just "gc_elapsed_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime)) :*: (S1 ('MetaSel ('Just "cpu_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime) :*: S1 ('MetaSel ('Just "elapsed_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime)))) :*: ((S1 ('MetaSel ('Just "nonmoving_gc_sync_cpu_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime) :*: (S1 ('MetaSel ('Just "nonmoving_gc_sync_elapsed_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime) :*: S1 ('MetaSel ('Just "nonmoving_gc_sync_max_elapsed_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime))) :*: ((S1 ('MetaSel ('Just "nonmoving_gc_cpu_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime) :*: S1 ('MetaSel ('Just "nonmoving_gc_elapsed_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime)) :*: (S1 ('MetaSel ('Just "nonmoving_gc_max_elapsed_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime) :*: S1 ('MetaSel ('Just "gc") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 GCDetails)))))))

data GCDetails Source #

Statistics about a single GC. This is a mirror of the C `struct GCDetails` in `RtsAPI.h`, with the field prefixed with `gc_` to avoid collisions with `RTSStats`.

Constructors

GCDetails |

Fields

- gcdetails_gen :: Word32

  The generation number of this GC

- gcdetails_threads :: Word32

  Number of threads used in this GC

- gcdetails_allocated_bytes :: Word64

  Number of bytes allocated since the previous GC

- gcdetails_live_bytes :: Word64

  Total amount of live data in the heap (includes large + compact data). Updated after every GC. Data in uncollected generations (in minor GCs) are considered live.

- gcdetails_large_objects_bytes :: Word64

  Total amount of live data in large objects

- gcdetails_compact_bytes :: Word64

  Total amount of live data in compact regions

- gcdetails_slop_bytes :: Word64

  Total amount of slop (wasted memory)

- gcdetails_mem_in_use_bytes :: Word64

  Total amount of memory in use by the RTS

- gcdetails_copied_bytes :: Word64

  Total amount of data copied during this GC

- gcdetails_par_max_copied_bytes :: Word64

  In parallel GC, the max amount of data copied by any one thread. Deprecated.

- gcdetails_par_balanced_copied_bytes :: Word64

  In parallel GC, the amount of balanced data copied by all threads

- gcdetails_block_fragmentation_bytes :: Word64

  The amount of memory lost due to block fragmentation in bytes. Block fragmentation is the difference between the amount of blocks retained by the RTS and the blocks that are in use. This occurs when megablocks are only sparsely used, eg, when data that cannot be moved retains a megablock.

  Since: base-4.18.0.0

- gcdetails_sync_elapsed_ns :: RtsTime

  The time elapsed during synchronisation before GC

- gcdetails_cpu_ns :: RtsTime

  The CPU time used during GC itself

- gcdetails_elapsed_ns :: RtsTime

  The time elapsed during GC itself

- gcdetails_nonmoving_gc_sync_cpu_ns :: RtsTime

  The CPU time used during the post-mark pause phase of the concurrent nonmoving GC.

- gcdetails_nonmoving_gc_sync_elapsed_ns :: RtsTime

  The time elapsed during the post-mark pause phase of the concurrent nonmoving GC.

#### Instances

Instances details

Generic GCDetails Source # |
Instance details Defined in GHC.Stats Associated Types type Rep GCDetails :: Type -> Type Source # Methods from :: GCDetails -> Rep GCDetails x Source # to :: Rep GCDetails x -> GCDetails Source #
Read GCDetails Source # | Since: base-4.10.0.0
Instance details Defined in GHC.Stats Methods readsPrec :: Int -> ReadS GCDetails Source # readList :: ReadS [GCDetails] Source # readPrec :: ReadPrec GCDetails Source # readListPrec :: ReadPrec [GCDetails] Source #
Show GCDetails Source # | Since: base-4.10.0.0
Instance details Defined in GHC.Stats Methods showsPrec :: Int -> GCDetails -> ShowS Source # show :: GCDetails -> String Source # showList :: [GCDetails] -> ShowS Source #
type Rep GCDetails Source # | Since: base-4.15.0.0

Instance details

Defined in GHC.Stats

type Rep GCDetails = D1 ('MetaData "GCDetails" "GHC.Stats" "base" 'False) (C1 ('MetaCons "GCDetails" 'PrefixI 'True) ((((S1 ('MetaSel ('Just "gcdetails_gen") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32) :*: S1 ('MetaSel ('Just "gcdetails_threads") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32)) :*: (S1 ('MetaSel ('Just "gcdetails_allocated_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "gcdetails_live_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) :*: ((S1 ('MetaSel ('Just "gcdetails_large_objects_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "gcdetails_compact_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "gcdetails_slop_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "gcdetails_mem_in_use_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)))) :*: (((S1 ('MetaSel ('Just "gcdetails_copied_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "gcdetails_par_max_copied_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "gcdetails_par_balanced_copied_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "gcdetails_block_fragmentation_bytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) :*: ((S1 ('MetaSel ('Just "gcdetails_sync_elapsed_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime) :*: S1 ('MetaSel ('Just "gcdetails_cpu_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime)) :*: (S1 ('MetaSel ('Just "gcdetails_elapsed_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime) :*: (S1 ('MetaSel ('Just "gcdetails_nonmoving_gc_sync_cpu_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime) :*: S1 ('MetaSel ('Just "gcdetails_nonmoving_gc_sync_elapsed_ns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RtsTime)))))))

type RtsTime = Int64 Source #

Time values from the RTS, using a fixed resolution of nanoseconds.

getRTSStats :: IO RTSStats Source #

Get current runtime system statistics.

Since: base-4.10.0.0

getRTSStatsEnabled :: IO Bool Source #

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

Since: base-4.10.0.0