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

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

Issue 10576004: Log growth policy decisions when verbose gc is enabled. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 6 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 prev_page = page; 374 prev_page = page;
375 } 375 }
376 // Advance to the next page. 376 // Advance to the next page.
377 page = next_page; 377 page = next_page;
378 } 378 }
379 379
380 // Record data and print if requested. 380 // Record data and print if requested.
381 intptr_t in_use_before = in_use_; 381 intptr_t in_use_before = in_use_;
382 in_use_ = in_use; 382 in_use_ = in_use;
383 383
384 int64_t end = OS::GetCurrentTimeMillis();
384 timer.Stop(); 385 timer.Stop();
385 386
386 // Record signals for growth control. 387 // Record signals for growth control.
387 int64_t elapsed = timer.TotalElapsedTime() * kMicrosecondsPerMillisecond;
388 page_space_controller_.EvaluateGarbageCollection(in_use_before, in_use, 388 page_space_controller_.EvaluateGarbageCollection(in_use_before, in_use,
389 start, start + elapsed); 389 start, end);
390 390
391 if (FLAG_verbose_gc) { 391 if (FLAG_verbose_gc) {
392 const intptr_t KB2 = KB / 2; 392 const intptr_t KB2 = KB / 2;
393 OS::PrintErr("Mark-Sweep[%d]: %lldus (%dK -> %dK, %dK)\n", 393 OS::PrintErr("Mark-Sweep[%d]: %lldus (%dK -> %dK, %dK)\n",
394 count_, 394 count_,
395 timer.TotalElapsedTime(), 395 timer.TotalElapsedTime(),
396 (in_use_before + (KB2)) / KB, 396 (in_use_before + (KB2)) / KB,
397 (in_use + (KB2)) / KB, 397 (in_use + (KB2)) / KB,
398 (capacity_ + KB2) / KB); 398 (capacity_ + KB2) / KB);
399 } 399 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 443
444 444
445 void PageSpaceController::EvaluateGarbageCollection( 445 void PageSpaceController::EvaluateGarbageCollection(
446 size_t in_use_before, size_t in_use_after, int64_t start, int64_t end) { 446 size_t in_use_before, size_t in_use_after, int64_t start, int64_t end) {
447 ASSERT(in_use_before >= in_use_after); 447 ASSERT(in_use_before >= in_use_after);
448 ASSERT(end >= start); 448 ASSERT(end >= start);
449 history_.AddGarbageCollectionTime(start, end); 449 history_.AddGarbageCollectionTime(start, end);
450 int collected_garbage_ratio = 450 int collected_garbage_ratio =
451 static_cast<int>((static_cast<double>(in_use_before - in_use_after) / 451 static_cast<int>((static_cast<double>(in_use_before - in_use_after) /
452 static_cast<double>(in_use_before)) * 100); 452 static_cast<double>(in_use_before)) * 100);
453 if ((collected_garbage_ratio > heap_growth_ratio_) && 453 bool enough_free_space =
454 (history_.GarbageCollectionTimeFraction() < 454 (collected_garbage_ratio >= heap_growth_ratio_);
455 garbage_collection_time_ratio_)) { 455 int garbage_collection_time_fraction =
456 history_.GarbageCollectionTimeFraction();
457 bool enough_free_time =
458 (garbage_collection_time_fraction <= garbage_collection_time_ratio_);
459 if (enough_free_space && enough_free_time) {
456 grow_heap_ = 0; 460 grow_heap_ = 0;
457 } else { 461 } else {
462 if (FLAG_verbose_gc) {
463 OS::PrintErr("PageSpaceController: ");
464 if (!enough_free_space) {
465 OS::PrintErr("free space %d%% < %d%%",
466 collected_garbage_ratio,
467 heap_growth_ratio_);
468 }
469 if (!enough_free_space && !enough_free_time) {
470 OS::PrintErr(", ");
471 }
472 if (!enough_free_time) {
473 OS::PrintErr("garbage collection time %d%% > %d%%",
474 garbage_collection_time_fraction,
475 garbage_collection_time_ratio_);
476 }
477 OS::PrintErr("\n");
478 }
458 grow_heap_ = heap_growth_rate_; 479 grow_heap_ = heap_growth_rate_;
459 } 480 }
460 } 481 }
461 482
462 483
463 PageSpaceGarbageCollectionHistory::PageSpaceGarbageCollectionHistory() 484 PageSpaceGarbageCollectionHistory::PageSpaceGarbageCollectionHistory()
464 : index_(0) { 485 : index_(0) {
465 for (uint32_t i = 0; i < kHistoryLength; i++) { 486 for (intptr_t i = 0; i < kHistoryLength; i++) {
466 start_[i] = 0; 487 start_[i] = 0;
467 end_[i] = 0; 488 end_[i] = 0;
468 } 489 }
469 } 490 }
470 491
471 492
472 void PageSpaceGarbageCollectionHistory:: 493 void PageSpaceGarbageCollectionHistory::
473 AddGarbageCollectionTime(uint64_t start, uint64_t end) { 494 AddGarbageCollectionTime(int64_t start, int64_t end) {
474 int index = index_ % kHistoryLength; 495 int index = index_ % kHistoryLength;
475 start_[index] = start; 496 start_[index] = start;
476 end_[index] = end; 497 end_[index] = end;
477 index_++; 498 index_++;
478 } 499 }
479 500
480 501
481 int PageSpaceGarbageCollectionHistory::GarbageCollectionTimeFraction() { 502 int PageSpaceGarbageCollectionHistory::GarbageCollectionTimeFraction() {
482 int current; 503 int current;
483 int previous; 504 int previous;
484 uint64_t gc_time = 0; 505 int64_t gc_time = 0;
485 uint64_t total_time = 0; 506 int64_t total_time = 0;
486 for (uint32_t i = 1; i < kHistoryLength; i++) { 507 for (intptr_t i = 1; i < kHistoryLength; i++) {
487 current = (index_ - i) % kHistoryLength; 508 current = (index_ - i) % kHistoryLength;
488 previous = (index_ - 1 - i) % kHistoryLength; 509 previous = (index_ - 1 - i) % kHistoryLength;
489 if (end_[previous] == 0) { 510 if (end_[previous] == 0) {
490 break; 511 break;
491 } 512 }
492 // iterate over the circular buffer in reverse order 513 // iterate over the circular buffer in reverse order
493 gc_time += end_[current] - start_[current]; 514 gc_time += end_[current] - start_[current];
494 total_time += end_[current] - end_[previous]; 515 total_time += end_[current] - end_[previous];
495 } 516 }
496 if (total_time == 0) { 517 if (total_time == 0) {
497 return 0; 518 return 0;
498 } else { 519 } else {
499 return static_cast<int>((static_cast<double>(gc_time) / 520 ASSERT(total_time >= gc_time);
500 static_cast<double>(total_time))*100); 521 int result= static_cast<int>((static_cast<double>(gc_time) /
522 static_cast<double>(total_time)) * 100);
523 return result;
501 } 524 }
502 } 525 }
503 526
504 } // namespace dart 527 } // 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