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

Side by Side Diff: runtime/vm/pages.cc

Issue 10876095: Increase the page space growth rate when there is insufficient free space. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/pages.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) 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/pages.h" 5 #include "vm/pages.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/gc_marker.h" 8 #include "vm/gc_marker.h"
9 #include "vm/gc_sweeper.h" 9 #include "vm/gc_sweeper.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 sweeping_ = false; 459 sweeping_ = false;
460 } 460 }
461 461
462 462
463 PageSpaceController::PageSpaceController(int heap_growth_ratio, 463 PageSpaceController::PageSpaceController(int heap_growth_ratio,
464 int heap_growth_rate, 464 int heap_growth_rate,
465 int garbage_collection_time_ratio) 465 int garbage_collection_time_ratio)
466 : is_enabled_(false), 466 : is_enabled_(false),
467 grow_heap_(heap_growth_rate), 467 grow_heap_(heap_growth_rate),
468 heap_growth_ratio_(heap_growth_ratio), 468 heap_growth_ratio_(heap_growth_ratio),
469 desired_utilization_((100.0 - heap_growth_ratio) / 100.0),
469 heap_growth_rate_(heap_growth_rate), 470 heap_growth_rate_(heap_growth_rate),
470 garbage_collection_time_ratio_(garbage_collection_time_ratio) { 471 garbage_collection_time_ratio_(garbage_collection_time_ratio) {
471 } 472 }
472 473
473 474
474 PageSpaceController::~PageSpaceController() {} 475 PageSpaceController::~PageSpaceController() {}
475 476
476 477
477 bool PageSpaceController::CanGrowPageSpace(intptr_t size_in_bytes) { 478 bool PageSpaceController::CanGrowPageSpace(intptr_t size_in_bytes) {
478 size_in_bytes = Utils::RoundUp(size_in_bytes, PageSpace::kPageSize); 479 size_in_bytes = Utils::RoundUp(size_in_bytes, PageSpace::kPageSize);
479 intptr_t size_in_pages = size_in_bytes / PageSpace::kPageSize; 480 intptr_t size_in_pages = size_in_bytes / PageSpace::kPageSize;
480 if (!is_enabled_) { 481 if (!is_enabled_) {
481 return true; 482 return true;
482 } 483 }
483 if (heap_growth_ratio_ == 100) { 484 if (heap_growth_ratio_ == 100) {
484 return true; 485 return true;
485 } 486 }
486 if (grow_heap_ <= 0) { 487 if (grow_heap_ <= 0) {
487 return false; 488 return false;
488 } 489 }
489 grow_heap_ -= size_in_pages; 490 grow_heap_ -= size_in_pages;
490 return true; 491 return true;
491 } 492 }
492 493
493 494
494 void PageSpaceController::EvaluateGarbageCollection( 495 void PageSpaceController::EvaluateGarbageCollection(
495 size_t in_use_before, size_t in_use_after, int64_t start, int64_t end) { 496 intptr_t in_use_before, intptr_t in_use_after, int64_t start, int64_t end) {
496 ASSERT(in_use_before >= in_use_after); 497 ASSERT(in_use_before >= in_use_after);
497 ASSERT(end >= start); 498 ASSERT(end >= start);
498 history_.AddGarbageCollectionTime(start, end); 499 history_.AddGarbageCollectionTime(start, end);
499 int collected_garbage_ratio = 500 int collected_garbage_ratio =
500 static_cast<int>((static_cast<double>(in_use_before - in_use_after) / 501 static_cast<int>((static_cast<double>(in_use_before - in_use_after) /
501 static_cast<double>(in_use_before)) * 100); 502 static_cast<double>(in_use_before))
503 * 100.0);
502 bool enough_free_space = 504 bool enough_free_space =
503 (collected_garbage_ratio >= heap_growth_ratio_); 505 (collected_garbage_ratio >= heap_growth_ratio_);
504 int garbage_collection_time_fraction = 506 int garbage_collection_time_fraction =
505 history_.GarbageCollectionTimeFraction(); 507 history_.GarbageCollectionTimeFraction();
506 bool enough_free_time = 508 bool enough_free_time =
507 (garbage_collection_time_fraction <= garbage_collection_time_ratio_); 509 (garbage_collection_time_fraction <= garbage_collection_time_ratio_);
508 if (enough_free_space && enough_free_time) { 510 if (enough_free_space && enough_free_time) {
509 grow_heap_ = 0; 511 grow_heap_ = 0;
510 } else { 512 } else {
511 if (FLAG_verbose_gc) { 513 if (FLAG_verbose_gc) {
512 OS::PrintErr("PageSpaceController: "); 514 OS::PrintErr("PageSpaceController: ");
513 if (!enough_free_space) { 515 if (!enough_free_space) {
514 OS::PrintErr("free space %d%% < %d%%", 516 OS::PrintErr("free space %d%% < %d%%",
515 collected_garbage_ratio, 517 collected_garbage_ratio,
516 heap_growth_ratio_); 518 heap_growth_ratio_);
517 } 519 }
518 if (!enough_free_space && !enough_free_time) { 520 if (!enough_free_space && !enough_free_time) {
519 OS::PrintErr(", "); 521 OS::PrintErr(", ");
520 } 522 }
521 if (!enough_free_time) { 523 if (!enough_free_time) {
522 OS::PrintErr("garbage collection time %d%% > %d%%", 524 OS::PrintErr("garbage collection time %d%% > %d%%",
523 garbage_collection_time_fraction, 525 garbage_collection_time_fraction,
524 garbage_collection_time_ratio_); 526 garbage_collection_time_ratio_);
525 } 527 }
526 OS::PrintErr("\n"); 528 OS::PrintErr("\n");
527 } 529 }
528 grow_heap_ = heap_growth_rate_; 530 if (!enough_free_space) {
531 intptr_t growth_target = static_cast<intptr_t>(in_use_after /
532 desired_utilization_);
533 intptr_t growth_in_bytes = Utils::RoundUp(growth_target - in_use_after,
534 PageSpace::kPageSize);
535 intptr_t growth_in_pages = growth_in_bytes / PageSpace::kPageSize;
536 grow_heap_ = Utils::Maximum(growth_in_pages, heap_growth_rate_);
537 } else {
538 grow_heap_ = heap_growth_rate_;
539 }
529 } 540 }
530 } 541 }
531 542
532 543
533 PageSpaceGarbageCollectionHistory::PageSpaceGarbageCollectionHistory() 544 PageSpaceGarbageCollectionHistory::PageSpaceGarbageCollectionHistory()
534 : index_(0) { 545 : index_(0) {
535 for (intptr_t i = 0; i < kHistoryLength; i++) { 546 for (intptr_t i = 0; i < kHistoryLength; i++) {
536 start_[i] = 0; 547 start_[i] = 0;
537 end_[i] = 0; 548 end_[i] = 0;
538 } 549 }
(...skipping 28 matching lines...) Expand all
567 return 0; 578 return 0;
568 } else { 579 } else {
569 ASSERT(total_time >= gc_time); 580 ASSERT(total_time >= gc_time);
570 int result= static_cast<int>((static_cast<double>(gc_time) / 581 int result= static_cast<int>((static_cast<double>(gc_time) /
571 static_cast<double>(total_time)) * 100); 582 static_cast<double>(total_time)) * 100);
572 return result; 583 return result;
573 } 584 }
574 } 585 }
575 586
576 } // namespace dart 587 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698