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

Side by Side Diff: content/renderer/render_process_impl.cc

Issue 2681523002: Increase the number of TaskScheduler foreground threads in renderers. (Closed)
Patch Set: self-review Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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; 96
97 // V8Platform::CallOnBackgroundThread() posts foreground blocking tasks. It
98 // expects to have as many threads as cores available for these tasks.
99 constexpr int kMaxNumThreadsInForegroundFileIOPoolLowerBound = 2;
100 constexpr int kMaxNumThreadsInForegroundFileIOPoolUpperBound = 128;
101 constexpr double kMaxNumThreadsInForegroundFileIOPoolCoresMultiplier = 1;
102 constexpr int kMaxNumThreadsInForegroundFileIOPoolOffset = 0;
103
97 constexpr auto kSuggestedReclaimTime = base::TimeDelta::FromSeconds(30); 104 constexpr auto kSuggestedReclaimTime = base::TimeDelta::FromSeconds(30);
98 105
99 std::vector<base::SchedulerWorkerPoolParams> params_vector; 106 std::vector<base::SchedulerWorkerPoolParams> params_vector;
100 params_vector.emplace_back("RendererBackground", ThreadPriority::BACKGROUND, 107 params_vector.emplace_back("RendererBackground", ThreadPriority::BACKGROUND,
101 StandbyThreadPolicy::LAZY, 108 StandbyThreadPolicy::LAZY,
102 kMaxNumThreadsInBackgroundPool, 109 kMaxNumThreadsInBackgroundPool,
103 kSuggestedReclaimTime); 110 kSuggestedReclaimTime);
104 params_vector.emplace_back( 111 params_vector.emplace_back(
105 "RendererBackgroundFileIO", ThreadPriority::BACKGROUND, 112 "RendererBackgroundFileIO", ThreadPriority::BACKGROUND,
106 StandbyThreadPolicy::LAZY, kMaxNumThreadsInBackgroundFileIOPool, 113 StandbyThreadPolicy::LAZY, kMaxNumThreadsInBackgroundFileIOPool,
107 kSuggestedReclaimTime); 114 kSuggestedReclaimTime);
108 params_vector.emplace_back("RendererForeground", ThreadPriority::NORMAL, 115 params_vector.emplace_back("RendererForeground", ThreadPriority::NORMAL,
109 StandbyThreadPolicy::LAZY, 116 StandbyThreadPolicy::LAZY,
110 base::RecommendedMaxNumberOfThreadsInPool( 117 base::RecommendedMaxNumberOfThreadsInPool(
111 kMaxNumThreadsInForegroundPoolLowerBound, 118 kMaxNumThreadsInForegroundPoolLowerBound,
112 kMaxNumThreadsInForegroundPoolUpperBound, 119 kMaxNumThreadsInForegroundPoolUpperBound,
113 kMaxNumThreadsInForegroundPoolCoresMultiplier, 120 kMaxNumThreadsInForegroundPoolCoresMultiplier,
114 kMaxNumThreadsInForegroundPoolOffset), 121 kMaxNumThreadsInForegroundPoolOffset),
115 kSuggestedReclaimTime); 122 kSuggestedReclaimTime);
116 params_vector.emplace_back("RendererForegroundFileIO", ThreadPriority::NORMAL, 123 params_vector.emplace_back(
117 StandbyThreadPolicy::LAZY, 124 "RendererForegroundFileIO", ThreadPriority::NORMAL,
118 kMaxNumThreadsInForegroundFileIOPool, 125 StandbyThreadPolicy::LAZY,
119 kSuggestedReclaimTime); 126 base::RecommendedMaxNumberOfThreadsInPool(
robliao 2017/02/06 20:07:51 Is using RecommendedMax... better than a std::min(
fdoray 2017/02/06 20:14:03 Done.
127 kMaxNumThreadsInForegroundFileIOPoolLowerBound,
128 kMaxNumThreadsInForegroundFileIOPoolUpperBound,
129 kMaxNumThreadsInForegroundFileIOPoolCoresMultiplier,
130 kMaxNumThreadsInForegroundFileIOPoolOffset),
131 kSuggestedReclaimTime);
120 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size()); 132 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size());
121 return params_vector; 133 return params_vector;
122 } 134 }
123 135
124 // Returns the worker pool index for |traits| defaulting to FOREGROUND or 136 // 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 137 // FOREGROUND_FILE_IO on any other priorities based off of worker pools defined
126 // in GetDefaultSchedulerWorkerPoolParams(). 138 // in GetDefaultSchedulerWorkerPoolParams().
127 size_t DefaultRendererWorkerPoolIndexForTraits(const base::TaskTraits& traits) { 139 size_t DefaultRendererWorkerPoolIndexForTraits(const base::TaskTraits& traits) {
128 const bool is_background = 140 const bool is_background =
129 traits.priority() == base::TaskPriority::BACKGROUND; 141 traits.priority() == base::TaskPriority::BACKGROUND;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 index_to_traits_callback = 243 index_to_traits_callback =
232 base::Bind(&DefaultRendererWorkerPoolIndexForTraits); 244 base::Bind(&DefaultRendererWorkerPoolIndexForTraits);
233 } 245 }
234 DCHECK(index_to_traits_callback); 246 DCHECK(index_to_traits_callback);
235 247
236 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( 248 base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
237 params_vector, index_to_traits_callback); 249 params_vector, index_to_traits_callback);
238 } 250 }
239 251
240 } // namespace content 252 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698