diff options
author | Simon Marlow <marlowsd@gmail.com> | 2016-11-25 16:45:43 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2016-12-06 15:25:50 +0000 |
commit | 24e6594cc7890babe69b8ba122d171affabad2d1 (patch) | |
tree | 0efef02a3e03787e9e6ee9822cb20efc7d48fec5 /includes/Rts.h | |
parent | eec02ab7c8433465cc8d6be0a8889e7c6a222fb0 (diff) | |
download | haskell-24e6594cc7890babe69b8ba122d171affabad2d1.tar.gz |
Overhaul GC stats
Summary:
Visible API changes:
* The C struct `GCDetails` gives the stats about a single GC. This is
passed to the `gcDone()` callback if one is set via the
RtsConfig. (previously we just passed a collection of values, so this
is more extensible, at the expense of breaking the existing API)
* `RTSStats` gives cumulative stats since the start of the program,
and includes the `GCDetails` for the most recent GC. This struct
can be obtained via `getRTSStats()` (the old `getGCStats()` has been
removed, and `getGCStatsEnabled()` has been renamed to
`getRTSStatsEnabled()`)
Improvements:
* The per-GC stats and cumulative stats are now cleanly separated.
* Inside the RTS we have a top-level `RTSStats` struct to keep all our
stats in, previously this was just a collection of strangely-named
variables. This struct is mostly just copied in `getRTSStats()`, so
the implementation of that function is a lot shorter.
* Types are more consistent. We use a uint64_t byte count for all
memory values, and Time for all time values.
* Names are more consistent. We use a suffix `_bytes` for all byte
counts and `_ns` for all time values.
* We now collect information about the amount of memory in large
objects and compact objects in `GCDetails`. (the latter was the reason
I started doing this patch but it seems to have ballooned a bit!)
* I fixed a bug in the calculation of the elapsed MUT time, and added
an ASSERT to stop the calculations going wrong in the future.
For now I kept the Haskell API in `GHC.Stats` the same, by
impedence-matching with the new API. We could either break that API
and make it match the C API more closely, or we could add a new API
and deprecate the old one. Opinions welcome.
This stuff is very easy to get wrong, and it's hard to test. Reviews
welcome!
Test Plan:
manual testing
validate
Reviewers: bgamari, niteria, austin, ezyang, hvr, erikd, rwbarton, Phyx
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2756
Diffstat (limited to 'includes/Rts.h')
-rw-r--r-- | includes/Rts.h | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/includes/Rts.h b/includes/Rts.h index be81b0d9c7..0599df655c 100644 --- a/includes/Rts.h +++ b/includes/Rts.h @@ -39,6 +39,7 @@ extern "C" { #endif #include "rts/Types.h" +#include "rts/Time.h" #if __GNUC__ >= 3 #define ATTRIBUTE_ALIGNED(n) __attribute__((aligned(n))) @@ -145,38 +146,6 @@ void _assertFail(const char *filename, unsigned int linenum) #define FMT_HexSizeT "zx" /* ----------------------------------------------------------------------------- - Time values in the RTS - -------------------------------------------------------------------------- */ - -// For most time values in the RTS we use a fixed resolution of nanoseconds, -// normalising the time we get from platform-dependent APIs to this -// resolution. -#define TIME_RESOLUTION 1000000000 -typedef StgInt64 Time; - -#define TIME_MAX HS_INT64_MAX - -#if TIME_RESOLUTION == 1000000000 -// I'm being lazy, but it's awkward to define fully general versions of these -#define TimeToUS(t) ((t) / 1000) -#define TimeToNS(t) (t) -#define USToTime(t) ((Time)(t) * 1000) -#define NSToTime(t) ((Time)(t)) -#else -#error Fix TimeToNS(), TimeToUS() etc. -#endif - -#define SecondsToTime(t) ((Time)(t) * TIME_RESOLUTION) -#define TimeToSeconds(t) ((t) / TIME_RESOLUTION) - -// Use instead of SecondsToTime() when we have a floating-point -// seconds value, to avoid truncating it. -INLINE_HEADER Time fsecondsToTime (double t) -{ - return (Time)(t * TIME_RESOLUTION); -} - -/* ----------------------------------------------------------------------------- Include everything STG-ish -------------------------------------------------------------------------- */ |