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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/scavenger.h ('k') | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/scavenger.h" 5 #include "vm/scavenger.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // going to use for forwarding pointers. 408 // going to use for forwarding pointers.
409 ASSERT(Object::tags_offset() == 0); 409 ASSERT(Object::tags_offset() == 0);
410 410
411 // Set initial size resulting in a total of three different levels. 411 // Set initial size resulting in a total of three different levels.
412 const intptr_t initial_semi_capacity_in_words = max_semi_capacity_in_words / 412 const intptr_t initial_semi_capacity_in_words = max_semi_capacity_in_words /
413 (FLAG_new_gen_growth_factor * FLAG_new_gen_growth_factor); 413 (FLAG_new_gen_growth_factor * FLAG_new_gen_growth_factor);
414 to_ = SemiSpace::New(initial_semi_capacity_in_words); 414 to_ = SemiSpace::New(initial_semi_capacity_in_words);
415 if (to_ == NULL) { 415 if (to_ == NULL) {
416 FATAL("Out of memory.\n"); 416 FATAL("Out of memory.\n");
417 } 417 }
418 UpdateMaxHeapCapacity();
419 // Setup local fields. 418 // Setup local fields.
420 top_ = FirstObjectStart(); 419 top_ = FirstObjectStart();
421 resolved_top_ = top_; 420 resolved_top_ = top_;
422 end_ = to_->end(); 421 end_ = to_->end();
423 422
424 survivor_end_ = FirstObjectStart(); 423 survivor_end_ = FirstObjectStart();
424
425 UpdateMaxHeapCapacity();
426 UpdateMaxHeapUsage();
427 if (heap_ != NULL) {
428 heap_->UpdateGlobalMaxUsed();
429 }
425 } 430 }
426 431
427 432
428 Scavenger::~Scavenger() { 433 Scavenger::~Scavenger() {
429 ASSERT(!scavenging_); 434 ASSERT(!scavenging_);
430 to_->Delete(); 435 to_->Delete();
431 } 436 }
432 437
433 438
434 intptr_t Scavenger::NewSizeInWords(intptr_t old_size_in_words) const { 439 intptr_t Scavenger::NewSizeInWords(intptr_t old_size_in_words) const {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 { 499 {
495 PageSpace* page_space = heap_->old_space(); 500 PageSpace* page_space = heap_->old_space();
496 MonitorLocker ml(page_space->tasks_lock()); 501 MonitorLocker ml(page_space->tasks_lock());
497 if (page_space->tasks() == 0) { 502 if (page_space->tasks() == 0) {
498 VerifyStoreBufferPointerVisitor verify_store_buffer_visitor(isolate, to_); 503 VerifyStoreBufferPointerVisitor verify_store_buffer_visitor(isolate, to_);
499 heap_->old_space()->VisitObjectPointers(&verify_store_buffer_visitor); 504 heap_->old_space()->VisitObjectPointers(&verify_store_buffer_visitor);
500 } 505 }
501 } 506 }
502 #endif // defined(DEBUG) 507 #endif // defined(DEBUG)
503 from->Delete(); 508 from->Delete();
509 UpdateMaxHeapUsage();
510 if (heap_ != NULL) {
511 heap_->UpdateGlobalMaxUsed();
512 }
504 if (invoke_api_callbacks && (isolate->gc_epilogue_callback() != NULL)) { 513 if (invoke_api_callbacks && (isolate->gc_epilogue_callback() != NULL)) {
505 (isolate->gc_epilogue_callback())(); 514 (isolate->gc_epilogue_callback())();
506 } 515 }
507 } 516 }
508 517
509 518
510 void Scavenger::IterateStoreBuffers(Isolate* isolate, 519 void Scavenger::IterateStoreBuffers(Isolate* isolate,
511 ScavengerVisitor* visitor) { 520 ScavengerVisitor* visitor) {
512 // Iterating through the store buffers. 521 // Iterating through the store buffers.
513 // Grab the deduplication sets out of the isolate's consolidated store buffer. 522 // Grab the deduplication sets out of the isolate's consolidated store buffer.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 722 }
714 ASSERT(to_ != NULL); 723 ASSERT(to_ != NULL);
715 ASSERT(heap_ != NULL); 724 ASSERT(heap_ != NULL);
716 Isolate* isolate = heap_->isolate(); 725 Isolate* isolate = heap_->isolate();
717 ASSERT(isolate != NULL); 726 ASSERT(isolate != NULL);
718 isolate->GetHeapNewCapacityMaxMetric()->SetValue( 727 isolate->GetHeapNewCapacityMaxMetric()->SetValue(
719 to_->size_in_words() * kWordSize); 728 to_->size_in_words() * kWordSize);
720 } 729 }
721 730
722 731
732 void Scavenger::UpdateMaxHeapUsage() {
733 if (heap_ == NULL) {
734 // Some unit tests.
735 return;
736 }
737 ASSERT(to_ != NULL);
738 ASSERT(heap_ != NULL);
739 Isolate* isolate = heap_->isolate();
740 ASSERT(isolate != NULL);
741 isolate->GetHeapNewUsedMaxMetric()->SetValue(UsedInWords() * kWordSize);
742 }
743
744
723 uword Scavenger::ProcessWeakProperty(RawWeakProperty* raw_weak, 745 uword Scavenger::ProcessWeakProperty(RawWeakProperty* raw_weak,
724 ScavengerVisitor* visitor) { 746 ScavengerVisitor* visitor) {
725 // The fate of the weak property is determined by its key. 747 // The fate of the weak property is determined by its key.
726 RawObject* raw_key = raw_weak->ptr()->key_; 748 RawObject* raw_key = raw_weak->ptr()->key_;
727 if (raw_key->IsHeapObject() && raw_key->IsNewObject()) { 749 if (raw_key->IsHeapObject() && raw_key->IsNewObject()) {
728 uword raw_addr = RawObject::ToAddr(raw_key); 750 uword raw_addr = RawObject::ToAddr(raw_key);
729 uword header = *reinterpret_cast<uword*>(raw_addr); 751 uword header = *reinterpret_cast<uword*>(raw_addr);
730 if (!IsForwarding(header)) { 752 if (!IsForwarding(header)) {
731 // Key is white. Delay the weak property. 753 // Key is white. Delay the weak property.
732 visitor->DelayWeakProperty(raw_weak); 754 visitor->DelayWeakProperty(raw_weak);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 int64_t run_time = OS::GetCurrentTimeMicros() - isolate->start_time(); 931 int64_t run_time = OS::GetCurrentTimeMicros() - isolate->start_time();
910 run_time = Utils::Maximum(run_time, static_cast<int64_t>(0)); 932 run_time = Utils::Maximum(run_time, static_cast<int64_t>(0));
911 double run_time_millis = MicrosecondsToMilliseconds(run_time); 933 double run_time_millis = MicrosecondsToMilliseconds(run_time);
912 double avg_time_between_collections = 934 double avg_time_between_collections =
913 run_time_millis / static_cast<double>(collections()); 935 run_time_millis / static_cast<double>(collections());
914 space.AddProperty("avgCollectionPeriodMillis", 936 space.AddProperty("avgCollectionPeriodMillis",
915 avg_time_between_collections); 937 avg_time_between_collections);
916 } else { 938 } else {
917 space.AddProperty("avgCollectionPeriodMillis", 0.0); 939 space.AddProperty("avgCollectionPeriodMillis", 0.0);
918 } 940 }
919 space.AddProperty("used", UsedInWords() * kWordSize); 941 space.AddProperty64("used", UsedInWords() * kWordSize);
920 space.AddProperty("capacity", CapacityInWords() * kWordSize); 942 space.AddProperty64("capacity", CapacityInWords() * kWordSize);
921 space.AddProperty("external", ExternalInWords() * kWordSize); 943 space.AddProperty64("external", ExternalInWords() * kWordSize);
922 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); 944 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros()));
923 } 945 }
924 946
925 947
926 void Scavenger::AllocateExternal(intptr_t size) { 948 void Scavenger::AllocateExternal(intptr_t size) {
927 ASSERT(size >= 0); 949 ASSERT(size >= 0);
928 external_size_ += size; 950 external_size_ += size;
929 } 951 }
930 952
931 953
932 void Scavenger::FreeExternal(intptr_t size) { 954 void Scavenger::FreeExternal(intptr_t size) {
933 ASSERT(size >= 0); 955 ASSERT(size >= 0);
934 external_size_ -= size; 956 external_size_ -= size;
935 ASSERT(external_size_ >= 0); 957 ASSERT(external_size_ >= 0);
936 } 958 }
937 959
938 } // namespace dart 960 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/scavenger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698