Reviewers: ulan,
Description:
Clean up the marking speed heuristics. This reduces the
max heap size on 64 bit from ca. 300Mbytes to ca. 200Mbytes
on Ulan's splay variant. On 32 bit not much change.
Please review this at http://codereview.chromium.org/8494012/
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M src/incremental-marking-inl.h
M src/incremental-marking.h
M src/incremental-marking.cc
Index: src/incremental-marking-inl.h
===================================================================
--- src/incremental-marking-inl.h (revision 9899)
+++ src/incremental-marking-inl.h (working copy)
@@ -96,6 +96,7 @@
Marking::BlackToGrey(mark_bit);
int obj_size = obj->Size();
MemoryChunk::IncrementLiveBytes(obj->address(), -obj_size);
+ bytes_scanned_ -= obj_size;
int64_t old_bytes_rescanned = bytes_rescanned_;
bytes_rescanned_ = old_bytes_rescanned + obj_size;
if ((bytes_rescanned_ >> 20) != (old_bytes_rescanned >> 20)) {
Index: src/incremental-marking.cc
===================================================================
--- src/incremental-marking.cc (revision 9899)
+++ src/incremental-marking.cc (working copy)
@@ -747,6 +747,7 @@
if (state_ == MARKING && no_marking_scope_depth_ > 0) return;
intptr_t bytes_to_process = allocated_ * allocation_marking_factor_;
+ bytes_scanned_ += bytes_to_process;
double start = 0;
@@ -808,33 +809,50 @@
bool speed_up = false;
+ if ((steps_count_ % kAllocationMarkingFactorSpeedupInterval) == 0) {
+ if (FLAG_trace_gc) {
+ PrintF("Speed up marking after %d steps\n",
+ static_cast<int>(kAllocationMarkingFactorSpeedupInterval));
+ }
+ speed_up = true;
+ }
+
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
+ SpaceLeftInOldSpace() * (allocation_marking_factor_ + 1) <
+ old_generation_space_available_at_start_of_incremental_) {
+ // 1/n of the space that was available is gone while we were
// incrementally marking.
+ if (FLAG_trace_gc) PrintF("Speed up marking because of low space
left\n");
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.
+ (allocation_marking_factor_ + 1) *
+ old_generation_space_used_at_start_of_incremental_) {
+ // Size of old space multiplied by n while we were incrementally
marking.
speed_up = true;
- old_generation_space_used_at_start_of_incremental_ =
- heap_->PromotedTotalSize();
+ if (FLAG_trace_gc) {
+ PrintF("Speed up marking because of heap size increase\n");
+ }
}
- if ((steps_count_ % kAllocationMarkingFactorSpeedupInterval) == 0 &&
- allocation_marking_factor_ < kMaxAllocationMarkingFactor) {
+ // We try to scan at at least twice the speed that we are allocating.
+ if ((bytes_scanned_ >> 1)
+ + heap_->MaxSemiSpaceSize() // A single scavenge cannot trigger
this.
+ + allocation_marking_factor_ * MB < // Delay before upping
again.
+ heap_->PromotedTotalSize()
+ - old_generation_space_used_at_start_of_incremental_) {
+ if (FLAG_trace_gc) {
+ PrintF("Speed up marking because marker was not keeping up\n");
+ }
speed_up = true;
}
if (speed_up) {
allocation_marking_factor_ += kAllocationMarkingFactorSpeedup;
allocation_marking_factor_ =
- static_cast<int>(allocation_marking_factor_ * 1.3);
+ Min(kMaxAllocationMarkingFactor,
+ static_cast<intptr_t>(allocation_marking_factor_ * 1.3));
if (FLAG_trace_gc) {
PrintF("Marking speed increased to %d\n",
allocation_marking_factor_);
}
@@ -862,6 +880,7 @@
steps_took_since_last_gc_ = 0;
bytes_rescanned_ = 0;
allocation_marking_factor_ = kInitialAllocationMarkingFactor;
+ bytes_scanned_ = 0;
}
Index: src/incremental-marking.h
===================================================================
--- src/incremental-marking.h (revision 9899)
+++ src/incremental-marking.h (working copy)
@@ -96,7 +96,7 @@
static const intptr_t kAllocationMarkingFactorSpeedupInterval = 1024;
// This is how much we increase the marking/allocating factor by.
static const intptr_t kAllocationMarkingFactorSpeedup = 2;
- static const intptr_t kMaxAllocationMarkingFactor = 1000000000;
+ static const intptr_t kMaxAllocationMarkingFactor = 100000;
void OldSpaceStep(intptr_t allocated) {
Step(allocated * kFastMarking / kInitialAllocationMarkingFactor);
@@ -262,6 +262,7 @@
int64_t bytes_rescanned_;
bool should_hurry_;
int allocation_marking_factor_;
+ intptr_t bytes_scanned_;
intptr_t allocated_;
int no_marking_scope_depth_;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev