Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_verbose_old_events/VerboseEventConcurrentStart.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 "VerboseEventConcurrentStart.hpp"
25
#include "GCExtensions.hpp"
26
#include "VerboseEventStream.hpp"
27
#include "VerboseManagerOld.hpp"
28
29
/**
30
* Create an new instance of a MM_VerboseEventConcurrentStart event.
31
* @param event Pointer to a structure containing the data passed over the hookInterface
32
*/
33
MM_VerboseEvent *
34
MM_VerboseEventConcurrentStart::newInstance(MM_ConcurrentCollectionStartEvent *event, J9HookInterface** hookInterface)
35
{
36
MM_VerboseEventConcurrentStart *eventObject;
37
38
eventObject = (MM_VerboseEventConcurrentStart *)MM_VerboseEvent::create(event->currentThread, sizeof(MM_VerboseEventConcurrentStart));
39
if(NULL != eventObject) {
40
new(eventObject) MM_VerboseEventConcurrentStart(event, hookInterface);
41
eventObject->initialize();
42
}
43
return eventObject;
44
}
45
46
/**
47
* Populate events data fields.
48
* The event calls the event stream requesting the address of events it is interested in.
49
* When an address is returned it populates itself with the data.
50
*/
51
void
52
MM_VerboseEventConcurrentStart::consumeEvents(void)
53
{
54
/* Increment collection count */
55
_manager->incrementConcurrentGCCount();
56
57
/* Consume global data */
58
_lastConTime = _manager->getLastConcurrentGCTime();
59
_conCollectionCount = _manager->getConcurrentGCCount();
60
}
61
62
/**
63
* Passes a format string and data to the output routine defined in the passed output agent.
64
* @param agent Pointer to an output agent.
65
*/
66
void
67
MM_VerboseEventConcurrentStart::formattedOutput(MM_VerboseOutputAgent *agent)
68
{
69
OMRPORT_ACCESS_FROM_OMRVMTHREAD(_omrThread);
70
char timestamp[32];
71
UDATA indentLevel = _manager->getIndentLevel();
72
U_64 timeInMicroSeconds;
73
U_64 prevTime;
74
const char* cardCleaningReasonString = "";
75
76
omrstr_ftime(timestamp, sizeof(timestamp), VERBOSEGC_DATE_FORMAT, _timeInMilliSeconds);
77
78
if (1 == _conCollectionCount) {
79
prevTime = _manager->getInitializedTime();
80
} else {
81
prevTime = _lastConTime;
82
}
83
timeInMicroSeconds = omrtime_hires_delta(prevTime, _time, J9PORT_TIME_DELTA_IN_MICROSECONDS);
84
85
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<con event=\"collection\" id=\"%zu\" timestamp=\"%s\" intervalms=\"%llu.%03.3llu\">",
86
_conCollectionCount,
87
timestamp,
88
timeInMicroSeconds / 1000,
89
timeInMicroSeconds % 1000
90
);
91
92
_manager->incrementIndent();
93
indentLevel = _manager->getIndentLevel();
94
95
/* output the common GC start info */
96
gcStartFormattedOutput(agent);
97
98
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<stats tracetarget=\"%zu\">", _traceTarget);
99
100
_manager->incrementIndent();
101
indentLevel = _manager->getIndentLevel();
102
103
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<traced total=\"%zu\" mutators=\"%zu\" helpers=\"%zu\" percent=\"%zu\" />",
104
_tracedTotal,
105
_tracedByMutators,
106
_tracedByHelpers,
107
_traceTarget == 0 ? 0 : (UDATA) ( ( (U_64) _tracedTotal * 100) / (U_64) _traceTarget)
108
);
109
110
switch (_cardCleaningReason) {
111
case TRACING_COMPLETED:
112
cardCleaningReasonString = "tracing completed";
113
break;
114
case CARD_CLEANING_THRESHOLD_REACHED:
115
cardCleaningReasonString = "card cleaning threshold reached";
116
break;
117
default:
118
cardCleaningReasonString = "unknown";
119
break;
120
}
121
122
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<cards cleaned=\"%zu\" kickoff=\"%zu\" reason=\"%s\" />",
123
_cardsCleaned,
124
_cardCleaningPhase1Threshold,
125
cardCleaningReasonString
126
);
127
128
if(_workStackOverflowOccured) {
129
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<warning details=\"concurrent work stack overflow\" count=\"%zu\" />", _workStackOverflowCount);
130
}
131
132
if (_extensions->verboseExtensions) {
133
/*
134
* CMVC 119942
135
*
136
* output stats about how many threads were scanned vs. how many were found at kickoff.
137
* The number actually scanned will usually be lower than the number found at kickoff
138
* because attached threads (like the JIT and the GC helper threads) won't typically be
139
* checking for async events
140
*/
141
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<threads kickoff=\"%zu\" scanned=\"%zu\" />", _threadsToScanCount, _threadsScannedCount);
142
}
143
144
_manager->decrementIndent();
145
indentLevel = _manager->getIndentLevel();
146
147
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "</stats>");
148
}
149
150