From 259126c0d95aeaeb82dee1f74ece8fe150ac9426 Mon Sep 17 00:00:00 2001 From: "jochen@chromium.org" Date: Wed, 1 Oct 2014 09:16:28 +0000 Subject: [PATCH] Remove sweeper threads Job based sweeping is enabled since 3.29, so remove the now obsolete thread based implementation BUG=none R=hpayer@chromium.org LOG=n Review URL: https://codereview.chromium.org/615933003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24352 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- BUILD.gn | 2 -- src/flag-definitions.h | 2 -- src/heap/mark-compact.cc | 64 +++++++++++------------------------- src/heap/mark-compact.h | 2 -- src/heap/sweeper-thread.cc | 82 ---------------------------------------------- src/heap/sweeper-thread.h | 45 ------------------------- src/isolate.cc | 27 +-------------- src/isolate.h | 10 ------ tools/gyp/v8.gyp | 2 -- 9 files changed, 20 insertions(+), 216 deletions(-) delete mode 100644 src/heap/sweeper-thread.cc delete mode 100644 src/heap/sweeper-thread.h diff --git a/BUILD.gn b/BUILD.gn index b366c15..3f4d47d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -676,8 +676,6 @@ source_set("v8_base") { "src/heap/store-buffer-inl.h", "src/heap/store-buffer.cc", "src/heap/store-buffer.h", - "src/heap/sweeper-thread.h", - "src/heap/sweeper-thread.cc", "src/hydrogen-alias-analysis.h", "src/hydrogen-bce.cc", "src/hydrogen-bce.h", diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 672f2b6..4cc4f25 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -535,7 +535,6 @@ DEFINE_BOOL(parallel_sweeping, false, "enable parallel sweeping") DEFINE_BOOL(concurrent_sweeping, true, "enable concurrent sweeping") DEFINE_INT(sweeper_threads, 0, "number of parallel and concurrent sweeping threads") -DEFINE_BOOL(job_based_sweeping, true, "enable job based sweeping") #ifdef VERIFY_HEAP DEFINE_BOOL(verify_heap, false, "verify heap pointers before and after GC") #endif @@ -666,7 +665,6 @@ DEFINE_NEG_IMPLICATION(predictable, concurrent_recompilation) DEFINE_NEG_IMPLICATION(predictable, concurrent_osr) DEFINE_NEG_IMPLICATION(predictable, concurrent_sweeping) DEFINE_NEG_IMPLICATION(predictable, parallel_sweeping) -DEFINE_NEG_IMPLICATION(predictable, job_based_sweeping) // diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index 9f9a658..ae99d98 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -18,7 +18,6 @@ #include "src/heap/objects-visiting.h" #include "src/heap/objects-visiting-inl.h" #include "src/heap/spaces-inl.h" -#include "src/heap/sweeper-thread.h" #include "src/heap-profiler.h" #include "src/ic/ic.h" #include "src/ic/stub-cache.h" @@ -557,39 +556,27 @@ void MarkCompactCollector::StartSweeperThreads() { DCHECK(free_list_old_pointer_space_.get()->IsEmpty()); DCHECK(free_list_old_data_space_.get()->IsEmpty()); sweeping_in_progress_ = true; - 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); - } + 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); } void MarkCompactCollector::EnsureSweepingCompleted() { DCHECK(sweeping_in_progress_ == true); - // If sweeping is not completed, we try to complete it here. If we do not - // have sweeper threads we have to complete since we do not have a good - // indicator for a swept space in that case. - if (!AreSweeperThreadsActivated() || !IsSweepingCompleted()) { + // If sweeping is not completed or not running at all, we try to complete it + // here. + if (!IsSweepingCompleted()) { SweepInParallel(heap()->paged_space(OLD_DATA_SPACE), 0); SweepInParallel(heap()->paged_space(OLD_POINTER_SPACE), 0); } - - 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(); - } + // Wait twice for both jobs. + pending_sweeper_jobs_semaphore_.Wait(); + pending_sweeper_jobs_semaphore_.Wait(); ParallelSweepSpacesComplete(); sweeping_in_progress_ = false; RefillFreeList(heap()->paged_space(OLD_DATA_SPACE)); @@ -606,20 +593,11 @@ void MarkCompactCollector::EnsureSweepingCompleted() { bool MarkCompactCollector::IsSweepingCompleted() { - for (int i = 0; i < isolate()->num_sweeper_threads(); i++) { - if (!isolate()->sweeper_threads()[i]->SweepingCompleted()) { - return false; - } - } - - if (FLAG_job_based_sweeping) { - if (!pending_sweeper_jobs_semaphore_.WaitFor( - base::TimeDelta::FromSeconds(0))) { - return false; - } - pending_sweeper_jobs_semaphore_.Signal(); + if (!pending_sweeper_jobs_semaphore_.WaitFor( + base::TimeDelta::FromSeconds(0))) { + return false; } - + pending_sweeper_jobs_semaphore_.Signal(); return true; } @@ -643,11 +621,6 @@ void MarkCompactCollector::RefillFreeList(PagedSpace* space) { } -bool MarkCompactCollector::AreSweeperThreadsActivated() { - return isolate()->sweeper_threads() != NULL || FLAG_job_based_sweeping; -} - - void Marking::TransferMark(Address old_start, Address new_start) { // This is only used when resizing an object. DCHECK(MemoryChunk::FromAddress(old_start) == @@ -4246,8 +4219,9 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { static bool ShouldStartSweeperThreads(MarkCompactCollector::SweeperType type) { - return type == MarkCompactCollector::PARALLEL_SWEEPING || - type == MarkCompactCollector::CONCURRENT_SWEEPING; + return (type == MarkCompactCollector::PARALLEL_SWEEPING || + type == MarkCompactCollector::CONCURRENT_SWEEPING) && + !FLAG_predictable; } diff --git a/src/heap/mark-compact.h b/src/heap/mark-compact.h index c5087b4..6afb8d6 100644 --- a/src/heap/mark-compact.h +++ b/src/heap/mark-compact.h @@ -641,8 +641,6 @@ class MarkCompactCollector { void RefillFreeList(PagedSpace* space); - bool AreSweeperThreadsActivated(); - // Checks if sweeping is in progress right now on any space. bool sweeping_in_progress() { return sweeping_in_progress_; } diff --git a/src/heap/sweeper-thread.cc b/src/heap/sweeper-thread.cc deleted file mode 100644 index b0e8cea..0000000 --- a/src/heap/sweeper-thread.cc +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2012 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. - -#include "src/heap/sweeper-thread.h" - -#include "src/v8.h" - -#include "src/isolate.h" -#include "src/v8threads.h" - -namespace v8 { -namespace internal { - -static const int kSweeperThreadStackSize = 64 * KB; - -SweeperThread::SweeperThread(Isolate* isolate) - : Thread(Thread::Options("v8:SweeperThread", kSweeperThreadStackSize)), - isolate_(isolate), - heap_(isolate->heap()), - collector_(heap_->mark_compact_collector()), - start_sweeping_semaphore_(0), - end_sweeping_semaphore_(0), - stop_semaphore_(0) { - DCHECK(!FLAG_job_based_sweeping); - base::NoBarrier_Store(&stop_thread_, static_cast(false)); -} - - -void SweeperThread::Run() { - Isolate::SetIsolateThreadLocals(isolate_, NULL); - DisallowHeapAllocation no_allocation; - DisallowHandleAllocation no_handles; - DisallowHandleDereference no_deref; - - while (true) { - start_sweeping_semaphore_.Wait(); - - if (base::Acquire_Load(&stop_thread_)) { - stop_semaphore_.Signal(); - return; - } - - collector_->SweepInParallel(heap_->old_data_space(), 0); - collector_->SweepInParallel(heap_->old_pointer_space(), 0); - end_sweeping_semaphore_.Signal(); - } -} - - -void SweeperThread::Stop() { - base::Release_Store(&stop_thread_, static_cast(true)); - start_sweeping_semaphore_.Signal(); - stop_semaphore_.Wait(); - Join(); -} - - -void SweeperThread::StartSweeping() { start_sweeping_semaphore_.Signal(); } - - -void SweeperThread::WaitForSweeperThread() { end_sweeping_semaphore_.Wait(); } - - -bool SweeperThread::SweepingCompleted() { - bool value = end_sweeping_semaphore_.WaitFor(base::TimeDelta::FromSeconds(0)); - if (value) { - end_sweeping_semaphore_.Signal(); - } - return value; -} - - -int SweeperThread::NumberOfThreads(int max_available) { - if (!FLAG_concurrent_sweeping && !FLAG_parallel_sweeping) return 0; - if (FLAG_sweeper_threads > 0) return FLAG_sweeper_threads; - if (FLAG_concurrent_sweeping) return max_available - 1; - DCHECK(FLAG_parallel_sweeping); - return max_available; -} -} -} // namespace v8::internal diff --git a/src/heap/sweeper-thread.h b/src/heap/sweeper-thread.h deleted file mode 100644 index fc6bdda..0000000 --- a/src/heap/sweeper-thread.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012 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_SWEEPER_THREAD_H_ -#define V8_HEAP_SWEEPER_THREAD_H_ - -#include "src/base/atomicops.h" -#include "src/base/platform/platform.h" -#include "src/flags.h" -#include "src/utils.h" - -#include "src/heap/spaces.h" - -#include "src/heap/heap.h" - -namespace v8 { -namespace internal { - -class SweeperThread : public base::Thread { - public: - explicit SweeperThread(Isolate* isolate); - ~SweeperThread() {} - - void Run(); - void Stop(); - void StartSweeping(); - void WaitForSweeperThread(); - bool SweepingCompleted(); - - static int NumberOfThreads(int max_available); - - private: - Isolate* isolate_; - Heap* heap_; - MarkCompactCollector* collector_; - base::Semaphore start_sweeping_semaphore_; - base::Semaphore end_sweeping_semaphore_; - base::Semaphore stop_semaphore_; - volatile base::AtomicWord stop_thread_; -}; -} -} // namespace v8::internal - -#endif // V8_HEAP_SWEEPER_THREAD_H_ diff --git a/src/isolate.cc b/src/isolate.cc index 4ccd8ca..7cf525d 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -18,7 +18,6 @@ #include "src/debug.h" #include "src/deoptimizer.h" #include "src/heap/spaces.h" -#include "src/heap/sweeper-thread.h" #include "src/heap-profiler.h" #include "src/hydrogen.h" #include "src/ic/stub-cache.h" @@ -1516,8 +1515,6 @@ Isolate::Isolate() function_entry_hook_(NULL), deferred_handles_head_(NULL), optimizing_compiler_thread_(NULL), - sweeper_thread_(NULL), - num_sweeper_threads_(0), stress_deopt_count_(0), next_optimization_id_(0), use_counter_callback_(NULL), @@ -1612,16 +1609,7 @@ void Isolate::Deinit() { optimizing_compiler_thread_ = NULL; } - for (int i = 0; i < num_sweeper_threads_; i++) { - sweeper_thread_[i]->Stop(); - delete sweeper_thread_[i]; - sweeper_thread_[i] = NULL; - } - delete[] sweeper_thread_; - sweeper_thread_ = NULL; - - if (FLAG_job_based_sweeping && - heap_.mark_compact_collector()->sweeping_in_progress()) { + if (heap_.mark_compact_collector()->sweeping_in_progress()) { heap_.mark_compact_collector()->EnsureSweepingCompleted(); } @@ -1950,11 +1938,6 @@ bool Isolate::Init(Deserializer* des) { Max(Min(base::SysInfo::NumberOfProcessors(), 4), 1); } - 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"); } else if (OptimizingCompilerThread::Enabled(max_available_threads_)) { @@ -1962,14 +1945,6 @@ bool Isolate::Init(Deserializer* des) { optimizing_compiler_thread_->Start(); } - if (num_sweeper_threads_ > 0) { - sweeper_thread_ = new SweeperThread*[num_sweeper_threads_]; - for (int i = 0; i < num_sweeper_threads_; i++) { - sweeper_thread_[i] = new SweeperThread(this); - sweeper_thread_[i]->Start(); - } - } - // If we are deserializing, read the state into the now-empty heap. if (!create_heap_objects) { des->Deserialize(this); diff --git a/src/isolate.h b/src/isolate.h index 7892ff6..a12216a 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -1061,14 +1061,6 @@ class Isolate { return optimizing_compiler_thread_; } - int num_sweeper_threads() const { - return num_sweeper_threads_; - } - - SweeperThread** sweeper_threads() { - return sweeper_thread_; - } - int id() const { return static_cast(id_); } HStatistics* GetHStatistics(); @@ -1327,8 +1319,6 @@ class Isolate { DeferredHandles* deferred_handles_head_; OptimizingCompilerThread* optimizing_compiler_thread_; - SweeperThread** sweeper_thread_; - int num_sweeper_threads_; // Counts deopt points if deopt_every_n_times is enabled. unsigned int stress_deopt_count_; diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index 3f925a3..c12ab14 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -588,8 +588,6 @@ '../../src/heap/store-buffer-inl.h', '../../src/heap/store-buffer.cc', '../../src/heap/store-buffer.h', - '../../src/heap/sweeper-thread.h', - '../../src/heap/sweeper-thread.cc', '../../src/hydrogen-alias-analysis.h', '../../src/hydrogen-bce.cc', '../../src/hydrogen-bce.h', -- 2.7.4