OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/render_process_impl.h" | 5 #include "content/renderer/render_process_impl.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 GetDefaultSchedulerWorkerPoolParams() { | 86 GetDefaultSchedulerWorkerPoolParams() { |
87 using StandbyThreadPolicy = | 87 using StandbyThreadPolicy = |
88 base::SchedulerWorkerPoolParams::StandbyThreadPolicy; | 88 base::SchedulerWorkerPoolParams::StandbyThreadPolicy; |
89 using ThreadPriority = base::ThreadPriority; | 89 using ThreadPriority = base::ThreadPriority; |
90 constexpr size_t kMaxNumThreadsInBackgroundPool = 1; | 90 constexpr size_t kMaxNumThreadsInBackgroundPool = 1; |
91 constexpr size_t kMaxNumThreadsInBackgroundFileIOPool = 1; | 91 constexpr size_t kMaxNumThreadsInBackgroundFileIOPool = 1; |
92 constexpr int kMaxNumThreadsInForegroundPoolLowerBound = 2; | 92 constexpr int kMaxNumThreadsInForegroundPoolLowerBound = 2; |
93 constexpr int kMaxNumThreadsInForegroundPoolUpperBound = 4; | 93 constexpr int kMaxNumThreadsInForegroundPoolUpperBound = 4; |
94 constexpr double kMaxNumThreadsInForegroundPoolCoresMultiplier = 1; | 94 constexpr double kMaxNumThreadsInForegroundPoolCoresMultiplier = 1; |
95 constexpr int kMaxNumThreadsInForegroundPoolOffset = 0; | 95 constexpr int kMaxNumThreadsInForegroundPoolOffset = 0; |
96 constexpr size_t kMaxNumThreadsInForegroundFileIOPool = 1; | |
97 constexpr auto kSuggestedReclaimTime = base::TimeDelta::FromSeconds(30); | 96 constexpr auto kSuggestedReclaimTime = base::TimeDelta::FromSeconds(30); |
98 | 97 |
99 std::vector<base::SchedulerWorkerPoolParams> params_vector; | 98 std::vector<base::SchedulerWorkerPoolParams> params_vector; |
100 params_vector.emplace_back("RendererBackground", ThreadPriority::BACKGROUND, | 99 params_vector.emplace_back("RendererBackground", ThreadPriority::BACKGROUND, |
101 StandbyThreadPolicy::LAZY, | 100 StandbyThreadPolicy::LAZY, |
102 kMaxNumThreadsInBackgroundPool, | 101 kMaxNumThreadsInBackgroundPool, |
103 kSuggestedReclaimTime); | 102 kSuggestedReclaimTime); |
104 params_vector.emplace_back( | 103 params_vector.emplace_back( |
105 "RendererBackgroundFileIO", ThreadPriority::BACKGROUND, | 104 "RendererBackgroundFileIO", ThreadPriority::BACKGROUND, |
106 StandbyThreadPolicy::LAZY, kMaxNumThreadsInBackgroundFileIOPool, | 105 StandbyThreadPolicy::LAZY, kMaxNumThreadsInBackgroundFileIOPool, |
107 kSuggestedReclaimTime); | 106 kSuggestedReclaimTime); |
108 params_vector.emplace_back("RendererForeground", ThreadPriority::NORMAL, | 107 params_vector.emplace_back("RendererForeground", ThreadPriority::NORMAL, |
109 StandbyThreadPolicy::LAZY, | 108 StandbyThreadPolicy::LAZY, |
110 base::RecommendedMaxNumberOfThreadsInPool( | 109 base::RecommendedMaxNumberOfThreadsInPool( |
111 kMaxNumThreadsInForegroundPoolLowerBound, | 110 kMaxNumThreadsInForegroundPoolLowerBound, |
112 kMaxNumThreadsInForegroundPoolUpperBound, | 111 kMaxNumThreadsInForegroundPoolUpperBound, |
113 kMaxNumThreadsInForegroundPoolCoresMultiplier, | 112 kMaxNumThreadsInForegroundPoolCoresMultiplier, |
114 kMaxNumThreadsInForegroundPoolOffset), | 113 kMaxNumThreadsInForegroundPoolOffset), |
115 kSuggestedReclaimTime); | 114 kSuggestedReclaimTime); |
115 | |
116 // V8Platform::CallOnBackgroundThread() posts foreground blocking tasks. It | |
117 // expects to have as many threads as cores available for these tasks. | |
gab
2017/02/06 21:17:10
Such a comment is fine to justify CL (i.e. in desc
fdoray
2017/02/09 13:32:13
Done. The v8 tasks are only blocking in tests.
| |
118 const int max_num_foreground_file_io_threads = | |
gab
2017/02/06 21:17:10
s/file_io/blocking/ now
fdoray
2017/02/09 13:32:14
Taken care of in a separate CL https://codereview.
| |
119 std::max(2, base::SysInfo::NumberOfProcessors()); | |
116 params_vector.emplace_back("RendererForegroundFileIO", ThreadPriority::NORMAL, | 120 params_vector.emplace_back("RendererForegroundFileIO", ThreadPriority::NORMAL, |
117 StandbyThreadPolicy::LAZY, | 121 StandbyThreadPolicy::LAZY, |
118 kMaxNumThreadsInForegroundFileIOPool, | 122 max_num_foreground_file_io_threads, |
119 kSuggestedReclaimTime); | 123 kSuggestedReclaimTime); |
120 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size()); | 124 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size()); |
121 return params_vector; | 125 return params_vector; |
122 } | 126 } |
123 | 127 |
124 // Returns the worker pool index for |traits| defaulting to FOREGROUND or | 128 // Returns the worker pool index for |traits| defaulting to FOREGROUND or |
125 // FOREGROUND_FILE_IO on any other priorities based off of worker pools defined | 129 // FOREGROUND_FILE_IO on any other priorities based off of worker pools defined |
126 // in GetDefaultSchedulerWorkerPoolParams(). | 130 // in GetDefaultSchedulerWorkerPoolParams(). |
127 size_t DefaultRendererWorkerPoolIndexForTraits(const base::TaskTraits& traits) { | 131 size_t DefaultRendererWorkerPoolIndexForTraits(const base::TaskTraits& traits) { |
128 const bool is_background = | 132 const bool is_background = |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 index_to_traits_callback = | 235 index_to_traits_callback = |
232 base::Bind(&DefaultRendererWorkerPoolIndexForTraits); | 236 base::Bind(&DefaultRendererWorkerPoolIndexForTraits); |
233 } | 237 } |
234 DCHECK(index_to_traits_callback); | 238 DCHECK(index_to_traits_callback); |
235 | 239 |
236 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( | 240 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( |
237 params_vector, index_to_traits_callback); | 241 params_vector, index_to_traits_callback); |
238 } | 242 } |
239 | 243 |
240 } // namespace content | 244 } // namespace content |
OLD | NEW |