Path: blob/master/runtime/gc_verbose_old_events/VerboseEventGCStart.cpp
5985 views
1/*******************************************************************************2* Copyright (c) 1991, 2014 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* 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 and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*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-exception21*******************************************************************************/2223#include "VerboseEventGCStart.hpp"24#include "GCExtensions.hpp"25#include "VerboseEventStream.hpp"26#include "VerboseManagerOld.hpp"2728void29MM_VerboseEventGCStart::initialize(void)30{31OMRPORT_ACCESS_FROM_OMRVMTHREAD(_omrThread);32_timeInMilliSeconds = omrtime_current_time_millis();33}343536/**37* Output common data for the every GC start event. This method is expected38* be to invoked by subclasses from their formattedOutput routines39*40* @param agent Pointer to an output agent.41*/42void43MM_VerboseEventGCStart::gcStartFormattedOutput(MM_VerboseOutputAgent *agent)44{45OMRPORT_ACCESS_FROM_OMRVMTHREAD(_omrThread);46UDATA indentLevel = _manager->getIndentLevel();4748U_64 exclusiveAccessTimeMicros = omrtime_hires_delta(0, _gcStartData.exclusiveAccessTime, J9PORT_TIME_DELTA_IN_MICROSECONDS);49U_64 meanExclusiveAccessIdleTimeMicros = omrtime_hires_delta(0, _gcStartData.meanExclusiveAccessIdleTime, J9PORT_TIME_DELTA_IN_MICROSECONDS);5051char* threadName = getOMRVMThreadName(_gcStartData.lastResponder);52char escapedThreadName[64];5354escapeXMLString(OMRPORTLIB, escapedThreadName, sizeof(escapedThreadName), threadName, strlen(threadName));55releaseOMRVMThreadName(_gcStartData.lastResponder);5657agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<time exclusiveaccessms=\"%llu.%03.3llu\" meanexclusiveaccessms=\"%llu.%03.3llu\" threads=\"%zu\" lastthreadtid=\"0x%p\" lastthreadname=\"%s\" />",58exclusiveAccessTimeMicros / 1000,59exclusiveAccessTimeMicros % 1000,60meanExclusiveAccessIdleTimeMicros / 1000,61meanExclusiveAccessIdleTimeMicros % 1000,62_gcStartData.haltedThreads,63_gcStartData.lastResponder->_language_vmthread,64escapedThreadName65);66if(_gcStartData.beatenByOtherThread) {67agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<warning details=\"gc start was delayed by previous garbage collections\" />");68}6970if(_extensions->verboseExtensions) {71agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<rememberedset count=\"%zu\" />",72_gcStartData.commonData.rememberedSetCount73);74}7576if(static_cast<J9VMThread*>(_omrThread->_language_vmthread)->javaVM->memoryManagerFunctions->j9gc_scavenger_enabled(static_cast<J9VMThread*>(_omrThread->_language_vmthread)->javaVM)) {77agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<nursery freebytes=\"%zu\" totalbytes=\"%zu\" percent=\"%zu\" />",78_gcStartData.commonData.nurseryFreeBytes,79_gcStartData.commonData.nurseryTotalBytes,80(UDATA) ( ( (U_64) _gcStartData.commonData.nurseryFreeBytes * 100) / (U_64) _gcStartData.commonData.nurseryTotalBytes)81);82}8384agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<tenured freebytes=\"%zu\" totalbytes=\"%zu\" percent=\"%zu\" %s>",85_gcStartData.commonData.tenureFreeBytes,86_gcStartData.commonData.tenureTotalBytes,87(UDATA) ( ( (U_64) _gcStartData.commonData.tenureFreeBytes * 100) / (U_64) _gcStartData.commonData.tenureTotalBytes),88hasDetailedTenuredOutput() ? "" : "/"89);9091if (hasDetailedTenuredOutput()) {92_manager->incrementIndent();93loaFormattedOutput(agent);94tlhFormattedOutput(agent);95_manager->decrementIndent();9697agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "</tenured>");98}99100}101102/**103* Returns true if there are subclauses to the <tenured> clause, or104* false if the <tenured> clause can stand alone105*/106bool107MM_VerboseEventGCStart::hasDetailedTenuredOutput()108{109/* if verbose extensions is on, then tlh and nontlh data will be output */110if (_extensions->verboseExtensions) {111return true;112}113114#if defined(J9VM_GC_LARGE_OBJECT_AREA)115if (_gcStartData.commonData.loaEnabled) {116return true;117}118#endif /* J9VM_GC_LARGE_OBJECT_AREA */119120return false;121}122123/**124* Output details about TLH and non-TLH allocates for the <tenured> clause.125* This output is only enabled if -Xgc:verboseExtensions is specified on the126* command line127*/128void129MM_VerboseEventGCStart::tlhFormattedOutput(MM_VerboseOutputAgent *agent)130{131if (_extensions->verboseExtensions) {132UDATA indentLevel = _manager->getIndentLevel();133134#if defined(J9VM_GC_THREAD_LOCAL_HEAP)135agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<tlh alloccount=\"%zu\" allocbytes=\"%zu\" requestedbytes=\"%zu\" /> ",136_gcStartData.tlhAllocCount,137_gcStartData.tlhAllocBytes,138_gcStartData.tlhRequestedBytes139);140#endif141142agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<nontlh alloccount=\"%zu\" allocbytes=\"%zu\" />",143_gcStartData.nonTlhAllocCount,144_gcStartData.nonTlhAllocBytes145);146}147}148149/**150* Output details about LOA and SOA spaces for the <tenured> clause.151* This output is only enabled if LOAs are enabled152*/153void154MM_VerboseEventGCStart::loaFormattedOutput(MM_VerboseOutputAgent *agent)155{156#if defined(J9VM_GC_LARGE_OBJECT_AREA)157if (_gcStartData.commonData.loaEnabled) {158UDATA indentLevel = _manager->getIndentLevel();159UDATA tenureSOATotalBytes = _gcStartData.commonData.tenureTotalBytes - _gcStartData.commonData.tenureLOATotalBytes;160UDATA tenureSOAFreeBytes = _gcStartData.commonData.tenureFreeBytes - _gcStartData.commonData.tenureLOAFreeBytes;161162agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<soa freebytes=\"%zu\" totalbytes=\"%zu\" percent=\"%zu\" />",163tenureSOAFreeBytes,164tenureSOATotalBytes,165(UDATA) ( ( (U_64) tenureSOAFreeBytes * 100) / (U_64) tenureSOATotalBytes)166);167168agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<loa freebytes=\"%zu\" totalbytes=\"%zu\" percent=\"%zu\" />",169_gcStartData.commonData.tenureLOAFreeBytes,170_gcStartData.commonData.tenureLOATotalBytes,171( _gcStartData.commonData.tenureLOATotalBytes == 0 ? 0 : (UDATA) ( ( (U_64) _gcStartData.commonData.tenureLOAFreeBytes * 100) / (U_64) _gcStartData.commonData.tenureLOATotalBytes))172);173}174#endif /* J9VM_GC_LARGE_OBJECT_AREA*/175}176177178