NonmovingCensus: Emit samples to eventlog
[ghc.git] / rts / eventlog / EventLog.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 2008-2009
4 *
5 * Support for fast binary event logging.
6 *
7 * ---------------------------------------------------------------------------*/
8
9 #pragma once
10
11 #include "rts/EventLogFormat.h"
12 #include "rts/EventLogWriter.h"
13 #include "Capability.h"
14 #include "sm/NonMovingCensus.h"
15
16 #include "BeginPrivate.h"
17
18 #if defined(TRACING)
19
20 /*
21 * Descriptions of EventTags for events.
22 */
23 extern char *EventTagDesc[];
24
25 void initEventLogging(const EventLogWriter *writer);
26 void endEventLogging(void);
27 void freeEventLogging(void);
28 void abortEventLogging(void); // #4512 - after fork child needs to abort
29 void flushEventLog(void); // event log inherited from parent
30 void moreCapEventBufs (uint32_t from, uint32_t to);
31
32 /*
33 * Post a scheduler event to the capability's event buffer (an event
34 * that has an associated thread).
35 */
36 void postSchedEvent(Capability *cap, EventTypeNum tag,
37 StgThreadID id, StgWord info1, StgWord info2);
38
39 /*
40 * Post a nullary event.
41 */
42 void postEvent(Capability *cap, EventTypeNum tag);
43 void postEventNoCap(EventTypeNum tag);
44
45 void postEventAtTimestamp (Capability *cap, EventTimestamp ts,
46 EventTypeNum tag);
47
48 void postMsg(char *msg, va_list ap);
49
50 void postUserEvent(Capability *cap, EventTypeNum type, char *msg);
51
52 void postUserBinaryEvent(Capability *cap, EventTypeNum type,
53 uint8_t *msg, size_t size);
54
55 void postCapMsg(Capability *cap, char *msg, va_list ap);
56
57 /*
58 * Post an event relating to a capability itself (create/delete/etc)
59 */
60 void postCapEvent (EventTypeNum tag,
61 EventCapNo capno);
62
63 /*
64 * Post an event that is associated with a capability set
65 */
66 void postCapsetEvent (EventTypeNum tag,
67 EventCapsetID capset,
68 StgWord info);
69
70 /*
71 * Post a capability set event with a string payload
72 */
73 void postCapsetStrEvent (EventTypeNum tag,
74 EventCapsetID capset,
75 char *msg);
76
77 /*
78 * Post a capability set event with several strings payload
79 */
80 void postCapsetVecEvent (EventTypeNum tag,
81 EventCapsetID capset,
82 int argc,
83 char *msg[]);
84
85 void postWallClockTime (EventCapsetID capset);
86
87 /*
88 * Post a `par` spark event
89 */
90 void postSparkEvent(Capability *cap, EventTypeNum tag, StgWord info1);
91
92 /*
93 * Post an event with several counters relating to `par` sparks.
94 */
95 void postSparkCountersEvent (Capability *cap,
96 SparkCounters counters,
97 StgWord remaining);
98
99 /*
100 * Post an event to annotate a thread with a label
101 */
102 void postThreadLabel(Capability *cap,
103 EventThreadID id,
104 char *label);
105
106 /*
107 * Various GC and heap events
108 */
109 void postHeapEvent (Capability *cap,
110 EventTypeNum tag,
111 EventCapsetID heap_capset,
112 W_ info1);
113
114 void postEventHeapInfo (EventCapsetID heap_capset,
115 uint32_t gens,
116 W_ maxHeapSize,
117 W_ allocAreaSize,
118 W_ mblockSize,
119 W_ blockSize);
120
121 void postEventGcStats (Capability *cap,
122 EventCapsetID heap_capset,
123 uint32_t gen,
124 W_ copied,
125 W_ slop,
126 W_ fragmentation,
127 uint32_t par_n_threads,
128 W_ par_max_copied,
129 W_ par_tot_copied,
130 W_ par_balanced_copied);
131
132 void postTaskCreateEvent (EventTaskId taskId,
133 EventCapNo cap,
134 EventKernelThreadId tid);
135
136 void postTaskMigrateEvent (EventTaskId taskId,
137 EventCapNo capno,
138 EventCapNo new_capno);
139
140 void postTaskDeleteEvent (EventTaskId taskId);
141
142 void postHeapProfBegin(StgWord8 profile_id);
143
144 void postHeapProfSampleBegin(StgInt era);
145
146 void postHeapProfSampleString(StgWord8 profile_id,
147 const char *label,
148 StgWord64 residency);
149
150 #if defined(PROFILING)
151 void postHeapProfCostCentre(StgWord32 ccID,
152 const char *label,
153 const char *module,
154 const char *srcloc,
155 StgBool is_caf);
156
157 void postHeapProfSampleCostCentre(StgWord8 profile_id,
158 CostCentreStack *stack,
159 StgWord64 residency);
160 #endif /* PROFILING */
161
162 void postConcUpdRemSetFlush(Capability *cap);
163 void postConcMarkEnd(StgWord32 marked_obj_count);
164 void postNonmovingHeapCensus(int log_blk_size,
165 const struct NonmovingAllocCensus *census);
166
167 #else /* !TRACING */
168
169 INLINE_HEADER void postSchedEvent (Capability *cap STG_UNUSED,
170 EventTypeNum tag STG_UNUSED,
171 StgThreadID id STG_UNUSED,
172 StgWord info1 STG_UNUSED,
173 StgWord info2 STG_UNUSED)
174 { /* nothing */ }
175
176 INLINE_HEADER void postEvent (Capability *cap STG_UNUSED,
177 EventTypeNum tag STG_UNUSED)
178 { /* nothing */ }
179
180 INLINE_HEADER void postEventNoCap (EventTypeNum tag STG_UNUSED)
181 { /* nothing */ }
182
183 INLINE_HEADER void postMsg (char *msg STG_UNUSED,
184 va_list ap STG_UNUSED)
185 { /* nothing */ }
186
187 INLINE_HEADER void postCapMsg (Capability *cap STG_UNUSED,
188 char *msg STG_UNUSED,
189 va_list ap STG_UNUSED)
190 { /* nothing */ }
191
192
193 INLINE_HEADER void postThreadLabel(Capability *cap STG_UNUSED,
194 EventThreadID id STG_UNUSED,
195 char *label STG_UNUSED)
196 { /* nothing */ }
197
198 #endif
199
200 #include "EndPrivate.h"