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

Unified Diff: src/heap/heap.cc

Issue 1148633005: Uncommit and shrink semi-spaces only on low allocation rate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/spaces.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 8b08802f461acd17f24c2e2676a39f2812fcd684..4e4f04a11293e71b330eba36293406c69c8e628d 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -733,6 +733,9 @@ void Heap::GarbageCollectionEpilogue() {
// whether we allocated in new space since the last GC.
new_space_top_after_last_gc_ = new_space()->top();
last_gc_time_ = MonotonicallyIncreasingTimeInMs();
+
+ ReduceNewSpaceSize(
+ tracer()->CurrentNewSpaceAllocationThroughputInBytesPerMillisecond());
}
@@ -4569,11 +4572,15 @@ void Heap::MakeHeapIterable() {
}
-void Heap::ReduceNewSpaceSize(GCIdleTimeAction action) {
- if (action.reduce_memory &&
- (action.type == DO_SCAVENGE || action.type == DO_FULL_GC ||
- (action.type == DO_INCREMENTAL_MARKING &&
- incremental_marking()->IsStopped()))) {
+bool Heap::HasLowAllocationRate(size_t allocation_rate) {
+ static const size_t kLowAllocationRate = 1000;
+ if (allocation_rate == 0) return false;
+ return allocation_rate < kLowAllocationRate;
+}
+
+
+void Heap::ReduceNewSpaceSize(size_t allocation_rate) {
+ if (HasLowAllocationRate(allocation_rate)) {
new_space_.Shrink();
UncommitFromSpace();
}
@@ -4639,6 +4646,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;
}
@@ -4701,7 +4710,6 @@ bool Heap::PerformIdleTimeAction(GCIdleTimeAction action,
break;
}
- ReduceNewSpaceSize(action);
return result;
}
@@ -4966,6 +4974,7 @@ void Heap::Verify() {
void Heap::ZapFromSpace() {
+ if (!new_space_.IsFromSpaceCommitted()) return;
NewSpacePageIterator it(new_space_.FromSpaceStart(),
new_space_.FromSpaceEnd());
while (it.has_next()) {
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698