Reviewers: ulan,
Description:
Uncommit and shrink semi-spaces only on low allocation rate.
BUG=
Please review this at https://codereview.chromium.org/1148633005/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+37, -7 lines):
M src/heap/gc-idle-time-handler.h
M src/heap/gc-idle-time-handler.cc
M src/heap/gc-tracer.h
M src/heap/gc-tracer.cc
M src/heap/heap.h
M src/heap/heap.cc
M test/cctest/test-heap.cc
Index: src/heap/gc-idle-time-handler.cc
diff --git a/src/heap/gc-idle-time-handler.cc
b/src/heap/gc-idle-time-handler.cc
index
e88710bd1d10533c8905aab3ef1a8422e95feba2..86587c6fd19671d919a291da07a31a21fcdf4886
100644
--- a/src/heap/gc-idle-time-handler.cc
+++ b/src/heap/gc-idle-time-handler.cc
@@ -58,8 +58,10 @@ void GCIdleTimeHandler::HeapState::Print() {
PrintF("scavenge_speed=%" V8_PTR_PREFIX "d ",
scavenge_speed_in_bytes_per_ms);
PrintF("new_space_size=%" V8_PTR_PREFIX "d ", used_new_space_size);
PrintF("new_space_capacity=%" V8_PTR_PREFIX "d ", new_space_capacity);
- PrintF("new_space_allocation_throughput=%" V8_PTR_PREFIX "d",
+ PrintF("new_space_allocation_throughput=%" V8_PTR_PREFIX "d ",
new_space_allocation_throughput_in_bytes_per_ms);
+ PrintF("current_new_space_allocation_throughput=%" V8_PTR_PREFIX "d",
+ current_new_space_allocation_throughput_in_bytes_per_ms);
}
Index: src/heap/gc-idle-time-handler.h
diff --git a/src/heap/gc-idle-time-handler.h
b/src/heap/gc-idle-time-handler.h
index
5c0a80a1d25653107afac42b393bc16179977646..e5b671cd063d9b4e36444a23fc8908dfbda07ab9
100644
--- a/src/heap/gc-idle-time-handler.h
+++ b/src/heap/gc-idle-time-handler.h
@@ -188,6 +188,7 @@ class GCIdleTimeHandler {
size_t used_new_space_size;
size_t new_space_capacity;
size_t new_space_allocation_throughput_in_bytes_per_ms;
+ size_t current_new_space_allocation_throughput_in_bytes_per_ms;
};
GCIdleTimeHandler()
Index: src/heap/gc-tracer.cc
diff --git a/src/heap/gc-tracer.cc b/src/heap/gc-tracer.cc
index
927915d7554bae15b4e26c43b997734824f8c231..2f48d92e44db2f0af25f2a27df23f49afd74b4bc
100644
--- a/src/heap/gc-tracer.cc
+++ b/src/heap/gc-tracer.cc
@@ -610,7 +610,7 @@ size_t GCTracer::NewSpaceAllocatedBytesInLast(double
time_ms) const {
++iter;
}
- if (durations < time_ms) return 0;
+ if (durations == 0.0) return 0;
bytes = static_cast<size_t>(bytes * (time_ms / durations) + 0.5);
// Return at least 1 since 0 means "no data".
@@ -618,6 +618,15 @@ size_t GCTracer::NewSpaceAllocatedBytesInLast(double
time_ms) const {
}
+size_t GCTracer::CurrentNewSpaceAllocationThroughputInBytesPerMillisecond()
+ const {
+ static const double kThroughputTimeFrame = 5000;
+ size_t allocated_bytes =
NewSpaceAllocatedBytesInLast(kThroughputTimeFrame);
+ if (allocated_bytes == 0) return 0;
+ return static_cast<size_t>(allocated_bytes / kThroughputTimeFrame);
+}
+
+
double GCTracer::ContextDisposalRateInMilliseconds() const {
if (context_disposal_events_.size() < kRingBufferMaxSize) return 0.0;
Index: src/heap/gc-tracer.h
diff --git a/src/heap/gc-tracer.h b/src/heap/gc-tracer.h
index
df30dccb6b5dd18d3ea4694241d348bbb7514e91..7fb6a766a6037181758eebd67eadaaa8f23b8bef
100644
--- a/src/heap/gc-tracer.h
+++ b/src/heap/gc-tracer.h
@@ -389,6 +389,11 @@ class GCTracer {
// Returns 0 if no allocation events have been recorded.
size_t NewSpaceAllocatedBytesInLast(double time_ms) const;
+ // Allocation throughput in the new space in bytes/milliseconds in
+ // the last five seconds.
+ // Returns 0 if no allocation events have been recorded.
+ size_t CurrentNewSpaceAllocationThroughputInBytesPerMillisecond() const;
+
// Computes the context disposal rate in milliseconds. It takes the time
// frame of the first recorded context disposal to the current time and
// divides it by the number of recorded events.
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
5a10a5cd210ac4da9700d1a746410fc787f93c6c..ac8ceef4101da5b65a65a9667dd08657833b1a62
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -4565,8 +4565,16 @@ void Heap::MakeHeapIterable() {
}
-void Heap::ReduceNewSpaceSize(GCIdleTimeAction action) {
- if (action.reduce_memory &&
+bool Heap::HasLowAllocationRate(GCIdleTimeHandler::HeapState heap_state) {
+ static const size_t kLowAllocationRate = 1000;
+ return
heap_state.current_new_space_allocation_throughput_in_bytes_per_ms <
+ kLowAllocationRate;
+}
+
+
+void Heap::ReduceNewSpaceSize(GCIdleTimeAction action,
+ GCIdleTimeHandler::HeapState heap_state) {
+ if (HasLowAllocationRate(heap_state) &&
(action.type == DO_SCAVENGE || action.type == DO_FULL_GC ||
(action.type == DO_INCREMENTAL_MARKING &&
incremental_marking()->IsStopped()))) {
@@ -4635,6 +4643,8 @@ GCIdleTimeHandler::HeapState
Heap::ComputeHeapState(bool reduce_memory) {
heap_state.new_space_capacity = new_space_.Capacity();
heap_state.new_space_allocation_throughput_in_bytes_per_ms =
tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond();
+ heap_state.current_new_space_allocation_throughput_in_bytes_per_ms =
+ tracer()->CurrentNewSpaceAllocationThroughputInBytesPerMillisecond();
return heap_state;
}
@@ -4697,7 +4707,7 @@ bool Heap::PerformIdleTimeAction(GCIdleTimeAction
action,
break;
}
- ReduceNewSpaceSize(action);
+ ReduceNewSpaceSize(action, heap_state);
return result;
}
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index
8ecf7ae1328df4e495242eb777a128b1e7d6efc0..95d6c806580848dcad7b64008263aacc3debe6c1
100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -2127,7 +2127,10 @@ class Heap {
void SelectScavengingVisitorsTable();
- void ReduceNewSpaceSize(GCIdleTimeAction action);
+ bool HasLowAllocationRate(GCIdleTimeHandler::HeapState heap_state);
+
+ void ReduceNewSpaceSize(GCIdleTimeAction action,
+ GCIdleTimeHandler::HeapState heap_state);
bool TryFinalizeIdleIncrementalMarking(
double idle_time_in_ms, size_t size_of_objects,
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index
d441ab6afe2c03c999b89be96e8ca6f491e7de11..36988ad78968133c0c447965ffc5fdec1d880610
100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -5551,7 +5551,7 @@ TEST(NewSpaceAllocationThroughput2) {
size_t counter2 = 2000;
tracer->SampleNewSpaceAllocation(time2, counter2);
size_t bytes = tracer->NewSpaceAllocatedBytesInLast(1000);
- CHECK_EQ(0, bytes);
+ CHECK_EQ(10000, bytes);
int time3 = 1000;
size_t counter3 = 30000;
tracer->SampleNewSpaceAllocation(time3, counter3);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.