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);
}
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()
++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".
}
+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) + 1);
+}
+
+
double GCTracer::ContextDisposalRateInMilliseconds() const {
if (context_disposal_events_.size() < kRingBufferMaxSize) return 0.0;
// 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.
// 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());
}
}
-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();
}
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;
}
break;
}
- ReduceNewSpaceSize(action);
return result;
}
void Heap::ZapFromSpace() {
+ if (!new_space_.IsFromSpaceCommitted()) return;
NewSpacePageIterator it(new_space_.FromSpaceStart(),
new_space_.FromSpaceEnd());
while (it.has_next()) {
void SelectScavengingVisitorsTable();
- void ReduceNewSpaceSize(GCIdleTimeAction action);
+ bool HasLowAllocationRate(size_t allocaion_rate);
+
+ void ReduceNewSpaceSize(size_t allocaion_rate);
bool TryFinalizeIdleIncrementalMarking(
double idle_time_in_ms, size_t size_of_objects,
return from_space_.Uncommit();
}
+ bool IsFromSpaceCommitted() { return from_space_.is_committed(); }
+
inline intptr_t inline_allocation_limit_step() {
return inline_allocation_limit_step_;
}
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);