Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Unified Diff: runtime/vm/scavenger.cc

Issue 1384003004: Add max post-gc heap usage metrics (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« runtime/vm/pages.h ('K') | « runtime/vm/scavenger.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scavenger.cc
diff --git a/runtime/vm/scavenger.cc b/runtime/vm/scavenger.cc
index e885b9801e7cf8c877ea03b8abc02333f726927f..83dd9ff66a683542a0dfef265a714df23045e2dd 100644
--- a/runtime/vm/scavenger.cc
+++ b/runtime/vm/scavenger.cc
@@ -415,13 +415,16 @@ Scavenger::Scavenger(Heap* heap,
if (to_ == NULL) {
FATAL("Out of memory.\n");
}
- UpdateMaxHeapCapacity();
// Setup local fields.
top_ = FirstObjectStart();
resolved_top_ = top_;
end_ = to_->end();
survivor_end_ = FirstObjectStart();
+
+ UpdateMaxHeapCapacity();
+ UpdateMaxHeapUsage();
+ UpdateGlobalMaxUsed();
}
@@ -501,6 +504,8 @@ void Scavenger::Epilogue(Isolate* isolate,
}
#endif // defined(DEBUG)
from->Delete();
+ UpdateMaxHeapUsage();
+ UpdateGlobalMaxUsed();
if (invoke_api_callbacks && (isolate->gc_epilogue_callback() != NULL)) {
(isolate->gc_epilogue_callback())();
}
@@ -720,6 +725,36 @@ void Scavenger::UpdateMaxHeapCapacity() {
}
+void Scavenger::UpdateMaxHeapUsage() {
+ if (heap_ == NULL) {
+ // Some unit tests.
+ return;
+ }
+ ASSERT(to_ != NULL);
+ ASSERT(heap_ != NULL);
+ Isolate* isolate = heap_->isolate();
+ ASSERT(isolate != NULL);
+ isolate->GetHeapNewUsedMaxMetric()->SetValue(UsedInWords() * kWordSize);
+}
+
+
+void Scavenger::UpdateGlobalMaxUsed() {
+ if (heap_ == NULL) {
+ // Some unit tests.
+ return;
+ }
+ ASSERT(to_ != NULL);
+ ASSERT(heap_ != NULL);
+ Isolate* isolate = heap_->isolate();
+ ASSERT(isolate != NULL);
+ // This is technically under-counting, but, we cannot safely query the
+ // page space here. This is also updated whenever a page space GC occurs,
+ // which will reflect the (larger) combined heap usage.
+ isolate->GetHeapGlobalUsedMaxMetric()->SetValue(
+ (static_cast<int64_t>(heap_->UsedInWords(Heap::kNew)) * kWordSize));
+}
+
+
uword Scavenger::ProcessWeakProperty(RawWeakProperty* raw_weak,
ScavengerVisitor* visitor) {
// The fate of the weak property is determined by its key.
« runtime/vm/pages.h ('K') | « runtime/vm/scavenger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698