Enable two-step allocator on FreeBSD
[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,
43 #if defined(DEBUG_RETAINER)
44 uint32_t, int,
45 #endif
46 double);
47 #endif /* PROFILING */
48
49 #if defined(PROFILING) || defined(DEBUG)
50 void stat_startHeapCensus(void);
51 void stat_endHeapCensus(void);
52 #endif
53
54 void stat_startExit(void);
55 void stat_endExit(void);
56
57 void stat_exit(void);
58 void stat_workerStop(void);
59
60 void initStats0(void);
61 void initStats1(void);
62
63 double mut_user_time_until(Time t);
64 double mut_user_time(void);
65
66 void statDescribeGens( void );
67
68 Time stat_getElapsedGCTime(void);
69 Time stat_getElapsedTime(void);
70
71 typedef struct GenerationSummaryStats_ {
72 uint32_t collections;
73 uint32_t par_collections;
74 Time cpu_ns;
75 Time elapsed_ns;
76 Time max_pause_ns;
77 Time avg_pause_ns;
78 #if defined(THREADED_RTS) && defined(PROF_SPIN)
79 uint64_t sync_spin;
80 uint64_t sync_yield;
81 #endif
82 } GenerationSummaryStats;
83
84 typedef struct RTSSummaryStats_ {
85 // These profiling times could potentially be in RTSStats. However, I'm not
86 // confident enough to do this now, since there is some logic depending on
87 // global state that I do not understand. (Or if I do understand it, it's
88 // wrong)
89 Time rp_cpu_ns;
90 Time rp_elapsed_ns;
91 Time hc_cpu_ns;
92 Time hc_elapsed_ns;
93
94 Time exit_cpu_ns;
95 Time exit_elapsed_ns;
96
97 #if defined(THREADED_RTS)
98 uint32_t bound_task_count;
99 uint64_t sparks_count;
100 SparkCounters sparks;
101 double work_balance;
102 #else // THREADED_RTS
103 double gc_cpu_percent;
104 double gc_elapsed_percent;
105 #endif
106 uint64_t fragmentation_bytes;
107 uint64_t average_bytes_used; // This is not shown in the '+RTS -s' report
108 uint64_t alloc_rate;
109 double productivity_cpu_percent;
110 double productivity_elapsed_percent;
111
112 // one for each generation, 0 first
113 GenerationSummaryStats* gc_summary_stats;
114 } RTSSummaryStats;
115
116 #include "EndPrivate.h"