Commit 95fa931e authored by Hannes Payer's avatar Hannes Payer Committed by Commit Bot

[heap] Clean up GCIdleTimeHandler.

Bug: chromium:1054771
Change-Id: Iaf1399a0ccc94f8f96cfdab4364eb918d58659d7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2073758Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66455}
parent 4e2ed06f
...@@ -12,10 +12,7 @@ namespace v8 { ...@@ -12,10 +12,7 @@ namespace v8 {
namespace internal { namespace internal {
const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9;
const size_t GCIdleTimeHandler::kMaxFinalIncrementalMarkCompactTimeInMs = 1000;
const double GCIdleTimeHandler::kHighContextDisposalRate = 100; const double GCIdleTimeHandler::kHighContextDisposalRate = 100;
const size_t GCIdleTimeHandler::kMinTimeForOverApproximatingWeakClosureInMs = 1;
void GCIdleTimeHeapState::Print() { void GCIdleTimeHeapState::Print() {
PrintF("contexts_disposed=%d ", contexts_disposed); PrintF("contexts_disposed=%d ", contexts_disposed);
...@@ -39,18 +36,6 @@ size_t GCIdleTimeHandler::EstimateMarkingStepSize( ...@@ -39,18 +36,6 @@ size_t GCIdleTimeHandler::EstimateMarkingStepSize(
return static_cast<size_t>(marking_step_size * kConservativeTimeRatio); return static_cast<size_t>(marking_step_size * kConservativeTimeRatio);
} }
double GCIdleTimeHandler::EstimateFinalIncrementalMarkCompactTime(
size_t size_of_objects,
double final_incremental_mark_compact_speed_in_bytes_per_ms) {
if (final_incremental_mark_compact_speed_in_bytes_per_ms == 0) {
final_incremental_mark_compact_speed_in_bytes_per_ms =
kInitialConservativeFinalIncrementalMarkCompactSpeed;
}
double result =
size_of_objects / final_incremental_mark_compact_speed_in_bytes_per_ms;
return Min<double>(result, kMaxFinalIncrementalMarkCompactTimeInMs);
}
bool GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact( bool GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact(
int contexts_disposed, double contexts_disposal_rate, int contexts_disposed, double contexts_disposal_rate,
size_t size_of_objects) { size_t size_of_objects) {
...@@ -59,34 +44,13 @@ bool GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact( ...@@ -59,34 +44,13 @@ bool GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact(
size_of_objects <= kMaxHeapSizeForContextDisposalMarkCompact; size_of_objects <= kMaxHeapSizeForContextDisposalMarkCompact;
} }
bool GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact(
double idle_time_in_ms, size_t size_of_objects,
double final_incremental_mark_compact_speed_in_bytes_per_ms) {
return idle_time_in_ms >=
EstimateFinalIncrementalMarkCompactTime(
size_of_objects,
final_incremental_mark_compact_speed_in_bytes_per_ms);
}
bool GCIdleTimeHandler::ShouldDoOverApproximateWeakClosure(
double idle_time_in_ms) {
// TODO(jochen): Estimate the time it will take to build the object groups.
return idle_time_in_ms >= kMinTimeForOverApproximatingWeakClosureInMs;
}
// The following logic is implemented by the controller: // The following logic is implemented by the controller:
// (1) If we don't have any idle time, do nothing, unless a context was // (1) If we don't have any idle time, do nothing, unless a context was
// disposed, incremental marking is stopped, and the heap is small. Then do // disposed, incremental marking is stopped, and the heap is small. Then do
// a full GC. // a full GC.
// (2) If the context disposal rate is high and we cannot perform a full GC, // (2) If the context disposal rate is high and we cannot perform a full GC,
// we do nothing until the context disposal rate becomes lower. // we do nothing until the context disposal rate becomes lower.
// (3) If the new space is almost full and we can afford a scavenge or if the // (3) If incremental marking is in progress, we perform a marking step.
// next scavenge will very likely take long, then a scavenge is performed.
// (4) If sweeping is in progress and we received a large enough idle time
// request, we finalize sweeping here.
// (5) If incremental marking is in progress, we perform a marking step. Note,
// that this currently may trigger a full garbage collection.
GCIdleTimeAction GCIdleTimeHandler::Compute(double idle_time_in_ms, GCIdleTimeAction GCIdleTimeHandler::Compute(double idle_time_in_ms,
GCIdleTimeHeapState heap_state) { GCIdleTimeHeapState heap_state) {
if (static_cast<int>(idle_time_in_ms) <= 0) { if (static_cast<int>(idle_time_in_ms) <= 0) {
......
...@@ -42,42 +42,15 @@ class V8_EXPORT_PRIVATE GCIdleTimeHandler { ...@@ -42,42 +42,15 @@ class V8_EXPORT_PRIVATE GCIdleTimeHandler {
// idle_time_in_ms. Hence, we conservatively prune our workload estimate. // idle_time_in_ms. Hence, we conservatively prune our workload estimate.
static const double kConservativeTimeRatio; static const double kConservativeTimeRatio;
// If we haven't recorded any mark-compact events yet, we use
// conservative lower bound for the mark-compact speed.
static const size_t kInitialConservativeMarkCompactSpeed = 2 * MB;
// If we haven't recorded any final incremental mark-compact events yet, we
// use conservative lower bound for the mark-compact speed.
static const size_t kInitialConservativeFinalIncrementalMarkCompactSpeed =
2 * MB;
// Maximum final incremental mark-compact time returned by
// EstimateFinalIncrementalMarkCompactTime.
static const size_t kMaxFinalIncrementalMarkCompactTimeInMs;
// This is the maximum scheduled idle time. Note that it can be more than // This is the maximum scheduled idle time. Note that it can be more than
// 16.66 ms when there is currently no rendering going on. // 16.66 ms when there is currently no rendering going on.
static const size_t kMaxScheduledIdleTime = 50; static const size_t kMaxScheduledIdleTime = 50;
// The maximum idle time when frames are rendered is 16.66ms.
static const size_t kMaxFrameRenderingIdleTime = 17;
static const int kMinBackgroundIdleTime = 900;
// An allocation throughput below kLowAllocationThroughput bytes/ms is
// considered low
static const size_t kLowAllocationThroughput = 1000;
static const size_t kMaxHeapSizeForContextDisposalMarkCompact = 100 * MB; static const size_t kMaxHeapSizeForContextDisposalMarkCompact = 100 * MB;
// If contexts are disposed at a higher rate a full gc is triggered. // If contexts are disposed at a higher rate a full gc is triggered.
static const double kHighContextDisposalRate; static const double kHighContextDisposalRate;
// Incremental marking step time.
static const size_t kIncrementalMarkingStepTimeInMs = 1;
static const size_t kMinTimeForOverApproximatingWeakClosureInMs;
GCIdleTimeHandler() = default; GCIdleTimeHandler() = default;
GCIdleTimeAction Compute(double idle_time_in_ms, GCIdleTimeAction Compute(double idle_time_in_ms,
...@@ -95,12 +68,6 @@ class V8_EXPORT_PRIVATE GCIdleTimeHandler { ...@@ -95,12 +68,6 @@ class V8_EXPORT_PRIVATE GCIdleTimeHandler {
double contexts_disposal_rate, double contexts_disposal_rate,
size_t size_of_objects); size_t size_of_objects);
static bool ShouldDoFinalIncrementalMarkCompact(
double idle_time_in_ms, size_t size_of_objects,
double final_incremental_mark_compact_speed_in_bytes_per_ms);
static bool ShouldDoOverApproximateWeakClosure(double idle_time_in_ms);
private: private:
DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler);
}; };
......
...@@ -30,7 +30,6 @@ class GCIdleTimeHandlerTest : public ::testing::Test { ...@@ -30,7 +30,6 @@ class GCIdleTimeHandlerTest : public ::testing::Test {
static const size_t kSizeOfObjects = 100 * MB; static const size_t kSizeOfObjects = 100 * MB;
static const size_t kMarkCompactSpeed = 200 * KB; static const size_t kMarkCompactSpeed = 200 * KB;
static const size_t kMarkingSpeed = 200 * KB;
private: private:
GCIdleTimeHandler handler_; GCIdleTimeHandler handler_;
...@@ -74,20 +73,6 @@ TEST(GCIdleTimeHandler, EstimateMarkingStepSizeOverflow2) { ...@@ -74,20 +73,6 @@ TEST(GCIdleTimeHandler, EstimateMarkingStepSizeOverflow2) {
} }
TEST_F(GCIdleTimeHandlerTest, ShouldDoFinalIncrementalMarkCompact) {
size_t idle_time_ms = 16;
EXPECT_TRUE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact(
idle_time_ms, 0, 0));
}
TEST_F(GCIdleTimeHandlerTest, DontDoFinalIncrementalMarkCompact) {
size_t idle_time_ms = 1;
EXPECT_FALSE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact(
idle_time_ms, kSizeOfObjects, kMarkingSpeed));
}
TEST_F(GCIdleTimeHandlerTest, ContextDisposeLowRate) { TEST_F(GCIdleTimeHandlerTest, ContextDisposeLowRate) {
if (!handler()->Enabled()) return; if (!handler()->Enabled()) return;
GCIdleTimeHeapState heap_state = DefaultHeapState(); GCIdleTimeHeapState heap_state = DefaultHeapState();
......
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