summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Profiling.hs
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2020-12-07 13:19:28 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2021-03-01 10:13:22 +0000
commitce5098decf4a2bfaf82911df510738e45347ed14 (patch)
treeb9ea9e60f38520f7dc61887532dab0b8f3bba357 /libraries/base/GHC/Profiling.hs
parent915daf51357175fcc31a37c0aaf2347875560269 (diff)
downloadhaskell-wip/ghc-dynamic-census.tar.gz
Profiling: Allow heap profiling to be controlled dynamically.wip/ghc-dynamic-census
This patch exposes three new functions in `GHC.Profiling` which allow heap profiling to be enabled and disabled dynamically. 1. startHeapProfTimer - Starts heap profiling with the given RTS options 2. stopHeapProfTimer - Stops heap profiling 3. requestHeapCensus - Perform a heap census on the next context switch, regardless of whether the timer is enabled or not.
Diffstat (limited to 'libraries/base/GHC/Profiling.hs')
-rw-r--r--libraries/base/GHC/Profiling.hs32
1 files changed, 31 insertions, 1 deletions
diff --git a/libraries/base/GHC/Profiling.hs b/libraries/base/GHC/Profiling.hs
index 917a208b30..b7cef2fecd 100644
--- a/libraries/base/GHC/Profiling.hs
+++ b/libraries/base/GHC/Profiling.hs
@@ -2,7 +2,14 @@
{-# LANGUAGE NoImplicitPrelude #-}
-- | @since 4.7.0.0
-module GHC.Profiling where
+module GHC.Profiling ( -- * Cost Centre Profiling
+ startProfTimer
+ , stopProfTimer
+ -- * Heap Profiling
+ , startHeapProfTimer
+ , stopHeapProfTimer
+ , requestHeapCensus
+ )where
import GHC.Base
@@ -17,3 +24,26 @@ foreign import ccall stopProfTimer :: IO ()
--
-- @since 4.7.0.0
foreign import ccall startProfTimer :: IO ()
+
+-- | Request a heap census on the next context switch. The census can be
+-- requested whether or not the heap profiling timer is running.
+-- Note: This won't do anything unless you also specify a profiling mode on the
+-- command line using the normal RTS options.
+--
+-- @since 4.16.0.0
+foreign import ccall requestHeapCensus :: IO ()
+
+-- | Start heap profiling. This is called normally by the RTS on start-up,
+-- but can be disabled using the rts flag `--no-automatic-heap-samples`
+-- Note: This won't do anything unless you also specify a profiling mode on the
+-- command line using the normal RTS options.
+--
+-- @since 4.16.0.0
+foreign import ccall startHeapProfTimer :: IO ()
+
+-- | Stop heap profiling.
+-- Note: This won't do anything unless you also specify a profiling mode on the
+-- command line using the normal RTS options.
+--
+-- @since 4.16.0.0
+foreign import ccall stopHeapProfTimer :: IO ()