summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sekyeong Heo <sekyeong.heo@samsung.com> 2020-12-22 19:38:28 +0900
committer Nicolas Geoffray <ngeoffray@google.com> 2021-05-13 08:39:27 +0000
commitb1db5a110d312c5a51a52f7f6bc870f9205b6ff8 (patch)
tree9ab0ca4cc92dda3b9ebcbaf32583463e0f25ea86
parentf7f97d2c3e847e68f87490e110e192dd587572bb (diff)
[art] Add GetObjectsAllocated and TotalTimeWaitingForGc APIs
It's difficult to analyze sluggish issue due to excessive GC. So, I would like to add APIs for GC status check. GetObjectsAllocated : return count of allocated objects. how to use : Debug.getRuntimeStat("art.gc.objects-allocated) TotalTimeWaitingForGc : return total waiting time for GC. how to use : Debug.getRuntimeStat("art.gc.total-time-waiting-for-gc") This must be submitted with the libcore code. Test: check value using Debug.getRuntimeStat() Change-Id: I2e865957ddb7e8cb5ac955e65a18d2aaffe4c672
-rw-r--r--runtime/gc/heap.h3
-rw-r--r--runtime/native/dalvik_system_VMDebug.cc10
2 files changed, 13 insertions, 0 deletions
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 5d0ba8ff89..53eed6be19 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -850,6 +850,9 @@ class Heap {
uint64_t GetBlockingGcTime() const;
void DumpGcCountRateHistogram(std::ostream& os) const REQUIRES(!*gc_complete_lock_);
void DumpBlockingGcCountRateHistogram(std::ostream& os) const REQUIRES(!*gc_complete_lock_);
+ uint64_t GetTotalTimeWaitingForGC() const {
+ return total_wait_time_;
+ }
// Perfetto Art Heap Profiler Support.
HeapSampler& GetHeapSampler() {
diff --git a/runtime/native/dalvik_system_VMDebug.cc b/runtime/native/dalvik_system_VMDebug.cc
index d1683a92e6..5c8bd8431a 100644
--- a/runtime/native/dalvik_system_VMDebug.cc
+++ b/runtime/native/dalvik_system_VMDebug.cc
@@ -313,6 +313,8 @@ enum class VMDebugRuntimeStatId {
kArtGcBlockingGcTime,
kArtGcGcCountRateHistogram,
kArtGcBlockingGcCountRateHistogram,
+ kArtGcObjectsAllocated,
+ kArtGcTotalTimeWaitingForGc,
kNumRuntimeStats,
};
@@ -353,6 +355,14 @@ static jstring VMDebug_getRuntimeStatInternal(JNIEnv* env, jclass, jint statId)
heap->DumpBlockingGcCountRateHistogram(output);
return env->NewStringUTF(output.str().c_str());
}
+ case VMDebugRuntimeStatId::kArtGcObjectsAllocated: {
+ std::string output = std::to_string(heap->GetObjectsAllocated());
+ return env->NewStringUTF(output.c_str());
+ }
+ case VMDebugRuntimeStatId::kArtGcTotalTimeWaitingForGc: {
+ std::string output = std::to_string(heap->GetTotalTimeWaitingForGC());
+ return env->NewStringUTF(output.c_str());
+ }
default:
return nullptr;
}