Commit aceb7d67 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[oilpan] Fix for EsimateLiveSize

Take current value for base size, similarly to what is used for
PartitionAlloc. This makes sure that an esimate is computed at the time
of calling the method.

Bug: chromium:840789
Change-Id: Iab7e63f5395cbc74226cd786d420c6145fdb7dd9
Reviewed-on: https://chromium-review.googlesource.com/1094822Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKeishi Hattori <keishi@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565967}
parent ab7eaacc
......@@ -382,30 +382,30 @@ size_t ThreadState::TotalMemorySize() {
}
size_t ThreadState::EstimatedLiveSize(size_t estimation_base_size,
size_t size_at_last_gc) {
size_t size_at_prev_gc) {
const ThreadHeapStatsCollector& stats_collector = *heap_->stats_collector();
const ThreadHeapStatsCollector::Event& prev = stats_collector.previous();
if (prev.wrapper_count_before_sweeping == 0)
return estimation_base_size;
// (estimated size) = (estimation base size) - (heap size at the last GC) /
// (# of persistent handles at the last GC) *
// (# of persistent handles collected since the last GC)
size_t size_retained_by_collected_persistents = static_cast<size_t>(
1.0 * size_at_last_gc / prev.wrapper_count_before_sweeping *
stats_collector.collected_wrapper_count());
if (estimation_base_size < size_retained_by_collected_persistents)
// (estimated size) = (estimation base size) -
// (heap size at the last GC) *
// (# of persistent handles collected since the last GC) /
// (# of persistent handles at the last GC)
size_t size_freed_by_collecting_persistents =
static_cast<size_t>(static_cast<double>(size_at_prev_gc) *
stats_collector.collected_wrapper_count() /
prev.wrapper_count_before_sweeping);
if (estimation_base_size < size_freed_by_collecting_persistents)
return 0;
return estimation_base_size - size_retained_by_collected_persistents;
return estimation_base_size - size_freed_by_collecting_persistents;
}
double ThreadState::HeapGrowingRate() {
const size_t current_size = heap_->stats_collector()->object_size_in_bytes();
// TODO(mlippautz): Clarify those two parameters below.
const size_t estimated_size =
EstimatedLiveSize(heap_->stats_collector()->previous().marked_bytes,
heap_->stats_collector()->previous().marked_bytes);
const size_t estimated_size = EstimatedLiveSize(
current_size, heap_->stats_collector()->previous().marked_bytes);
// If the estimatedSize is 0, we set a high growing rate to trigger a GC.
double growing_rate =
......
......@@ -646,7 +646,15 @@ class PLATFORM_EXPORT ThreadState {
// conservative GC was performed to handle the emergency.
bool ForceMemoryPressureGCIfNeeded();
size_t EstimatedLiveSize(size_t current_size, size_t size_at_last_gc);
// Esimates the size of a heap based on |size_at_prev_gc| and wrapper counts
// (live and collected). |current_size| should be the currently allocated size
// for that heap.
//
// Note that this function should not be called while sweeping is running as
// it uses snapshots and live values collected during garbage collection and
// calling it during sweeping mixes garbage collection cycles.
size_t EstimatedLiveSize(size_t current_size, size_t size_at_prev_gc);
size_t TotalMemorySize();
double HeapGrowingRate();
double PartitionAllocGrowingRate();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment