8191861: Move and refactor hSpaceCounters

Reviewed-by: pliden, ehelin, rkennke
This commit is contained in:
Stefan Karlsson 2017-11-24 15:48:01 +01:00
parent dbc915dcb9
commit 677e5bdaed
5 changed files with 73 additions and 55 deletions

View File

@ -42,11 +42,11 @@
#include "gc/g1/g1SATBCardTableModRefBS.hpp"
#include "gc/g1/g1SurvivorRegions.hpp"
#include "gc/g1/g1YCTypes.hpp"
#include "gc/g1/hSpaceCounters.hpp"
#include "gc/g1/heapRegionManager.hpp"
#include "gc/g1/heapRegionSet.hpp"
#include "gc/shared/barrierSet.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/plab.hpp"
#include "gc/shared/preservedMarks.hpp"
#include "memory/memRegion.hpp"

View File

@ -26,6 +26,7 @@
#include "gc/g1/g1CollectedHeap.inline.hpp"
#include "gc/g1/g1MonitoringSupport.hpp"
#include "gc/g1/g1Policy.hpp"
#include "gc/shared/hSpaceCounters.hpp"
G1GenerationCounters::G1GenerationCounters(G1MonitoringSupport* g1mm,
const char* name,
@ -128,10 +129,10 @@ G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
// name "generation.1.space.0"
// Counters are created from maxCapacity, capacity, initCapacity,
// and used.
_old_space_counters = new HSpaceCounters("space", 0 /* ordinal */,
_old_space_counters = new HSpaceCounters(_old_collection_counters->name_space(),
"space", 0 /* ordinal */,
pad_capacity(overall_reserved()) /* max_capacity */,
pad_capacity(old_space_committed()) /* init_capacity */,
_old_collection_counters);
pad_capacity(old_space_committed()) /* init_capacity */);
// Young collection set
// name "generation.0". This is logically the young generation.
@ -139,27 +140,29 @@ G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
// See _old_collection_counters for additional counters
_young_collection_counters = new G1YoungGenerationCounters(this, "young");
const char* young_collection_name_space = _young_collection_counters->name_space();
// name "generation.0.space.0"
// See _old_space_counters for additional counters
_eden_counters = new HSpaceCounters("eden", 0 /* ordinal */,
_eden_counters = new HSpaceCounters(young_collection_name_space,
"eden", 0 /* ordinal */,
pad_capacity(overall_reserved()) /* max_capacity */,
pad_capacity(eden_space_committed()) /* init_capacity */,
_young_collection_counters);
pad_capacity(eden_space_committed()) /* init_capacity */);
// name "generation.0.space.1"
// See _old_space_counters for additional counters
// Set the arguments to indicate that this survivor space is not used.
_from_counters = new HSpaceCounters("s0", 1 /* ordinal */,
_from_counters = new HSpaceCounters(young_collection_name_space,
"s0", 1 /* ordinal */,
pad_capacity(0) /* max_capacity */,
pad_capacity(0) /* init_capacity */,
_young_collection_counters);
pad_capacity(0) /* init_capacity */);
// name "generation.0.space.2"
// See _old_space_counters for additional counters
_to_counters = new HSpaceCounters("s1", 2 /* ordinal */,
_to_counters = new HSpaceCounters(young_collection_name_space,
"s1", 2 /* ordinal */,
pad_capacity(overall_reserved()) /* max_capacity */,
pad_capacity(survivor_space_committed()) /* init_capacity */,
_young_collection_counters);
pad_capacity(survivor_space_committed()) /* init_capacity */);
if (UsePerfData) {
// Given that this survivor space is not used, we update it here

View File

@ -25,9 +25,11 @@
#ifndef SHARE_VM_GC_G1_G1MONITORINGSUPPORT_HPP
#define SHARE_VM_GC_G1_G1MONITORINGSUPPORT_HPP
#include "gc/g1/hSpaceCounters.hpp"
#include "gc/shared/generationCounters.hpp"
class CollectorCounters;
class G1CollectedHeap;
class HSpaceCounters;
// Class for monitoring logical spaces in G1. It provides data for
// both G1's jstat counters as well as G1's memory pools.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, 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
@ -23,22 +23,23 @@
*/
#include "precompiled.hpp"
#include "gc/g1/hSpaceCounters.hpp"
#include "gc/shared/generation.hpp"
#include "gc/shared/hSpaceCounters.hpp"
#include "memory/allocation.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/perfData.hpp"
HSpaceCounters::HSpaceCounters(const char* name,
HSpaceCounters::HSpaceCounters(const char* name_space,
const char* name,
int ordinal,
size_t max_size,
size_t initial_capacity,
GenerationCounters* gc) {
size_t initial_capacity) {
if (UsePerfData) {
EXCEPTION_MARK;
ResourceMark rm;
const char* cns =
PerfDataManager::name_space(gc->name_space(), "space", ordinal);
PerfDataManager::name_space(name_space, "space", ordinal);
_name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtGC);
strcpy(_name_space, cns);
@ -64,3 +65,33 @@ HSpaceCounters::HSpaceCounters(const char* name,
initial_capacity, CHECK);
}
}
HSpaceCounters::~HSpaceCounters() {
if (_name_space != NULL) {
FREE_C_HEAP_ARRAY(char, _name_space);
}
}
void HSpaceCounters::update_capacity(size_t v) {
_capacity->set_value(v);
}
void HSpaceCounters::update_used(size_t v) {
_used->set_value(v);
}
void HSpaceCounters::update_all(size_t capacity, size_t used) {
update_capacity(capacity);
update_used(used);
}
debug_only(
// for security reasons, we do not allow arbitrary reads from
// the counters as they may live in shared memory.
jlong HSpaceCounters::used() {
return _used->get_value();
}
jlong HSpaceCounters::capacity() {
return _used->get_value();
}
)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, 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
@ -22,65 +22,47 @@
*
*/
#ifndef SHARE_VM_GC_G1_HSPACECOUNTERS_HPP
#define SHARE_VM_GC_G1_HSPACECOUNTERS_HPP
#ifndef SHARE_VM_GC_SHARED_HSPACECOUNTERS_HPP
#define SHARE_VM_GC_SHARED_HSPACECOUNTERS_HPP
#include "gc/shared/generation.hpp"
#include "gc/shared/generationCounters.hpp"
#include "memory/allocation.hpp"
#include "runtime/perfData.hpp"
#include "utilities/macros.hpp"
// A HSpaceCounter is a holder class for performance counters
// that track a collections (logical spaces) in a heap;
class HeapSpaceUsedHelper;
class G1SpaceMonitoringSupport;
class HSpaceCounters: public CHeapObj<mtGC> {
friend class VMStructs;
private:
PerfVariable* _capacity;
PerfVariable* _used;
PerfVariable* _capacity;
PerfVariable* _used;
// Constant PerfData types don't need to retain a reference.
// However, it's a good idea to document them here.
char* _name_space;
char* _name_space;
public:
HSpaceCounters(const char* name, int ordinal, size_t max_size,
size_t initial_capacity, GenerationCounters* gc);
HSpaceCounters(const char* name_space, const char* name, int ordinal,
size_t max_size, size_t initial_capacity);
~HSpaceCounters() {
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
}
~HSpaceCounters();
inline void update_capacity(size_t v) {
_capacity->set_value(v);
}
void update_capacity(size_t v);
void update_used(size_t v);
inline void update_used(size_t v) {
_used->set_value(v);
}
void update_all(size_t capacity, size_t used);
debug_only(
// for security reasons, we do not allow arbitrary reads from
// the counters as they may live in shared memory.
jlong used() {
return _used->get_value();
}
jlong capacity() {
return _used->get_value();
}
jlong used();
jlong capacity();
)
inline void update_all(size_t capacity, size_t used) {
update_capacity(capacity);
update_used(used);
}
const char* name_space() const { return _name_space; }
};
#endif // SHARE_VM_GC_G1_HSPACECOUNTERS_HPP
#endif // SHARE_VM_GC_SHARED_HSPACECOUNTERS_HPP