Merge non-moving garbage collector
[ghc.git] / rts / Stats.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2005
4 *
5 * Statistics and timing-related functions.
6 *
7 * ---------------------------------------------------------------------------*/
8
9 #pragma once
10
11 #include "GetTime.h"
12 #include "sm/GC.h"
13 #include "Sparks.h"
14
15 #include "BeginPrivate.h"
16
17 #if defined(mingw32_HOST_OS)
18 /* On Win64, if we say "printf" then gcc thinks we are going to use
19 MS format specifiers like %I64d rather than %llu */
20 #define PRINTF gnu_printf
21 #else
22 /* However, on OS X, "gnu_printf" isn't recognised */
23 #define PRINTF printf
24 #endif
25
26 struct gc_thread_;
27
28 void stat_startInit(void);
29 void stat_endInit(void);
30
31 void stat_startGCSync(struct gc_thread_ *_gct);
32 void stat_startGC(Capability *cap, struct gc_thread_ *_gct);
33 void stat_endGC (Capability *cap, struct gc_thread_ *_gct, W_ live,
34 W_ copied, W_ slop, uint32_t gen, uint32_t n_gc_threads,
35 W_ par_max_copied, W_ par_balanced_copied,
36 W_ gc_spin_spin, W_ gc_spin_yield, W_ mut_spin_spin,
37 W_ mut_spin_yield, W_ any_work, W_ no_work,
38 W_ scav_find_work);
39
40 #if defined(PROFILING)
41 void stat_startRP(void);
42 void stat_endRP(uint32_t, int, double);
43 #endif /* PROFILING */
44
45 #if defined(PROFILING) || defined(DEBUG)
46 void stat_startHeapCensus(void);
47 void stat_endHeapCensus(void);
48 #endif
49
50 void stat_startExit(void);
51 void stat_endExit(void);
52
53 void stat_exit(void);
54 void stat_workerStop(void);
55
56 void initStats0(void);
57 void initStats1(void);
58 void resetChildProcessStats(void);
59
60 double mut_user_time_until(Time t);
61 double mut_user_time(void);
62
63 void statDescribeGens( void );
64
65 Time stat_getElapsedGCTime(void);
66 Time stat_getElapsedTime(void);
67
68 typedef struct GenerationSummaryStats_ {
69 uint32_t collections;
70 uint32_t par_collections;
71 Time cpu_ns;
72 Time elapsed_ns;
73 Time max_pause_ns;
74 Time avg_pause_ns;
75 #if defined(THREADED_RTS) && defined(PROF_SPIN)
76 uint64_t sync_spin;
77 uint64_t sync_yield;
78 #endif
79 } GenerationSummaryStats;
80
81 typedef struct RTSSummaryStats_ {
82 // These profiling times could potentially be in RTSStats. However, I'm not
83 // confident enough to do this now, since there is some logic depending on
84 // global state that I do not understand. (Or if I do understand it, it's
85 // wrong)
86 Time rp_cpu_ns;
87 Time rp_elapsed_ns;
88 Time hc_cpu_ns;
89 Time hc_elapsed_ns;
90
91 Time exit_cpu_ns;
92 Time exit_elapsed_ns;
93
94 #if defined(THREADED_RTS)
95 uint32_t bound_task_count;
96 uint64_t sparks_count;
97 SparkCounters sparks;
98 double work_balance;
99 #else // THREADED_RTS
100 double gc_cpu_percent;
101 double gc_elapsed_percent;
102 #endif
103 uint64_t fragmentation_bytes;
104 uint64_t average_bytes_used; // This is not shown in the '+RTS -s' report
105 uint64_t alloc_rate;
106 double productivity_cpu_percent;
107 double productivity_elapsed_percent;
108
109 // one for each generation, 0 first
110 GenerationSummaryStats* gc_summary_stats;
111 } RTSSummaryStats;
112
113 #include "EndPrivate.h"