[Git][ghc/ghc][wip/andreask/allocCounter_docs] Update `setAllocationCounter` docs.
Andreas Klebinger
gitlab at gitlab.haskell.org
Sun Jun 7 10:27:06 UTC 2020
Andreas Klebinger pushed to branch wip/andreask/allocCounter_docs at Glasgow Haskell Compiler / GHC
Commits:
6e27a72d by Andreas Klebinger at 2020-06-07T12:26:57+02:00
Update `setAllocationCounter` docs.
Unlike the old docs implied the counter might not be initialized to
zero. This was in particular true when executed in an interpreted
context. See #16012.
I changed to docs to make no guarantees about specific initialization
values which fixes #16012.
- - - - -
1 changed file:
- libraries/base/GHC/Conc/Sync.hs
Changes:
=====================================
libraries/base/GHC/Conc/Sync.hs
=====================================
@@ -173,11 +173,12 @@ instance Ord ThreadId where
_ -> GT
-- | Every thread has an allocation counter that tracks how much
--- memory has been allocated by the thread. The counter is
--- initialized to zero, and 'setAllocationCounter' sets the current
--- value. The allocation counter counts *down*, so in the absence of
--- a call to 'setAllocationCounter' its value is the negation of the
--- number of bytes of memory allocated by the thread.
+-- memory has been allocated by the thread. The counter might be
+-- initialized with an arbitrary value >= 0 by GHC.
+-- 'setAllocationCounter' sets the current value.
+-- The allocation counter counts *down*.
+-- If initialized to zero a call to 'setAllocationCounter' reports
+-- the negation of the number of bytes of memory allocated by the thread.
--
-- There are two things that you can do with this counter:
--
@@ -186,7 +187,9 @@ instance Ord ThreadId where
--
-- * Use it as a resource limit. See 'enableAllocationLimit'.
--
--- Allocation accounting is accurate only to about 4Kbytes.
+-- Allocation accounting is accurate only to about 4Kbytes. Without
+-- initialization results are only meaningful if compared to the results
+-- of other invocations on the same thread.
--
-- @since 4.8.0.0
setAllocationCounter :: Int64 -> IO ()
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6e27a72ddd395c927d2724a246de67046a0046e3
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6e27a72ddd395c927d2724a246de67046a0046e3
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200607/f8ae4a51/attachment-0001.html>
More information about the ghc-commits
mailing list