Revision: 19357
Author: [email protected]
Date: Thu Feb 13 15:36:17 2014 UTC
Log: Introduce --job-based-sweeping flag and use individual jobs for
sweeping if set
BUG=v8:3104
[email protected]
LOG=y
Review URL: https://codereview.chromium.org/143803007
http://code.google.com/p/v8/source/detail?r=19357
Modified:
/branches/bleeding_edge/src/flag-definitions.h
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/isolate.cc
/branches/bleeding_edge/src/mark-compact.cc
/branches/bleeding_edge/src/mark-compact.h
/branches/bleeding_edge/src/sweeper-thread.cc
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Wed Feb 12 09:19:30 2014
UTC
+++ /branches/bleeding_edge/src/flag-definitions.h Thu Feb 13 15:36:17 2014
UTC
@@ -530,6 +530,7 @@
DEFINE_bool(concurrent_sweeping, false, "enable concurrent sweeping")
DEFINE_int(sweeper_threads, 0,
"number of parallel and concurrent sweeping threads")
+DEFINE_bool(job_based_sweeping, false, "enable job based sweeping")
#ifdef VERIFY_HEAP
DEFINE_bool(verify_heap, false, "verify heap pointers before and after GC")
#endif
=======================================
--- /branches/bleeding_edge/src/heap.cc Wed Feb 12 22:04:19 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Thu Feb 13 15:36:17 2014 UTC
@@ -6360,7 +6360,7 @@
bool Heap::AdvanceSweepers(int step_size) {
- ASSERT(isolate()->num_sweeper_threads() == 0);
+ ASSERT(!mark_compact_collector()->AreSweeperThreadsActivated());
bool sweeping_complete = old_data_space()->AdvanceSweeper(step_size);
sweeping_complete &= old_pointer_space()->AdvanceSweeper(step_size);
return sweeping_complete;
=======================================
--- /branches/bleeding_edge/src/isolate.cc Wed Feb 12 09:19:30 2014 UTC
+++ /branches/bleeding_edge/src/isolate.cc Thu Feb 13 15:36:17 2014 UTC
@@ -1671,6 +1671,10 @@
delete[] sweeper_thread_;
sweeper_thread_ = NULL;
+ if (FLAG_job_based_sweeping &&
+ heap_.mark_compact_collector()->IsConcurrentSweepingInProgress()) {
+ heap_.mark_compact_collector()->WaitUntilSweepingCompleted();
+ }
if (FLAG_hydrogen_stats) GetHStatistics()->Print();
@@ -2012,7 +2016,10 @@
max_available_threads_ = Max(Min(CPU::NumberOfProcessorsOnline(), 4),
1);
}
- num_sweeper_threads_ =
SweeperThread::NumberOfThreads(max_available_threads_);
+ if (!FLAG_job_based_sweeping) {
+ num_sweeper_threads_ =
+ SweeperThread::NumberOfThreads(max_available_threads_);
+ }
if (FLAG_trace_hydrogen || FLAG_trace_hydrogen_stubs) {
PrintF("Concurrent recompilation has been disabled for tracing.\n");
=======================================
--- /branches/bleeding_edge/src/mark-compact.cc Tue Feb 11 11:27:22 2014 UTC
+++ /branches/bleeding_edge/src/mark-compact.cc Thu Feb 13 15:36:17 2014 UTC
@@ -67,6 +67,7 @@
compacting_(false),
was_marked_incrementally_(false),
sweeping_pending_(false),
+ pending_sweeper_jobs_semaphore_(0),
sequential_sweeping_(false),
tracer_(NULL),
migration_slots_buffer_(NULL),
@@ -569,6 +570,27 @@
}
+class MarkCompactCollector::SweeperTask : public v8::Task {
+ public:
+ SweeperTask(Heap* heap, PagedSpace* space)
+ : heap_(heap), space_(space) {}
+
+ virtual ~SweeperTask() {}
+
+ private:
+ // v8::Task overrides.
+ virtual void Run() V8_OVERRIDE {
+ heap_->mark_compact_collector()->SweepInParallel(space_);
+
heap_->mark_compact_collector()->pending_sweeper_jobs_semaphore_.Signal();
+ }
+
+ Heap* heap_;
+ PagedSpace* space_;
+
+ DISALLOW_COPY_AND_ASSIGN(SweeperTask);
+};
+
+
void MarkCompactCollector::StartSweeperThreads() {
// TODO(hpayer): This check is just used for debugging purpose and
// should be removed or turned into an assert after investigating the
@@ -579,6 +601,14 @@
for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
isolate()->sweeper_threads()[i]->StartSweeping();
}
+ if (FLAG_job_based_sweeping) {
+ V8::GetCurrentPlatform()->CallOnBackgroundThread(
+ new SweeperTask(heap(), heap()->old_data_space()),
+ v8::Platform::kShortRunningTask);
+ V8::GetCurrentPlatform()->CallOnBackgroundThread(
+ new SweeperTask(heap(), heap()->old_pointer_space()),
+ v8::Platform::kShortRunningTask);
+ }
}
@@ -587,6 +617,11 @@
for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
isolate()->sweeper_threads()[i]->WaitForSweeperThread();
}
+ if (FLAG_job_based_sweeping) {
+ // Wait twice for both jobs.
+ pending_sweeper_jobs_semaphore_.Wait();
+ pending_sweeper_jobs_semaphore_.Wait();
+ }
sweeping_pending_ = false;
RefillFreeLists(heap()->paged_space(OLD_DATA_SPACE));
RefillFreeLists(heap()->paged_space(OLD_POINTER_SPACE));
@@ -616,7 +651,7 @@
bool MarkCompactCollector::AreSweeperThreadsActivated() {
- return isolate()->sweeper_threads() != NULL;
+ return isolate()->sweeper_threads() != NULL || FLAG_job_based_sweeping;
}
@@ -4138,7 +4173,7 @@
#endif
SweeperType how_to_sweep =
FLAG_lazy_sweeping ? LAZY_CONSERVATIVE : CONSERVATIVE;
- if (isolate()->num_sweeper_threads() > 0) {
+ if (AreSweeperThreadsActivated()) {
if (FLAG_parallel_sweeping) how_to_sweep = PARALLEL_CONSERVATIVE;
if (FLAG_concurrent_sweeping) how_to_sweep = CONCURRENT_CONSERVATIVE;
}
=======================================
--- /branches/bleeding_edge/src/mark-compact.h Tue Jan 21 12:48:10 2014 UTC
+++ /branches/bleeding_edge/src/mark-compact.h Thu Feb 13 15:36:17 2014 UTC
@@ -744,6 +744,8 @@
void MarkAllocationSite(AllocationSite* site);
private:
+ class SweeperTask;
+
explicit MarkCompactCollector(Heap* heap);
~MarkCompactCollector();
@@ -791,6 +793,8 @@
// True if concurrent or parallel sweeping is currently in progress.
bool sweeping_pending_;
+ Semaphore pending_sweeper_jobs_semaphore_;
+
bool sequential_sweeping_;
// A pointer to the current stack-allocated GC tracer object during a
full
=======================================
--- /branches/bleeding_edge/src/sweeper-thread.cc Tue Jan 21 11:48:51 2014
UTC
+++ /branches/bleeding_edge/src/sweeper-thread.cc Thu Feb 13 15:36:17 2014
UTC
@@ -45,6 +45,7 @@
start_sweeping_semaphore_(0),
end_sweeping_semaphore_(0),
stop_semaphore_(0) {
+ ASSERT(!FLAG_job_based_sweeping);
NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(false));
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.