Path: blob/master/runtime/gc_verbose_old_events/VerboseEventConcurrentStart.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 "VerboseEventConcurrentStart.hpp"24#include "GCExtensions.hpp"25#include "VerboseEventStream.hpp"26#include "VerboseManagerOld.hpp"2728/**29* Create an new instance of a MM_VerboseEventConcurrentStart event.30* @param event Pointer to a structure containing the data passed over the hookInterface31*/32MM_VerboseEvent *33MM_VerboseEventConcurrentStart::newInstance(MM_ConcurrentCollectionStartEvent *event, J9HookInterface** hookInterface)34{35MM_VerboseEventConcurrentStart *eventObject;3637eventObject = (MM_VerboseEventConcurrentStart *)MM_VerboseEvent::create(event->currentThread, sizeof(MM_VerboseEventConcurrentStart));38if(NULL != eventObject) {39new(eventObject) MM_VerboseEventConcurrentStart(event, hookInterface);40eventObject->initialize();41}42return eventObject;43}4445/**46* Populate events data fields.47* The event calls the event stream requesting the address of events it is interested in.48* When an address is returned it populates itself with the data.49*/50void51MM_VerboseEventConcurrentStart::consumeEvents(void)52{53/* Increment collection count */54_manager->incrementConcurrentGCCount();5556/* Consume global data */57_lastConTime = _manager->getLastConcurrentGCTime();58_conCollectionCount = _manager->getConcurrentGCCount();59}6061/**62* Passes a format string and data to the output routine defined in the passed output agent.63* @param agent Pointer to an output agent.64*/65void66MM_VerboseEventConcurrentStart::formattedOutput(MM_VerboseOutputAgent *agent)67{68OMRPORT_ACCESS_FROM_OMRVMTHREAD(_omrThread);69char timestamp[32];70UDATA indentLevel = _manager->getIndentLevel();71U_64 timeInMicroSeconds;72U_64 prevTime;73const char* cardCleaningReasonString = "";7475omrstr_ftime(timestamp, sizeof(timestamp), VERBOSEGC_DATE_FORMAT, _timeInMilliSeconds);7677if (1 == _conCollectionCount) {78prevTime = _manager->getInitializedTime();79} else {80prevTime = _lastConTime;81}82timeInMicroSeconds = omrtime_hires_delta(prevTime, _time, J9PORT_TIME_DELTA_IN_MICROSECONDS);8384agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<con event=\"collection\" id=\"%zu\" timestamp=\"%s\" intervalms=\"%llu.%03.3llu\">",85_conCollectionCount,86timestamp,87timeInMicroSeconds / 1000,88timeInMicroSeconds % 100089);9091_manager->incrementIndent();92indentLevel = _manager->getIndentLevel();9394/* output the common GC start info */95gcStartFormattedOutput(agent);9697agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<stats tracetarget=\"%zu\">", _traceTarget);9899_manager->incrementIndent();100indentLevel = _manager->getIndentLevel();101102agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<traced total=\"%zu\" mutators=\"%zu\" helpers=\"%zu\" percent=\"%zu\" />",103_tracedTotal,104_tracedByMutators,105_tracedByHelpers,106_traceTarget == 0 ? 0 : (UDATA) ( ( (U_64) _tracedTotal * 100) / (U_64) _traceTarget)107);108109switch (_cardCleaningReason) {110case TRACING_COMPLETED:111cardCleaningReasonString = "tracing completed";112break;113case CARD_CLEANING_THRESHOLD_REACHED:114cardCleaningReasonString = "card cleaning threshold reached";115break;116default:117cardCleaningReasonString = "unknown";118break;119}120121agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<cards cleaned=\"%zu\" kickoff=\"%zu\" reason=\"%s\" />",122_cardsCleaned,123_cardCleaningPhase1Threshold,124cardCleaningReasonString125);126127if(_workStackOverflowOccured) {128agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<warning details=\"concurrent work stack overflow\" count=\"%zu\" />", _workStackOverflowCount);129}130131if (_extensions->verboseExtensions) {132/*133* CMVC 119942134*135* output stats about how many threads were scanned vs. how many were found at kickoff.136* The number actually scanned will usually be lower than the number found at kickoff137* because attached threads (like the JIT and the GC helper threads) won't typically be138* checking for async events139*/140agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<threads kickoff=\"%zu\" scanned=\"%zu\" />", _threadsToScanCount, _threadsScannedCount);141}142143_manager->decrementIndent();144indentLevel = _manager->getIndentLevel();145146agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "</stats>");147}148149150