diff options
author | Mathieu Chartier <mathieuc@google.com> | 2013-07-23 14:04:34 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-07-23 14:04:34 -0700 |
commit | 3489af22a126e135acfc3c93beec9c31999c0ce6 (patch) | |
tree | 2ff3d04dea669ec31f84f35108de4171d3fc9e37 | |
parent | a3d6b8cb884fce2fe34258e9d582b11ea9545fd9 (diff) | |
parent | 63a54345598861030178e033ffbd72c0e231a4c9 (diff) | |
download | art-3489af22a126e135acfc3c93beec9c31999c0ce6.tar.gz art-3489af22a126e135acfc3c93beec9c31999c0ce6.tar.bz2 art-3489af22a126e135acfc3c93beec9c31999c0ce6.zip |
am 63a54345: Add option for changing number of GC threads.
* commit '63a54345598861030178e033ffbd72c0e231a4c9':
Add option for changing number of GC threads.
-rw-r--r-- | runtime/gc/heap.cc | 10 | ||||
-rw-r--r-- | runtime/gc/heap.h | 6 | ||||
-rw-r--r-- | runtime/runtime.cc | 8 | ||||
-rw-r--r-- | runtime/runtime.h | 1 |
4 files changed, 17 insertions, 8 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 942a4b1c3d..3c964d6fa0 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -67,10 +67,11 @@ const double Heap::kDefaultTargetUtilization = 0.5; Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max_free, double target_utilization, size_t capacity, - const std::string& original_image_file_name, bool concurrent_gc) + const std::string& original_image_file_name, bool concurrent_gc, size_t num_gc_threads) : alloc_space_(NULL), card_table_(NULL), concurrent_gc_(concurrent_gc), + num_gc_threads_(num_gc_threads), have_zygote_space_(false), reference_queue_lock_(NULL), is_gc_running_(false), @@ -200,7 +201,7 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max gc_complete_cond_.reset(new ConditionVariable("GC complete condition variable", *gc_complete_lock_)); - // Create the reference queue lock, this is required so for parrallel object scanning in the GC. + // Create the reference queue lock, this is required so for parallel object scanning in the GC. reference_queue_lock_ = new Mutex("reference queue lock"); last_gc_time_ns_ = NanoTime(); @@ -221,10 +222,7 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max } void Heap::CreateThreadPool() { - // TODO: Make sysconf(_SC_NPROCESSORS_CONF) be a helper function? - // Use the number of processors - 1 since the thread doing the GC does work while its waiting for - // workers to complete. - thread_pool_.reset(new ThreadPool(1)); // new ThreadPool(sysconf(_SC_NPROCESSORS_CONF) - 1)); + thread_pool_.reset(new ThreadPool(num_gc_threads_)); } void Heap::DeleteThreadPool() { diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h index b51e187d6f..4a043a7427 100644 --- a/runtime/gc/heap.h +++ b/runtime/gc/heap.h @@ -136,7 +136,8 @@ class Heap { // ImageWriter output. explicit Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max_free, double target_utilization, size_t capacity, - const std::string& original_image_file_name, bool concurrent_gc); + const std::string& original_image_file_name, bool concurrent_gc, + size_t num_gc_threads); ~Heap(); @@ -498,6 +499,9 @@ class Heap { // false for stop-the-world mark sweep. const bool concurrent_gc_; + // How many GC threads we may use for garbage collection. + const bool num_gc_threads_; + // If we have a zygote space. bool have_zygote_space_; diff --git a/runtime/runtime.cc b/runtime/runtime.cc index ba183111ec..cf6e537df0 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -338,6 +338,8 @@ Runtime::ParsedOptions* Runtime::ParsedOptions::Create(const Options& options, b parsed->heap_max_free_ = gc::Heap::kDefaultMaxFree; parsed->heap_target_utilization_ = gc::Heap::kDefaultTargetUtilization; parsed->heap_growth_limit_ = 0; // 0 means no growth limit. + // Default to number of processors minus one since the main GC thread also does work. + parsed->heap_gc_threads_ = sysconf(_SC_NPROCESSORS_CONF) - 1; parsed->stack_size_ = 0; // 0 means default. parsed->is_compiler_ = false; @@ -472,6 +474,9 @@ Runtime::ParsedOptions* Runtime::ParsedOptions::Create(const Options& options, b return NULL; } parsed->heap_target_utilization_ = value; + } else if (StartsWith(option, "-XX:HeapGCThreads=")) { + parsed->heap_gc_threads_ = + ParseMemoryOption(option.substr(strlen("-XX:HeapGCThreads=")).c_str(), 1024); } else if (StartsWith(option, "-Xss")) { size_t size = ParseMemoryOption(option.substr(strlen("-Xss")).c_str(), 1); if (size == 0) { @@ -829,7 +834,8 @@ bool Runtime::Init(const Options& raw_options, bool ignore_unrecognized) { options->heap_target_utilization_, options->heap_maximum_size_, options->image_, - options->is_concurrent_gc_enabled_); + options->is_concurrent_gc_enabled_, + options->heap_gc_threads_); BlockSignals(); InitPlatformSignalHandlers(); diff --git a/runtime/runtime.h b/runtime/runtime.h index 58f985fae7..d480e36ff3 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -92,6 +92,7 @@ class Runtime { size_t heap_initial_size_; size_t heap_maximum_size_; size_t heap_growth_limit_; + size_t heap_gc_threads_; size_t heap_min_free_; size_t heap_max_free_; double heap_target_utilization_; |