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

Side by Side Diff: runtime/vm/heap.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 unified diff | Download patch
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/metrics.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/heap.h" 5 #include "vm/heap.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 int promo_percent = (allocated == 0) ? 0 : 446 int promo_percent = (allocated == 0) ? 0 :
447 (100 * stats->promoted_count) / allocated; 447 (100 * stats->promoted_count) / allocated;
448 if (promo_percent >= FLAG_pretenure_threshold) { 448 if (promo_percent >= FLAG_pretenure_threshold) {
449 pretenure_policy_ += FLAG_pretenure_interval; 449 pretenure_policy_ += FLAG_pretenure_interval;
450 } else { 450 } else {
451 pretenure_policy_ = Utils::Maximum(0, pretenure_policy_ - 1); 451 pretenure_policy_ = Utils::Maximum(0, pretenure_policy_ - 1);
452 } 452 }
453 } 453 }
454 454
455 455
456 void Heap::UpdateGlobalMaxUsed() {
457 ASSERT(isolate_ != NULL);
458 // We are accessing the used in words count for both new and old space
459 // without synchronizing. The value of this metric is approximate.
460 isolate_->GetHeapGlobalUsedMaxMetric()->SetValue(
461 (UsedInWords(Heap::kNew) * kWordSize) +
462 (UsedInWords(Heap::kOld) * kWordSize));
463 }
464
465
456 void Heap::SetGrowthControlState(bool state) { 466 void Heap::SetGrowthControlState(bool state) {
457 old_space_.SetGrowthControlState(state); 467 old_space_.SetGrowthControlState(state);
458 } 468 }
459 469
460 470
461 bool Heap::GrowthControlState() { 471 bool Heap::GrowthControlState() {
462 return old_space_.GrowthControlState(); 472 return old_space_.GrowthControlState();
463 } 473 }
464 474
465 475
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 ObjectSet* allocated_set = CreateAllocatedObjectSet(mark_expectation); 571 ObjectSet* allocated_set = CreateAllocatedObjectSet(mark_expectation);
562 VerifyPointersVisitor visitor(isolate(), allocated_set); 572 VerifyPointersVisitor visitor(isolate(), allocated_set);
563 VisitObjectPointers(&visitor); 573 VisitObjectPointers(&visitor);
564 delete allocated_set; 574 delete allocated_set;
565 // Only returning a value so that Heap::Validate can be called from an ASSERT. 575 // Only returning a value so that Heap::Validate can be called from an ASSERT.
566 return true; 576 return true;
567 } 577 }
568 578
569 579
570 void Heap::PrintSizes() const { 580 void Heap::PrintSizes() const {
571 OS::PrintErr("New space (%" Pd "k of %" Pd "k) " 581 OS::PrintErr("New space (%" Pd64 "k of %" Pd64 "k) "
572 "Old space (%" Pd "k of %" Pd "k)\n", 582 "Old space (%" Pd64 "k of %" Pd64 "k)\n",
573 (UsedInWords(kNew) / KBInWords), 583 (UsedInWords(kNew) / KBInWords),
574 (CapacityInWords(kNew) / KBInWords), 584 (CapacityInWords(kNew) / KBInWords),
575 (UsedInWords(kOld) / KBInWords), 585 (UsedInWords(kOld) / KBInWords),
576 (CapacityInWords(kOld) / KBInWords)); 586 (CapacityInWords(kOld) / KBInWords));
577 } 587 }
578 588
579 589
580 intptr_t Heap::UsedInWords(Space space) const { 590 int64_t Heap::UsedInWords(Space space) const {
581 return space == kNew ? new_space_.UsedInWords() : old_space_.UsedInWords(); 591 return space == kNew ? new_space_.UsedInWords() : old_space_.UsedInWords();
582 } 592 }
583 593
584 594
585 intptr_t Heap::CapacityInWords(Space space) const { 595 int64_t Heap::CapacityInWords(Space space) const {
586 return space == kNew ? new_space_.CapacityInWords() : 596 return space == kNew ? new_space_.CapacityInWords() :
587 old_space_.CapacityInWords(); 597 old_space_.CapacityInWords();
588 } 598 }
589 599
590 intptr_t Heap::ExternalInWords(Space space) const { 600
601 int64_t Heap::ExternalInWords(Space space) const {
591 return space == kNew ? new_space_.ExternalInWords() : 602 return space == kNew ? new_space_.ExternalInWords() :
592 old_space_.ExternalInWords(); 603 old_space_.ExternalInWords();
593 } 604 }
594 605
606
595 int64_t Heap::GCTimeInMicros(Space space) const { 607 int64_t Heap::GCTimeInMicros(Space space) const {
596 if (space == kNew) { 608 if (space == kNew) {
597 return new_space_.gc_time_micros(); 609 return new_space_.gc_time_micros();
598 } 610 }
599 return old_space_.gc_time_micros(); 611 return old_space_.gc_time_micros();
600 } 612 }
601 613
602 614
603 intptr_t Heap::Collections(Space space) const { 615 intptr_t Heap::Collections(Space space) const {
604 if (space == kNew) { 616 if (space == kNew) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 Dart::vm_isolate()->heap()->WriteProtect(false); 793 Dart::vm_isolate()->heap()->WriteProtect(false);
782 } 794 }
783 795
784 796
785 WritableVMIsolateScope::~WritableVMIsolateScope() { 797 WritableVMIsolateScope::~WritableVMIsolateScope() {
786 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); 798 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0);
787 Dart::vm_isolate()->heap()->WriteProtect(true); 799 Dart::vm_isolate()->heap()->WriteProtect(true);
788 } 800 }
789 801
790 } // namespace dart 802 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698