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

Unified Diff: src/heap/scavenge-job.h

Issue 1352453004: Perform scavenge in idle tasks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 3 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/incremental-marking.cc ('k') | src/heap/scavenge-job.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/scavenge-job.h
diff --git a/src/heap/scavenge-job.h b/src/heap/scavenge-job.h
new file mode 100644
index 0000000000000000000000000000000000000000..c9e508ec5278c2b390459b279bda0fd04d1b0626
--- /dev/null
+++ b/src/heap/scavenge-job.h
@@ -0,0 +1,80 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_HEAP_SCAVENGE_JOB_H_
+#define V8_HEAP_SCAVENGE_JOB_H_
+
+#include "src/cancelable-task.h"
+#include "src/heap/gc-tracer.h"
+
+namespace v8 {
+namespace internal {
+
+class Heap;
+class Isolate;
+
+
+// This class posts idle tasks and performs scavenges in the idle tasks.
+class ScavengeJob {
+ public:
+ class IdleTask : public CancelableIdleTask {
+ public:
+ explicit IdleTask(Isolate* isolate, ScavengeJob* job)
+ : CancelableIdleTask(isolate), job_(job) {}
+ // CancelableIdleTask overrides.
+ void RunInternal(double deadline_in_seconds) override;
+
+ private:
+ ScavengeJob* job_;
+ };
+
+ ScavengeJob()
+ : idle_task_pending_(false),
+ idle_task_rescheduled_(false),
+ bytes_allocated_since_the_last_task_(0) {}
+
+ // Posts an idle task if the cumulative bytes allocated since the last
+ // idle task exceed kBytesAllocatedBeforeNextIdleTask.
+ void ScheduleIdleTaskIfNeeded(Heap* heap, int bytes_allocated);
+
+ // Posts an idle task ignoring the bytes allocated, but makes sure
+ // that the new idle task cannot reschedule again.
+ // This prevents infinite rescheduling.
+ void RescheduleIdleTask(Heap* heap);
+
+ bool IdleTaskPending() { return idle_task_pending_; }
+ void NotifyIdleTask() { idle_task_pending_ = false; }
+ bool IdleTaskRescheduled() { return idle_task_rescheduled_; }
+
+ static bool ReachedIdleAllocationLimit(size_t scavenge_speed_in_bytes_per_ms,
+ size_t new_space_size,
+ size_t new_space_capacity);
+
+ static bool EnoughIdleTimeForScavenge(double idle_time_ms,
+ size_t scavenge_speed_in_bytes_per_ms,
+ size_t new_space_size);
+
+ // If we haven't recorded any scavenger events yet, we use a conservative
+ // lower bound for the scavenger speed.
+ static const int kInitialScavengeSpeedInBytesPerMs = 256 * KB;
+ // Estimate of the average idle time that an idle task gets.
+ static const int kAverageIdleTimeMs = 5;
+ // The number of bytes to be allocated in new space before the next idle
+ // task is posted.
+ static const size_t kBytesAllocatedBeforeNextIdleTask = 512 * KB;
+ // The minimum size of allocated new space objects to trigger a scavenge.
+ static const size_t kMinAllocationLimit = 512 * KB;
+ // The allocation limit cannot exceed this fraction of the new space capacity.
+ static const double kMaxAllocationLimitAsFractionOfNewSpace;
+
+ private:
+ void ScheduleIdleTask(Heap* heap);
+ bool idle_task_pending_;
+ bool idle_task_rescheduled_;
+ int bytes_allocated_since_the_last_task_;
+};
+}
+} // namespace v8::internal
+
+#endif // V8_HEAP_SCAVENGE_JOB_H_
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | src/heap/scavenge-job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698