summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2015-06-10 17:20:54 -0700
committerHiroshi Yamauchi <yamauchi@google.com>2015-06-10 17:20:54 -0700
commit9a7fffb36bad0bf3e7bac21dd223d975bc9dde55 (patch)
tree58591407efac04f264bf97543d5b1a51616767e5
parent21cb657159b3e93cc888685ade83f8fc519290be (diff)
downloadart-9a7fffb36bad0bf3e7bac21dd223d975bc9dde55.zip
art-9a7fffb36bad0bf3e7bac21dd223d975bc9dde55.tar.gz
art-9a7fffb36bad0bf3e7bac21dd223d975bc9dde55.tar.bz2
Reset GC performance stats at zygote fork.
So GCs before a zygote fork won't be attributed to an app. Bug: 21491908 Change-Id: Ib37bc587e0f039ef8faeabe63dec19de49501863
-rw-r--r--runtime/gc/heap.cc21
-rw-r--r--runtime/gc/heap.h1
-rw-r--r--runtime/runtime.cc4
3 files changed, 26 insertions, 0 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index aeab7d8..eabbbec 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -1000,6 +1000,27 @@ void Heap::DumpGcPerformanceInfo(std::ostream& os) {
BaseMutex::DumpAll(os);
}
+void Heap::ResetGcPerformanceInfo() {
+ for (auto& collector : garbage_collectors_) {
+ collector->ResetMeasurements();
+ }
+ total_allocation_time_.StoreRelaxed(0);
+ total_bytes_freed_ever_ = 0;
+ total_objects_freed_ever_ = 0;
+ total_wait_time_ = 0;
+ blocking_gc_count_ = 0;
+ blocking_gc_time_ = 0;
+ gc_count_last_window_ = 0;
+ blocking_gc_count_last_window_ = 0;
+ last_update_time_gc_count_rate_histograms_ = // Round down by the window duration.
+ (NanoTime() / kGcCountRateHistogramWindowDuration) * kGcCountRateHistogramWindowDuration;
+ {
+ MutexLock mu(Thread::Current(), *gc_complete_lock_);
+ gc_count_rate_histogram_.Reset();
+ blocking_gc_count_rate_histogram_.Reset();
+ }
+}
+
uint64_t Heap::GetGcCount() const {
uint64_t gc_count = 0U;
for (auto& collector : garbage_collectors_) {
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 81a9741..dac747b 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -597,6 +597,7 @@ class Heap {
// GC performance measuring
void DumpGcPerformanceInfo(std::ostream& os);
+ void ResetGcPerformanceInfo();
// Returns true if we currently care about pause times.
bool CareAboutPauseTimes() const {
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 9d651bf..4a2a0c9 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -645,6 +645,10 @@ void Runtime::DidForkFromZygote(JNIEnv* env, NativeBridgeAction action, const ch
// Create the thread pools.
heap_->CreateThreadPool();
+ // Reset the gc performance data at zygote fork so that the GCs
+ // before fork aren't attributed to an app.
+ heap_->ResetGcPerformanceInfo();
+
if (jit_.get() == nullptr && jit_options_->UseJIT()) {
// Create the JIT if the flag is set and we haven't already create it (happens for run-tests).
CreateJit();