Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_verbose_old_events/VerboseEventGCStart.cpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2014 IBM Corp. and others
4
*
5
* This program and the accompanying materials are made available under
6
* the terms of the Eclipse Public License 2.0 which accompanies this
7
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
8
* or the Apache License, Version 2.0 which accompanies this distribution and
9
* is available at https://www.apache.org/licenses/LICENSE-2.0.
10
*
11
* This Source Code may also be made available under the following
12
* Secondary Licenses when the conditions for such availability set
13
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
14
* General Public License, version 2 with the GNU Classpath
15
* Exception [1] and GNU General Public License, version 2 with the
16
* OpenJDK Assembly Exception [2].
17
*
18
* [1] https://www.gnu.org/software/classpath/license.html
19
* [2] http://openjdk.java.net/legal/assembly-exception.html
20
*
21
* 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
22
*******************************************************************************/
23
24
#include "VerboseEventGCStart.hpp"
25
#include "GCExtensions.hpp"
26
#include "VerboseEventStream.hpp"
27
#include "VerboseManagerOld.hpp"
28
29
void
30
MM_VerboseEventGCStart::initialize(void)
31
{
32
OMRPORT_ACCESS_FROM_OMRVMTHREAD(_omrThread);
33
_timeInMilliSeconds = omrtime_current_time_millis();
34
}
35
36
37
/**
38
* Output common data for the every GC start event. This method is expected
39
* be to invoked by subclasses from their formattedOutput routines
40
*
41
* @param agent Pointer to an output agent.
42
*/
43
void
44
MM_VerboseEventGCStart::gcStartFormattedOutput(MM_VerboseOutputAgent *agent)
45
{
46
OMRPORT_ACCESS_FROM_OMRVMTHREAD(_omrThread);
47
UDATA indentLevel = _manager->getIndentLevel();
48
49
U_64 exclusiveAccessTimeMicros = omrtime_hires_delta(0, _gcStartData.exclusiveAccessTime, J9PORT_TIME_DELTA_IN_MICROSECONDS);
50
U_64 meanExclusiveAccessIdleTimeMicros = omrtime_hires_delta(0, _gcStartData.meanExclusiveAccessIdleTime, J9PORT_TIME_DELTA_IN_MICROSECONDS);
51
52
char* threadName = getOMRVMThreadName(_gcStartData.lastResponder);
53
char escapedThreadName[64];
54
55
escapeXMLString(OMRPORTLIB, escapedThreadName, sizeof(escapedThreadName), threadName, strlen(threadName));
56
releaseOMRVMThreadName(_gcStartData.lastResponder);
57
58
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<time exclusiveaccessms=\"%llu.%03.3llu\" meanexclusiveaccessms=\"%llu.%03.3llu\" threads=\"%zu\" lastthreadtid=\"0x%p\" lastthreadname=\"%s\" />",
59
exclusiveAccessTimeMicros / 1000,
60
exclusiveAccessTimeMicros % 1000,
61
meanExclusiveAccessIdleTimeMicros / 1000,
62
meanExclusiveAccessIdleTimeMicros % 1000,
63
_gcStartData.haltedThreads,
64
_gcStartData.lastResponder->_language_vmthread,
65
escapedThreadName
66
);
67
if(_gcStartData.beatenByOtherThread) {
68
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<warning details=\"gc start was delayed by previous garbage collections\" />");
69
}
70
71
if(_extensions->verboseExtensions) {
72
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<rememberedset count=\"%zu\" />",
73
_gcStartData.commonData.rememberedSetCount
74
);
75
}
76
77
if(static_cast<J9VMThread*>(_omrThread->_language_vmthread)->javaVM->memoryManagerFunctions->j9gc_scavenger_enabled(static_cast<J9VMThread*>(_omrThread->_language_vmthread)->javaVM)) {
78
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<nursery freebytes=\"%zu\" totalbytes=\"%zu\" percent=\"%zu\" />",
79
_gcStartData.commonData.nurseryFreeBytes,
80
_gcStartData.commonData.nurseryTotalBytes,
81
(UDATA) ( ( (U_64) _gcStartData.commonData.nurseryFreeBytes * 100) / (U_64) _gcStartData.commonData.nurseryTotalBytes)
82
);
83
}
84
85
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<tenured freebytes=\"%zu\" totalbytes=\"%zu\" percent=\"%zu\" %s>",
86
_gcStartData.commonData.tenureFreeBytes,
87
_gcStartData.commonData.tenureTotalBytes,
88
(UDATA) ( ( (U_64) _gcStartData.commonData.tenureFreeBytes * 100) / (U_64) _gcStartData.commonData.tenureTotalBytes),
89
hasDetailedTenuredOutput() ? "" : "/"
90
);
91
92
if (hasDetailedTenuredOutput()) {
93
_manager->incrementIndent();
94
loaFormattedOutput(agent);
95
tlhFormattedOutput(agent);
96
_manager->decrementIndent();
97
98
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "</tenured>");
99
}
100
101
}
102
103
/**
104
* Returns true if there are subclauses to the <tenured> clause, or
105
* false if the <tenured> clause can stand alone
106
*/
107
bool
108
MM_VerboseEventGCStart::hasDetailedTenuredOutput()
109
{
110
/* if verbose extensions is on, then tlh and nontlh data will be output */
111
if (_extensions->verboseExtensions) {
112
return true;
113
}
114
115
#if defined(J9VM_GC_LARGE_OBJECT_AREA)
116
if (_gcStartData.commonData.loaEnabled) {
117
return true;
118
}
119
#endif /* J9VM_GC_LARGE_OBJECT_AREA */
120
121
return false;
122
}
123
124
/**
125
* Output details about TLH and non-TLH allocates for the <tenured> clause.
126
* This output is only enabled if -Xgc:verboseExtensions is specified on the
127
* command line
128
*/
129
void
130
MM_VerboseEventGCStart::tlhFormattedOutput(MM_VerboseOutputAgent *agent)
131
{
132
if (_extensions->verboseExtensions) {
133
UDATA indentLevel = _manager->getIndentLevel();
134
135
#if defined(J9VM_GC_THREAD_LOCAL_HEAP)
136
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<tlh alloccount=\"%zu\" allocbytes=\"%zu\" requestedbytes=\"%zu\" /> ",
137
_gcStartData.tlhAllocCount,
138
_gcStartData.tlhAllocBytes,
139
_gcStartData.tlhRequestedBytes
140
);
141
#endif
142
143
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<nontlh alloccount=\"%zu\" allocbytes=\"%zu\" />",
144
_gcStartData.nonTlhAllocCount,
145
_gcStartData.nonTlhAllocBytes
146
);
147
}
148
}
149
150
/**
151
* Output details about LOA and SOA spaces for the <tenured> clause.
152
* This output is only enabled if LOAs are enabled
153
*/
154
void
155
MM_VerboseEventGCStart::loaFormattedOutput(MM_VerboseOutputAgent *agent)
156
{
157
#if defined(J9VM_GC_LARGE_OBJECT_AREA)
158
if (_gcStartData.commonData.loaEnabled) {
159
UDATA indentLevel = _manager->getIndentLevel();
160
UDATA tenureSOATotalBytes = _gcStartData.commonData.tenureTotalBytes - _gcStartData.commonData.tenureLOATotalBytes;
161
UDATA tenureSOAFreeBytes = _gcStartData.commonData.tenureFreeBytes - _gcStartData.commonData.tenureLOAFreeBytes;
162
163
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<soa freebytes=\"%zu\" totalbytes=\"%zu\" percent=\"%zu\" />",
164
tenureSOAFreeBytes,
165
tenureSOATotalBytes,
166
(UDATA) ( ( (U_64) tenureSOAFreeBytes * 100) / (U_64) tenureSOATotalBytes)
167
);
168
169
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<loa freebytes=\"%zu\" totalbytes=\"%zu\" percent=\"%zu\" />",
170
_gcStartData.commonData.tenureLOAFreeBytes,
171
_gcStartData.commonData.tenureLOATotalBytes,
172
( _gcStartData.commonData.tenureLOATotalBytes == 0 ? 0 : (UDATA) ( ( (U_64) _gcStartData.commonData.tenureLOAFreeBytes * 100) / (U_64) _gcStartData.commonData.tenureLOATotalBytes))
173
);
174
}
175
#endif /* J9VM_GC_LARGE_OBJECT_AREA*/
176
}
177
178