Revision: 9138
Author: [email protected]
Date: Mon Sep 5 04:54:49 2011
Log: Speed up incremental marking if the heap size doubled
since we started or if the space remaining halves.
Review URL: http://codereview.chromium.org/7737024
http://code.google.com/p/v8/source/detail?r=9138
Modified:
/branches/experimental/gc/src/heap.h
/branches/experimental/gc/src/incremental-marking.cc
/branches/experimental/gc/src/incremental-marking.h
=======================================
--- /branches/experimental/gc/src/heap.h Mon Sep 5 04:23:41 2011
+++ /branches/experimental/gc/src/heap.h Mon Sep 5 04:54:49 2011
@@ -1209,16 +1209,18 @@
MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length,
PretenureFlag
pretenure);
+ inline intptr_t PromotedTotalSize() {
+ return PromotedSpaceSize() + PromotedExternalMemorySize();
+ }
+
// True if we have reached the allocation limit in the old generation
that
// should force the next GC (caused normally) to be a full one.
inline bool OldGenerationPromotionLimitReached() {
- return (PromotedSpaceSize() + PromotedExternalMemorySize())
- > old_gen_promotion_limit_;
+ return PromotedTotalSize() > old_gen_promotion_limit_;
}
inline intptr_t OldGenerationSpaceAvailable() {
- return old_gen_allocation_limit_ -
- (PromotedSpaceSize() + PromotedExternalMemorySize());
+ return old_gen_allocation_limit_ - PromotedTotalSize();
}
static const intptr_t kMinimumPromotionLimit = 5 * Page::kPageSize;
@@ -1305,8 +1307,7 @@
inline bool NextGCIsLikelyToBeFull() {
if (FLAG_gc_global) return true;
- intptr_t total_promoted =
- PromotedSpaceSize() + PromotedExternalMemorySize();
+ intptr_t total_promoted = PromotedTotalSize();
intptr_t adjusted_promotion_limit =
old_gen_promotion_limit_ - new_space_.Capacity();
=======================================
--- /branches/experimental/gc/src/incremental-marking.cc Tue Aug 23
09:03:55 2011
+++ /branches/experimental/gc/src/incremental-marking.cc Mon Sep 5
04:54:49 2011
@@ -43,6 +43,8 @@
steps_count_(0),
steps_took_(0),
longest_step_(0.0),
+ old_generation_space_available_at_start_of_incremental_(0),
+ old_generation_space_used_at_start_of_incremental_(0),
steps_count_since_last_gc_(0),
steps_took_since_last_gc_(0),
should_hurry_(false),
@@ -583,7 +585,32 @@
steps_count_++;
steps_count_since_last_gc_++;
- if ((steps_count_ % kAllocationMarkingFactorSpeedupInterval) == 0) {
+ bool speed_up = false;
+
+ if (old_generation_space_available_at_start_of_incremental_ < 10 * MB ||
+ SpaceLeftInOldSpace() <
+ old_generation_space_available_at_start_of_incremental_ >> 1) {
+ // Half of the space that was available is gone while we were
+ // incrementally marking.
+ speed_up = true;
+ old_generation_space_available_at_start_of_incremental_ =
+ SpaceLeftInOldSpace();
+ }
+
+ if (heap_->PromotedTotalSize() >
+ old_generation_space_used_at_start_of_incremental_ << 1) {
+ // Size of old space doubled while we were incrementally marking.
+ speed_up = true;
+ old_generation_space_used_at_start_of_incremental_ =
+ heap_->PromotedTotalSize();
+ }
+
+ if ((steps_count_ % kAllocationMarkingFactorSpeedupInterval) == 0 &&
+ allocation_marking_factor_ < kMaxAllocationMarkingFactor) {
+ speed_up = true;
+ }
+
+ if (speed_up && 0) {
allocation_marking_factor_ += kAllocationMarkingFactorSpeedup;
allocation_marking_factor_ =
static_cast<int>(allocation_marking_factor_ * 1.3);
@@ -602,4 +629,23 @@
}
+void IncrementalMarking::ResetStepCounters() {
+ steps_count_ = 0;
+ steps_took_ = 0;
+ longest_step_ = 0.0;
+ old_generation_space_available_at_start_of_incremental_ =
+ SpaceLeftInOldSpace();
+ old_generation_space_used_at_start_of_incremental_ =
+ heap_->PromotedTotalSize();
+ steps_count_since_last_gc_ = 0;
+ steps_took_since_last_gc_ = 0;
+ bytes_rescanned_ = 0;
+ allocation_marking_factor_ = kInitialAllocationMarkingFactor;
+}
+
+
+int64_t IncrementalMarking::SpaceLeftInOldSpace() {
+ return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSize();
+}
+
} } // namespace v8::internal
=======================================
--- /branches/experimental/gc/src/incremental-marking.h Tue Aug 23 09:03:55
2011
+++ /branches/experimental/gc/src/incremental-marking.h Mon Sep 5 04:54:49
2011
@@ -191,15 +191,9 @@
should_hurry_ = val;
}
- void ResetStepCounters() {
- steps_count_ = 0;
- steps_took_ = 0;
- longest_step_ = 0.0;
- steps_count_since_last_gc_ = 0;
- steps_took_since_last_gc_ = 0;
- bytes_rescanned_ = 0;
- allocation_marking_factor_ = kInitialAllocationMarkingFactor;
- }
+ int64_t SpaceLeftInOldSpace();
+
+ void ResetStepCounters();
void StartMarking();
@@ -227,6 +221,8 @@
int steps_count_;
double steps_took_;
double longest_step_;
+ int64_t old_generation_space_available_at_start_of_incremental_;
+ int64_t old_generation_space_used_at_start_of_incremental_;
int steps_count_since_last_gc_;
double steps_took_since_last_gc_;
int64_t bytes_rescanned_;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev