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

Unified Diff: runtime/vm/pages.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
Index: runtime/vm/pages.cc
diff --git a/runtime/vm/pages.cc b/runtime/vm/pages.cc
index 7cee6df7868fbd11a1d689a0a364ba9ee601948a..9da3ee24950935fa643ac163015182eb18322041 100644
--- a/runtime/vm/pages.cc
+++ b/runtime/vm/pages.cc
@@ -171,6 +171,7 @@ PageSpace::PageSpace(Heap* heap,
collections_(0) {
// We aren't holding the lock but no one can reference us yet.
UpdateMaxCapacityLocked();
+ UpdateMaxUsed();
}
@@ -547,6 +548,33 @@ void PageSpace::UpdateMaxCapacityLocked() {
}
+void PageSpace::UpdateMaxUsed() {
+ if (heap_ == NULL) {
+ // Some unit tests.
+ return;
+ }
+ ASSERT(heap_ != NULL);
+ ASSERT(heap_->isolate() != NULL);
+ Isolate* isolate = heap_->isolate();
+ isolate->GetHeapOldUsedMaxMetric()->SetValue(
+ static_cast<int64_t>(UsedInWords()) * kWordSize);
+}
+
+
+void PageSpace::UpdateGlobalMaxUsed() {
+ if (heap_ == NULL) {
+ // Some unit tests.
+ return;
+ }
+ ASSERT(heap_ != NULL);
+ ASSERT(heap_->isolate() != NULL);
+ Isolate* isolate = heap_->isolate();
+ isolate->GetHeapGlobalUsedMaxMetric()->SetValue(
+ (static_cast<int64_t>(heap_->UsedInWords(Heap::kNew)) * kWordSize) +
+ (static_cast<int64_t>(heap_->UsedInWords(Heap::kOld)) * kWordSize));
+}
+
+
bool PageSpace::Contains(uword addr) const {
for (ExclusivePageIterator it(this); !it.Done(); it.Advance()) {
if (it.page()->Contains(addr)) {
@@ -932,6 +960,9 @@ void PageSpace::MarkSweep(bool invoke_api_callbacks) {
freelist_[HeapPage::kExecutable].Print();
}
+ UpdateMaxUsed();
+ UpdateGlobalMaxUsed();
+
isolate->thread_registry()->ResumeAllThreads();
// Done, reset the task count.
« runtime/vm/pages.h ('K') | « runtime/vm/pages.h ('k') | runtime/vm/scavenger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698