Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_verbose_handler_realtime/VerboseHandlerOutputRealtime.hpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2020 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
#if !defined(VERBOSEHANDLEROUTPUTREALTIME_HPP_)
24
#define VERBOSEHANDLEROUTPUTREALTIME_HPP_
25
26
#include "j9.h"
27
#include "j9cfg.h"
28
#include "j9modron.h"
29
#include "mmhook.h"
30
#include "mmprivatehook.h"
31
32
#include "VerboseHandlerOutput.hpp"
33
#include "GCExtensions.hpp"
34
35
class MM_EnvironmentBase;
36
37
class MM_VerboseHandlerOutputRealtime : public MM_VerboseHandlerOutput
38
{
39
private:
40
U_64 _verboseInitTimeStamp;
41
42
/* Data for increments */
43
U_64 _heartbeatStartTime;
44
U_64 _incrementStartTime;
45
46
UDATA _incrementCount;
47
48
U_64 _maxIncrementTime;
49
U_64 _maxIncrementStartTime;
50
U_64 _minIncrementTime;
51
U_64 _totalIncrementTime;
52
53
U_64 _maxHeapFree;
54
U_64 _minHeapFree;
55
U_64 _totalHeapFree;
56
57
UDATA _classLoadersUnloadedTotal; /**< Sum of _classLoadersUnloaded from all events between two heartbeat verbose gc reports */
58
UDATA _classesUnloadedTotal; /**< Sum of _classesUnloaded from all events between two heartbeat verbose gc reports */
59
UDATA _anonymousClassesUnloadedTotal; /**< Sum of _anonymousClassesUnloaded from all events between two heartbeat verbose gc reports */
60
61
UDATA _weakReferenceClearCountTotal; /**< Number of weak references between two heartbeats (total of all quantas) */
62
UDATA _softReferenceClearCountTotal; /**< Number of soft references between two heartbeats (total of all quantas) */
63
UDATA _softReferenceThreshold; /**< the max soft reference threshold */
64
UDATA _dynamicSoftReferenceThreshold; /**< the dynamic soft reference threshold */
65
UDATA _phantomReferenceClearCountTotal; /**< Number of phantom references between two heartbeats (total of all quantas) */
66
67
UDATA _finalizableCountTotal; /**< Number of finalizable objects between two heartbeats (total of all quantas) */
68
69
UDATA _workPacketOverflowCountTotal; /**< Sum of _workPacketCount from all events between two heartbeat verbose gc reports */
70
UDATA _objectOverflowCountTotal; /**< Sum of _objectOverflowCount from all events between two heartbeat verbose gc reports */
71
72
UDATA _nonDeterministicSweepTotal; /**< Number of non deterministic sweeps between two heartbeats (total of all quantas) */
73
UDATA _nonDeterministicSweepConsecutiveMax; /**< The maximum of all longest streaks, between two heartbeats */
74
U_64 _nonDeterministicSweepDelayMax; /**< The longest delay caused by non deterministic sweep among all allocs between two heartbeats */
75
76
U_64 _maxExclusiveAccessTime; /**< The maximum time (of all events of the chain) GC main thread spent stopping mutators */
77
U_64 _minExclusiveAccessTime; /**< The minimum time (of all events of the chain) GC main thread spent stopping mutators */
78
U_64 _totalExclusiveAccessTime; /**< The average time (of all events of the chain) GC main thread spent stopping mutators */
79
80
UDATA _maxStartPriority; /**< The maximum start priority of all increments in the event chain. Only used for the last event in the chain. */
81
UDATA _minStartPriority; /**< The minimum start priority of all increments in the event chain. Only used for the last event in the chain. */
82
83
typedef enum {
84
INACTIVE = 0,
85
PRE_COLLECT,
86
MARK,
87
CLASS_UNLOAD,
88
SWEEP,
89
POST_COLLECT
90
} GCPhase;
91
92
GCPhase _gcPhase; /**< Current GC phase. */
93
GCPhase _previousGCPhase; /**< The GC phase at the start of the current increment. Different from the current gcPhase if current increment spans across more than one gc phase. */
94
95
/* Data for sync GC*/
96
bool _syncGCTriggered; /**< Have we in a sync GC cycle right now? */
97
U_64 _syncGCStartTime; /**< The start time of a sync GC */
98
GCReason _syncGCReason; /**< The code for cause of the sync GC */
99
UDATA _syncGCReasonParameter; /**< Additional info for the sync GC */
100
U_64 _syncGCExclusiveAccessTime; /**< The exclusive access time of a sync GC */
101
UDATA _syncGCStartHeapFree; /**< The free heap at the start of a sync GC */
102
UDATA _syncGCStartImmortalFree; /**< The free immortal space at the start of a sync GC */
103
UDATA _syncGCStartClassLoadersUnloaded; /**< The unloaded class loader count at the start of a sync GC */
104
UDATA _syncGCStartClassesUnloaded; /**< The unloaded class count at the start of a sync GC */
105
UDATA _syncGCStartAnonymousClassesUnloaded; /**< The unloaded anonymous class count at the start of a sync GC */
106
107
protected:
108
J9HookInterface** _mmHooks; /**< Pointers to the Hook interface */
109
110
public:
111
112
private:
113
void resetHeartbeatStats()
114
{
115
_heartbeatStartTime = 0;
116
_incrementStartTime = 0;
117
_incrementCount = 0;
118
_maxIncrementTime = 0;
119
_maxIncrementStartTime = 0;
120
_minIncrementTime = (U_64)-1;
121
_totalIncrementTime = 0;
122
_maxHeapFree = 0;
123
_minHeapFree = (UDATA)-1;
124
_totalHeapFree = 0;
125
_classLoadersUnloadedTotal = 0;
126
_classesUnloadedTotal = 0;
127
_anonymousClassesUnloadedTotal = 0;
128
_weakReferenceClearCountTotal = 0;
129
_softReferenceClearCountTotal = 0;
130
_dynamicSoftReferenceThreshold = 0;
131
_softReferenceThreshold = 0;
132
_phantomReferenceClearCountTotal = 0;
133
_finalizableCountTotal = 0;
134
_workPacketOverflowCountTotal = 0;
135
_objectOverflowCountTotal = 0;
136
_nonDeterministicSweepTotal = 0;
137
_nonDeterministicSweepConsecutiveMax = 0;
138
_nonDeterministicSweepDelayMax = 0;
139
_maxExclusiveAccessTime = 0;
140
_minExclusiveAccessTime = (UDATA)-1;
141
_totalExclusiveAccessTime = 0;
142
_maxStartPriority = 0;
143
_minStartPriority = (UDATA)-1;
144
}
145
146
void resetSyncGCStats()
147
{
148
_syncGCTriggered = false;
149
_syncGCStartTime = 0;
150
_syncGCReason = UNKOWN_REASON;
151
_syncGCReasonParameter = 0;
152
_syncGCExclusiveAccessTime = 0;
153
_syncGCStartHeapFree = 0;
154
_syncGCStartImmortalFree = 0;
155
_syncGCStartClassLoadersUnloaded = 0;
156
_syncGCStartClassesUnloaded = 0;
157
_syncGCStartAnonymousClassesUnloaded = 0;
158
}
159
160
const char *
161
getGCPhaseAsString(GCPhase gcPhase)
162
{
163
switch(gcPhase) {
164
case PRE_COLLECT:
165
return "precollect";
166
case MARK:
167
return "mark";
168
case CLASS_UNLOAD:
169
return "classunload";
170
case SWEEP:
171
return "sweep";
172
case POST_COLLECT:
173
return "postcollect";
174
default:
175
return "unknown";
176
}
177
}
178
179
/**
180
* Answers whether the current increment spans more than one GC phase.
181
*/
182
bool
183
incrementStartsInPreviousGCPhase()
184
{
185
return (_gcPhase != _previousGCPhase);
186
}
187
188
protected:
189
190
/**
191
* Answer a string representation of a given cycle type.
192
* @param[IN] cycle type
193
* @return string representing the human readable "type" of the cycle.
194
*/
195
virtual const char *getCycleType(UDATA type);
196
virtual void outputInitializedInnerStanza(MM_EnvironmentBase *env, MM_VerboseBuffer *buffer);
197
198
MM_VerboseHandlerOutputRealtime(MM_GCExtensions *extensions) :
199
MM_VerboseHandlerOutput(extensions),
200
_verboseInitTimeStamp(0),
201
_heartbeatStartTime(0),
202
_incrementStartTime(0),
203
_incrementCount(0),
204
_maxIncrementTime(0),
205
_maxIncrementStartTime(0),
206
_minIncrementTime((U_64)-1),
207
_totalIncrementTime(0),
208
_maxHeapFree(0),
209
_minHeapFree((UDATA)-1),
210
_totalHeapFree(0),
211
_classLoadersUnloadedTotal(0),
212
_classesUnloadedTotal(0),
213
_anonymousClassesUnloadedTotal(0),
214
_weakReferenceClearCountTotal(0),
215
_softReferenceClearCountTotal(0),
216
_softReferenceThreshold(0),
217
_dynamicSoftReferenceThreshold(0),
218
_phantomReferenceClearCountTotal(0),
219
_finalizableCountTotal(0),
220
_workPacketOverflowCountTotal(0),
221
_objectOverflowCountTotal(0),
222
_nonDeterministicSweepTotal(0),
223
_nonDeterministicSweepConsecutiveMax(0),
224
_nonDeterministicSweepDelayMax(0),
225
_maxExclusiveAccessTime(0),
226
_minExclusiveAccessTime((UDATA)-1),
227
_totalExclusiveAccessTime(0),
228
_maxStartPriority(0),
229
_minStartPriority((UDATA)-1),
230
_gcPhase(INACTIVE),
231
_previousGCPhase(INACTIVE),
232
_syncGCTriggered(false),
233
_syncGCStartTime(0),
234
_syncGCReason(UNKOWN_REASON),
235
_syncGCReasonParameter(0),
236
_syncGCExclusiveAccessTime(0),
237
_syncGCStartHeapFree(0),
238
_syncGCStartImmortalFree(0),
239
_syncGCStartClassLoadersUnloaded(0),
240
_syncGCStartClassesUnloaded(0),
241
_syncGCStartAnonymousClassesUnloaded(0),
242
_mmHooks(NULL)
243
{};
244
245
virtual bool initialize(MM_EnvironmentBase *env, MM_VerboseManager *manager);
246
virtual void tearDown(MM_EnvironmentBase *env);
247
248
virtual bool getThreadName(char *buf, UDATA bufLen, OMR_VMThread *vmThread);
249
virtual void writeVmArgs(MM_EnvironmentBase* env, MM_VerboseBuffer* buffer);
250
251
public:
252
static MM_VerboseHandlerOutput *newInstance(MM_EnvironmentBase *env, MM_VerboseManager *manager);
253
254
void handleCycleStart(J9HookInterface** hook, UDATA eventNum, void* eventData);
255
void handleCycleEnd(J9HookInterface** hook, UDATA eventNum, void* eventData);
256
257
void handleEvent(MM_MetronomeIncrementStartEvent* eventData);
258
void handleEvent(MM_MetronomeIncrementEndEvent* eventData);
259
void handleEvent(MM_MetronomeSynchronousGCStartEvent* eventData);
260
void handleEvent(MM_MetronomeSynchronousGCEndEvent* eventData);
261
void handleEvent(MM_MarkStartEvent* eventData);
262
void handleEvent(MM_MarkEndEvent* eventData);
263
void handleEvent(MM_SweepStartEvent* eventData);
264
void handleEvent(MM_SweepEndEvent* eventData);
265
void handleEvent(MM_ClassUnloadingStartEvent* eventData);
266
void handleEvent(MM_ClassUnloadingEndEvent* eventData);
267
void handleEvent(MM_OutOfMemoryEvent* eventData);
268
void handleEvent(MM_UtilizationTrackerOverflowEvent* eventData);
269
void handleEvent(MM_NonMonotonicTimeEvent* eventData);
270
271
void writeHeartbeatData(MM_EnvironmentBase* env, U_64 timestamp);
272
void writeHeartbeatDataAndResetHeartbeatStats(MM_EnvironmentBase* env, U_64 timestamp);
273
274
virtual void enableVerbose();
275
virtual void disableVerbose();
276
};
277
278
#endif /* VERBOSEHANDLEROUTPUTREALTIME_HPP_ */
279
280