mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 04:24:49 +02:00
8036698: Add trace event for updates to metaspace gc threshold
Reviewed-by: stefank, mgerdin
This commit is contained in:
parent
1fb0683664
commit
51584519f4
7 changed files with 177 additions and 14 deletions
|
@ -32,7 +32,9 @@
|
|||
#include "memory/gcLocker.hpp"
|
||||
#include "memory/metachunk.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
#include "memory/metaspaceGCThresholdUpdater.hpp"
|
||||
#include "memory/metaspaceShared.hpp"
|
||||
#include "memory/metaspaceTracer.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "runtime/atomic.inline.hpp"
|
||||
|
@ -57,6 +59,7 @@ size_t const allocation_from_dictionary_limit = 4 * K;
|
|||
MetaWord* last_allocated = 0;
|
||||
|
||||
size_t Metaspace::_compressed_class_space_size;
|
||||
const MetaspaceTracer* Metaspace::_tracer = NULL;
|
||||
|
||||
// Used in declarations in SpaceManager and ChunkManager
|
||||
enum ChunkIndex {
|
||||
|
@ -1436,10 +1439,11 @@ void MetaspaceGC::compute_new_size() {
|
|||
expand_bytes = align_size_up(expand_bytes, Metaspace::commit_alignment());
|
||||
// Don't expand unless it's significant
|
||||
if (expand_bytes >= MinMetaspaceExpansion) {
|
||||
MetaspaceGC::inc_capacity_until_GC(expand_bytes);
|
||||
}
|
||||
size_t new_capacity_until_GC = MetaspaceGC::inc_capacity_until_GC(expand_bytes);
|
||||
Metaspace::tracer()->report_gc_threshold(capacity_until_GC,
|
||||
new_capacity_until_GC,
|
||||
MetaspaceGCThresholdUpdater::ComputeNewSize);
|
||||
if (PrintGCDetails && Verbose) {
|
||||
size_t new_capacity_until_GC = capacity_until_GC;
|
||||
gclog_or_tty->print_cr(" expanding:"
|
||||
" minimum_desired_capacity: %6.1fKB"
|
||||
" expand_bytes: %6.1fKB"
|
||||
|
@ -1450,6 +1454,7 @@ void MetaspaceGC::compute_new_size() {
|
|||
MinMetaspaceExpansion / (double) K,
|
||||
new_capacity_until_GC / (double) K);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1528,7 +1533,10 @@ void MetaspaceGC::compute_new_size() {
|
|||
// Don't shrink unless it's significant
|
||||
if (shrink_bytes >= MinMetaspaceExpansion &&
|
||||
((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) {
|
||||
MetaspaceGC::dec_capacity_until_GC(shrink_bytes);
|
||||
size_t new_capacity_until_GC = MetaspaceGC::dec_capacity_until_GC(shrink_bytes);
|
||||
Metaspace::tracer()->report_gc_threshold(capacity_until_GC,
|
||||
new_capacity_until_GC,
|
||||
MetaspaceGCThresholdUpdater::ComputeNewSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3132,6 +3140,7 @@ void Metaspace::global_initialize() {
|
|||
}
|
||||
|
||||
MetaspaceGC::initialize();
|
||||
_tracer = new MetaspaceTracer();
|
||||
}
|
||||
|
||||
Metachunk* Metaspace::get_initialization_chunk(MetadataType mdtype,
|
||||
|
@ -3220,8 +3229,12 @@ MetaWord* Metaspace::expand_and_allocate(size_t word_size, MetadataType mdtype)
|
|||
assert(delta_bytes > 0, "Must be");
|
||||
|
||||
size_t after_inc = MetaspaceGC::inc_capacity_until_GC(delta_bytes);
|
||||
|
||||
// capacity_until_GC might be updated concurrently, must calculate previous value.
|
||||
size_t before_inc = after_inc - delta_bytes;
|
||||
|
||||
tracer()->report_gc_threshold(before_inc, after_inc,
|
||||
MetaspaceGCThresholdUpdater::ExpandAndAllocate);
|
||||
if (PrintGCDetails && Verbose) {
|
||||
gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT
|
||||
" to " SIZE_FORMAT, before_inc, after_inc);
|
||||
|
|
|
@ -60,6 +60,7 @@ class ChunkManager;
|
|||
class ClassLoaderData;
|
||||
class Metablock;
|
||||
class Metachunk;
|
||||
class MetaspaceTracer;
|
||||
class MetaWord;
|
||||
class Mutex;
|
||||
class outputStream;
|
||||
|
@ -149,6 +150,8 @@ class Metaspace : public CHeapObj<mtClass> {
|
|||
static ChunkManager* _chunk_manager_metadata;
|
||||
static ChunkManager* _chunk_manager_class;
|
||||
|
||||
static const MetaspaceTracer* _tracer;
|
||||
|
||||
public:
|
||||
static VirtualSpaceList* space_list() { return _space_list; }
|
||||
static VirtualSpaceList* class_space_list() { return _class_space_list; }
|
||||
|
@ -164,6 +167,8 @@ class Metaspace : public CHeapObj<mtClass> {
|
|||
return mdtype == ClassType ? chunk_manager_class() : chunk_manager_metadata();
|
||||
}
|
||||
|
||||
static const MetaspaceTracer* tracer() { return _tracer; }
|
||||
|
||||
private:
|
||||
// This is used by DumpSharedSpaces only, where only _vsm is used. So we will
|
||||
// maintain a single list for now.
|
||||
|
|
52
hotspot/src/share/vm/memory/metaspaceGCThresholdUpdater.hpp
Normal file
52
hotspot/src/share/vm/memory/metaspaceGCThresholdUpdater.hpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_VM_MEMORY_METASPACE_GC_THRESHOLD_UPDATER_HPP
|
||||
#define SHARE_VM_MEMORY_METASPACE_GC_THRESHOLD_UPDATER_HPP
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
|
||||
class MetaspaceGCThresholdUpdater : public AllStatic {
|
||||
public:
|
||||
enum Type {
|
||||
ComputeNewSize,
|
||||
ExpandAndAllocate,
|
||||
Last
|
||||
};
|
||||
|
||||
static const char* to_string(MetaspaceGCThresholdUpdater::Type updater) {
|
||||
switch (updater) {
|
||||
case ComputeNewSize:
|
||||
return "compute_new_size";
|
||||
case ExpandAndAllocate:
|
||||
return "expand_and_allocate";
|
||||
default:
|
||||
assert(false, err_msg("Got bad updater: %d", (int) updater));
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SHARE_VM_MEMORY_METASPACE_GC_THRESHOLD_UPDATER_HPP
|
40
hotspot/src/share/vm/memory/metaspaceTracer.cpp
Normal file
40
hotspot/src/share/vm/memory/metaspaceTracer.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "memory/metaspaceTracer.hpp"
|
||||
#include "trace/tracing.hpp"
|
||||
#include "trace/traceBackend.hpp"
|
||||
|
||||
void MetaspaceTracer::report_gc_threshold(size_t old_val,
|
||||
size_t new_val,
|
||||
MetaspaceGCThresholdUpdater::Type updater) const {
|
||||
EventMetaspaceGCThreshold event;
|
||||
if (event.should_commit()) {
|
||||
event.set_oldValue(old_val);
|
||||
event.set_newValue(new_val);
|
||||
event.set_updater((u1)updater);
|
||||
event.commit();
|
||||
}
|
||||
}
|
38
hotspot/src/share/vm/memory/metaspaceTracer.hpp
Normal file
38
hotspot/src/share/vm/memory/metaspaceTracer.hpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_VM_MEMORY_METASPACE_TRACER_HPP
|
||||
#define SHARE_VM_MEMORY_METASPACE_TRACER_HPP
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/metaspaceGCThresholdUpdater.hpp"
|
||||
|
||||
class MetaspaceTracer : public CHeapObj<mtTracing> {
|
||||
public:
|
||||
void report_gc_threshold(size_t old_val,
|
||||
size_t new_val,
|
||||
MetaspaceGCThresholdUpdater::Type updater) const;
|
||||
};
|
||||
|
||||
#endif // SHARE_VM_MEMORY_METASPACE_TRACER_HPP
|
|
@ -199,6 +199,12 @@ Declares a structure type that can be used in other events.
|
|||
<structvalue type="MetaspaceSizes" field="classSpace" label="Class"/>
|
||||
</event>
|
||||
|
||||
<event id="MetaspaceGCThreshold" path="vm/gc/metaspace/gc_threshold" label="Metaspace GC Threshold" is_instant="true">
|
||||
<value type="BYTES64" field="oldValue" label="Old Value" />
|
||||
<value type="BYTES64" field="newValue" label="New Value" />
|
||||
<value type="GCTHRESHOLDUPDATER" field="updater" label="Updater" />
|
||||
</event>
|
||||
|
||||
<event id="PSHeapSummary" path="vm/gc/heap/ps_summary" label="Parallel Scavenge Heap Summary" is_instant="true">
|
||||
<value type="UINT" field="gcId" label="GC ID" relation="GC_ID"/>
|
||||
<value type="GCWHEN" field="when" label="When" />
|
||||
|
|
|
@ -130,6 +130,11 @@ Now we can use the content + data type in declaring event fields.
|
|||
<value type="UTF8" field="type" label="type" />
|
||||
</content_type>
|
||||
|
||||
<content_type id="GCThresholdUpdater" hr_name="GC Treshold Updater"
|
||||
type="U1" jvm_type="GCTHRESHOLDUPDATER">
|
||||
<value type="UTF8" field="updater" label="updater" />
|
||||
</content_type>
|
||||
|
||||
<content_type id="ReferenceType" hr_name="Reference Type"
|
||||
type="U1" jvm_type="REFERENCETYPE">
|
||||
<value type="UTF8" field="type" label="type" />
|
||||
|
@ -324,6 +329,10 @@ Now we can use the content + data type in declaring event fields.
|
|||
<primary_type symbol="G1YCTYPE" datatype="U1" contenttype="G1YCTYPE"
|
||||
type="u1" sizeop="sizeof(u1)" />
|
||||
|
||||
<!-- GCTHRESHOLDUPDATER -->
|
||||
<primary_type symbol="GCTHRESHOLDUPDATER" datatype="U1" contenttype="GCTHRESHOLDUPDATER"
|
||||
type="u1" sizeop="sizeof(u1)" />
|
||||
|
||||
<!-- REFERENCETYPE -->
|
||||
<primary_type symbol="REFERENCETYPE" datatype="U1"
|
||||
contenttype="REFERENCETYPE" type="u1" sizeop="sizeof(u1)" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue