-
-
Save cscotta/ede22a2ccd5e5d797371 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r cbc4dbb7485a src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp | |
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Tue Oct 25 08:17:15 2011 -0700 | |
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Mon Jul 08 14:12:03 2013 -0700 | |
@@ -2026,7 +2026,7 @@ | |
} | |
{ | |
- TraceCMSMemoryManagerStats tmms(gch->gc_cause()); | |
+ TraceCMSMemoryManagerStats tmms(gch->gc_cause(), stats().cms_allocation_rate()); | |
} | |
GenMarkSweep::invoke_at_safepoint(_cmsGen->level(), | |
ref_processor(), clear_all_soft_refs); | |
@@ -3479,7 +3479,8 @@ | |
void CMSCollector::checkpointRootsInitial(bool asynch) { | |
assert(_collectorState == InitialMarking, "Wrong collector state"); | |
check_correct_thread_executing(); | |
- TraceCMSMemoryManagerStats tms(_collectorState,GenCollectedHeap::heap()->gc_cause()); | |
+ double rate = stats().cms_allocation_rate(); | |
+ TraceCMSMemoryManagerStats tms(_collectorState,GenCollectedHeap::heap()->gc_cause(), rate); | |
ReferenceProcessor* rp = ref_processor(); | |
SpecializationStats::clear(); | |
@@ -4858,7 +4859,9 @@ | |
// world is stopped at this checkpoint | |
assert(SafepointSynchronize::is_at_safepoint(), | |
"world should be stopped"); | |
- TraceCMSMemoryManagerStats tms(_collectorState,GenCollectedHeap::heap()->gc_cause()); | |
+ | |
+ double rate = stats().cms_allocation_rate(); | |
+ TraceCMSMemoryManagerStats tms(_collectorState,GenCollectedHeap::heap()->gc_cause(), rate); | |
verify_work_stacks_empty(); | |
verify_overflow_empty(); | |
@@ -5994,7 +5997,9 @@ | |
verify_work_stacks_empty(); | |
verify_overflow_empty(); | |
increment_sweep_count(); | |
- TraceCMSMemoryManagerStats tms(_collectorState,GenCollectedHeap::heap()->gc_cause()); | |
+ double rate = stats().cms_allocation_rate(); | |
+ TraceCMSMemoryManagerStats tms(_collectorState,GenCollectedHeap::heap()->gc_cause(), rate); | |
_inter_sweep_timer.stop(); | |
_inter_sweep_estimate.sample(_inter_sweep_timer.seconds()); | |
@@ -9297,43 +9302,46 @@ | |
return res; | |
} | |
-TraceCMSMemoryManagerStats::TraceCMSMemoryManagerStats(CMSCollector::CollectorState phase, GCCause::Cause cause): TraceMemoryManagerStats() { | |
+TraceCMSMemoryManagerStats::TraceCMSMemoryManagerStats(CMSCollector::CollectorState phase, GCCause::Cause cause, double allocRate): TraceMemoryManagerStats() { | |
switch (phase) { | |
case CMSCollector::InitialMarking: | |
initialize(true /* fullGC */ , | |
cause /* cause of the GC */, | |
+ allocRate, | |
true /* recordGCBeginTime */, | |
true /* recordPreGCUsage */, | |
false /* recordPeakUsage */, | |
false /* recordPostGCusage */, | |
true /* recordAccumulatedGCTime */, | |
false /* recordGCEndTime */, | |
- false /* countCollection */ ); | |
+ false /* countCollection */); | |
break; | |
case CMSCollector::FinalMarking: | |
initialize(true /* fullGC */ , | |
cause /* cause of the GC */, | |
+ allocRate, | |
false /* recordGCBeginTime */, | |
false /* recordPreGCUsage */, | |
false /* recordPeakUsage */, | |
false /* recordPostGCusage */, | |
true /* recordAccumulatedGCTime */, | |
false /* recordGCEndTime */, | |
- false /* countCollection */ ); | |
+ false /* countCollection */); | |
break; | |
case CMSCollector::Sweeping: | |
initialize(true /* fullGC */ , | |
cause /* cause of the GC */, | |
+ allocRate, /* allocation rate */ | |
false /* recordGCBeginTime */, | |
false /* recordPreGCUsage */, | |
true /* recordPeakUsage */, | |
true /* recordPostGCusage */, | |
false /* recordAccumulatedGCTime */, | |
true /* recordGCEndTime */, | |
- true /* countCollection */ ); | |
+ true /* countCollection */); | |
break; | |
default: | |
@@ -9342,14 +9350,15 @@ | |
} | |
// when bailing out of cms in concurrent mode failure | |
-TraceCMSMemoryManagerStats::TraceCMSMemoryManagerStats(GCCause::Cause cause): TraceMemoryManagerStats() { | |
+TraceCMSMemoryManagerStats::TraceCMSMemoryManagerStats(GCCause::Cause cause, double allocRate): TraceMemoryManagerStats() { | |
initialize(true /* fullGC */ , | |
cause /* cause of the GC */, | |
+ allocRate, /* allocation rate */ | |
true /* recordGCBeginTime */, | |
true /* recordPreGCUsage */, | |
true /* recordPeakUsage */, | |
true /* recordPostGCusage */, | |
true /* recordAccumulatedGCTime */, | |
true /* recordGCEndTime */, | |
- true /* countCollection */ ); | |
-} | |
+ true /* countCollection */); | |
+} | |
diff -r cbc4dbb7485a src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp | |
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Tue Oct 25 08:17:15 2011 -0700 | |
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Mon Jul 08 14:12:03 2013 -0700 | |
@@ -1899,8 +1899,8 @@ | |
class TraceCMSMemoryManagerStats : public TraceMemoryManagerStats { | |
public: | |
- TraceCMSMemoryManagerStats(CMSCollector::CollectorState phase, GCCause::Cause cause); | |
- TraceCMSMemoryManagerStats(GCCause::Cause cause); | |
+ TraceCMSMemoryManagerStats(CMSCollector::CollectorState phase, GCCause::Cause cause, double allocRate); | |
+ TraceCMSMemoryManagerStats(GCCause::Cause cause, double allocRate); | |
}; | |
diff -r cbc4dbb7485a src/share/vm/services/jmm.h | |
--- a/src/share/vm/services/jmm.h Tue Oct 25 08:17:15 2011 -0700 | |
+++ b/src/share/vm/services/jmm.h Mon Jul 08 14:12:03 2013 -0700 | |
@@ -209,6 +209,7 @@ | |
jobjectArray (JNICALL *GetInputArgumentArray) (JNIEnv *env); | |
jobjectArray (JNICALL *GetMemoryPools) (JNIEnv* env, jobject mgr); | |
+ jdouble (JNICALL *GetAllocationRate) (JNIEnv* env, jobject mgr); | |
jobjectArray (JNICALL *GetMemoryManagers) (JNIEnv* env, jobject pool); | |
diff -r cbc4dbb7485a src/share/vm/services/management.cpp | |
--- a/src/share/vm/services/management.cpp Tue Oct 25 08:17:15 2011 -0700 | |
+++ b/src/share/vm/services/management.cpp Mon Jul 08 14:12:03 2013 -0700 | |
@@ -589,6 +589,28 @@ | |
return (jobjectArray) JNIHandles::make_local(env, poolArray()); | |
JVM_END | |
+/************* ***********************/ | |
+// Returns the allocation rate for a given memory manager. | |
+JVM_ENTRY(jdouble, jmm_GetAllocationRate(JNIEnv* env, jobject obj)) | |
+ ResourceMark rm(THREAD); | |
+ | |
+ double rate = -1; | |
+ MemoryManager* mgr; | |
+ | |
+ if (obj != NULL) { | |
+ oop mgr_obj = JNIHandles::resolve(obj); | |
+ assert(mgr_obj->is_instance(), "Should be an instanceOop"); | |
+ instanceHandle mh(THREAD, (instanceOop) mgr_obj); | |
+ mgr = MemoryService::get_memory_manager(mh); | |
+ } | |
+ | |
+ if (mgr != NULL) { | |
+ rate = mgr->get_allocation_rate(); | |
+ } | |
+ | |
+ return rate; | |
+JVM_END | |
+ | |
// Returns an array of java/lang/management/MemoryManagerMXBean object | |
// one for each memory manager if obj == null; otherwise returns | |
// an array of memory managers for a given memory pool if | |
@@ -2122,6 +2144,7 @@ | |
jmm_GetThreadInfo, | |
jmm_GetInputArgumentArray, | |
jmm_GetMemoryPools, | |
+ jmm_GetAllocationRate, | |
jmm_GetMemoryManagers, | |
jmm_GetMemoryPoolUsage, | |
jmm_GetPeakMemoryPoolUsage, | |
diff -r cbc4dbb7485a src/share/vm/services/memoryManager.cpp | |
--- a/src/share/vm/services/memoryManager.cpp Tue Oct 25 08:17:15 2011 -0700 | |
+++ b/src/share/vm/services/memoryManager.cpp Mon Jul 08 14:12:03 2013 -0700 | |
@@ -44,6 +44,7 @@ | |
MemoryManager::MemoryManager() { | |
_num_pools = 0; | |
_memory_mgr_obj = NULL; | |
+ _allocation_rate = -1; | |
} | |
void MemoryManager::add_pool(MemoryPool* pool) { | |
diff -r cbc4dbb7485a src/share/vm/services/memoryManager.hpp | |
--- a/src/share/vm/services/memoryManager.hpp Tue Oct 25 08:17:15 2011 -0700 | |
+++ b/src/share/vm/services/memoryManager.hpp Mon Jul 08 14:12:03 2013 -0700 | |
@@ -48,6 +48,7 @@ | |
MemoryPool* _pools[max_num_pools]; | |
int _num_pools; | |
+ double _allocation_rate; | |
protected: | |
volatile instanceOop _memory_mgr_obj; | |
@@ -68,6 +69,9 @@ | |
MemoryManager(); | |
+ void set_allocation_rate(double rate) { _allocation_rate = rate; } | |
+ double get_allocation_rate() { return _allocation_rate; } | |
+ | |
int num_memory_pools() const { return _num_pools; } | |
MemoryPool* get_memory_pool(int index) { | |
assert(index >= 0 && index < _num_pools, "Invalid index"); | |
diff -r cbc4dbb7485a src/share/vm/services/memoryService.cpp | |
--- a/src/share/vm/services/memoryService.cpp Tue Oct 25 08:17:15 2011 -0700 | |
+++ b/src/share/vm/services/memoryService.cpp Mon Jul 08 14:12:03 2013 -0700 | |
@@ -566,7 +566,7 @@ | |
void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage, | |
bool recordAccumulatedGCTime, | |
bool recordGCEndTime, bool countCollection, | |
- GCCause::Cause cause) { | |
+ GCCause::Cause cause, double allocationRate) { | |
GCMemoryManager* mgr; | |
if (fullGC) { | |
@@ -579,6 +579,9 @@ | |
// register the GC end statistics and memory usage | |
mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, | |
countCollection, cause); | |
+ if (allocationRate != -1) { | |
+ mgr->set_allocation_rate(allocationRate); | |
+ } | |
} | |
void MemoryService::oops_do(OopClosure* f) { | |
@@ -634,7 +637,7 @@ | |
// gc manager (so _fullGC is set to false ) and for other generation kinds | |
// doing mark-sweep-compact uses major gc manager (so _fullGC is set | |
// to true). | |
-TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause) { | |
+TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause, double allocRate) { | |
switch (kind) { | |
case Generation::DefNew: | |
#ifndef SERIALGC | |
@@ -655,8 +658,24 @@ | |
} | |
// this has to be called in a stop the world pause and represent | |
// an entire gc pause, start to finish: | |
- initialize(_fullGC, cause,true, true, true, true, true, true, true); | |
+ initialize(_fullGC, cause, allocRate, true, true, true, true, true, true, true); | |
} | |
+ | |
+TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC, | |
+ GCCause::Cause cause, | |
+ double allocationRate, | |
+ bool recordGCBeginTime, | |
+ bool recordPreGCUsage, | |
+ bool recordPeakUsage, | |
+ bool recordPostGCUsage, | |
+ bool recordAccumulatedGCTime, | |
+ bool recordGCEndTime, | |
+ bool countCollection) { | |
+ initialize(fullGC, cause, allocationRate, recordGCBeginTime, recordPreGCUsage, | |
+ recordPeakUsage, recordPostGCUsage, recordAccumulatedGCTime, | |
+ recordGCEndTime, countCollection); | |
+} | |
+ | |
TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC, | |
GCCause::Cause cause, | |
bool recordGCBeginTime, | |
@@ -666,7 +685,7 @@ | |
bool recordAccumulatedGCTime, | |
bool recordGCEndTime, | |
bool countCollection) { | |
- initialize(fullGC, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage, | |
+ initialize(fullGC, cause, -1, recordGCBeginTime, recordPreGCUsage, recordPeakUsage, | |
recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, | |
countCollection); | |
} | |
@@ -675,6 +694,7 @@ | |
// the MemoryService | |
void TraceMemoryManagerStats::initialize(bool fullGC, | |
GCCause::Cause cause, | |
+ double allocationRate, | |
bool recordGCBeginTime, | |
bool recordPreGCUsage, | |
bool recordPeakUsage, | |
@@ -691,6 +711,7 @@ | |
_recordGCEndTime = recordGCEndTime; | |
_countCollection = countCollection; | |
_cause = cause; | |
+ _allocationRate = allocationRate; | |
MemoryService::gc_begin(_fullGC, _recordGCBeginTime, _recordAccumulatedGCTime, | |
_recordPreGCUsage, _recordPeakUsage); | |
@@ -698,6 +719,6 @@ | |
TraceMemoryManagerStats::~TraceMemoryManagerStats() { | |
MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime, | |
- _recordGCEndTime, _countCollection, _cause); | |
+ _recordGCEndTime, _countCollection, _cause, _allocationRate); | |
} | |
diff -r cbc4dbb7485a src/share/vm/services/memoryService.hpp | |
--- a/src/share/vm/services/memoryService.hpp Tue Oct 25 08:17:15 2011 -0700 | |
+++ b/src/share/vm/services/memoryService.hpp Mon Jul 08 14:12:03 2013 -0700 | |
@@ -30,9 +30,11 @@ | |
#include "runtime/handles.hpp" | |
#include "services/memoryUsage.hpp" | |
#include "gc_interface/gcCause.hpp" | |
+#include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp" | |
// Forward declaration | |
class MemoryPool; | |
+class CMSStats; | |
class MemoryManager; | |
class GCMemoryManager; | |
class CollectedHeap; | |
@@ -66,7 +68,6 @@ | |
major = 1, | |
n_gens = 2 | |
}; | |
- | |
static GrowableArray<MemoryPool*>* _pools_list; | |
static GrowableArray<MemoryManager*>* _managers_list; | |
@@ -164,7 +165,7 @@ | |
static void gc_end(bool fullGC, bool recordPostGCUsage, | |
bool recordAccumulatedGCTime, | |
bool recordGCEndTime, bool countCollection, | |
- GCCause::Cause cause); | |
+ GCCause::Cause cause, double allocRate); | |
static void oops_do(OopClosure* f); | |
@@ -194,11 +195,23 @@ | |
bool _recordAccumulatedGCTime; | |
bool _recordGCEndTime; | |
bool _countCollection; | |
+ double _allocationRate; | |
GCCause::Cause _cause; | |
public: | |
TraceMemoryManagerStats() {} | |
TraceMemoryManagerStats(bool fullGC, | |
GCCause::Cause cause, | |
+ double allocationRate, | |
+ bool recordGCBeginTime = true, | |
+ bool recordPreGCUsage = true, | |
+ bool recordPeakUsage = true, | |
+ bool recordPostGCUsage = true, | |
+ bool recordAccumulatedGCTime = true, | |
+ bool recordGCEndTime = true, | |
+ bool countCollection = true); | |
+ | |
+ TraceMemoryManagerStats(bool fullGC, | |
+ GCCause::Cause cause, | |
bool recordGCBeginTime = true, | |
bool recordPreGCUsage = true, | |
bool recordPeakUsage = true, | |
@@ -209,6 +222,7 @@ | |
void initialize(bool fullGC, | |
GCCause::Cause cause, | |
+ double allocationRate, | |
bool recordGCBeginTime, | |
bool recordPreGCUsage, | |
bool recordPeakUsage, | |
@@ -217,7 +231,7 @@ | |
bool recordGCEndTime, | |
bool countCollection); | |
- TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause); | |
+ TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause, double allocRate); | |
~TraceMemoryManagerStats(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment