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

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

Issue 2681523002: Increase the number of TaskScheduler foreground threads in renderers. (Closed)
Patch Set: CR gab #14 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>
11 #include <objidl.h> 11 #include <objidl.h>
12 #include <mlang.h> 12 #include <mlang.h>
13 #endif 13 #endif
14 14
15 #include <stddef.h> 15 #include <stddef.h>
16 16
17 #include <algorithm>
17 #include <vector> 18 #include <vector>
18 19
19 #include "base/bind.h" 20 #include "base/bind.h"
20 #include "base/command_line.h" 21 #include "base/command_line.h"
21 #include "base/compiler_specific.h" 22 #include "base/compiler_specific.h"
22 #include "base/debug/crash_logging.h" 23 #include "base/debug/crash_logging.h"
23 #include "base/feature_list.h" 24 #include "base/feature_list.h"
24 #include "base/sys_info.h" 25 #include "base/sys_info.h"
25 #include "base/task_scheduler/initialization_util.h" 26 #include "base/task_scheduler/initialization_util.h"
26 #include "base/task_scheduler/scheduler_worker_pool_params.h" 27 #include "base/task_scheduler/scheduler_worker_pool_params.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switch_name)) { 81 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switch_name)) {
81 v8::V8::SetFlagsFromString(v8_flag, strlen(v8_flag)); 82 v8::V8::SetFlagsFromString(v8_flag, strlen(v8_flag));
82 } 83 }
83 } 84 }
84 85
85 std::vector<base::SchedulerWorkerPoolParams> 86 std::vector<base::SchedulerWorkerPoolParams>
86 GetDefaultSchedulerWorkerPoolParams() { 87 GetDefaultSchedulerWorkerPoolParams() {
87 using StandbyThreadPolicy = 88 using StandbyThreadPolicy =
88 base::SchedulerWorkerPoolParams::StandbyThreadPolicy; 89 base::SchedulerWorkerPoolParams::StandbyThreadPolicy;
89 using ThreadPriority = base::ThreadPriority; 90 using ThreadPriority = base::ThreadPriority;
90 constexpr size_t kMaxNumThreadsInBackgroundPool = 1; 91 constexpr int kMaxNumThreadsInBackgroundPool = 1;
91 constexpr size_t kMaxNumThreadsInBackgroundFileIOPool = 1; 92 constexpr int kMaxNumThreadsInBackgroundFileIOPool = 1;
92 constexpr int kMaxNumThreadsInForegroundPoolLowerBound = 2; 93 constexpr int kMaxNumThreadsInForegroundPoolLowerBound = 2;
93 constexpr int kMaxNumThreadsInForegroundPoolUpperBound = 4; 94 constexpr int kMaxNumThreadsInForegroundFileIOPool = 1;
94 constexpr double kMaxNumThreadsInForegroundPoolCoresMultiplier = 1;
95 constexpr int kMaxNumThreadsInForegroundPoolOffset = 0;
96 constexpr size_t kMaxNumThreadsInForegroundFileIOPool = 1;
97 constexpr auto kSuggestedReclaimTime = base::TimeDelta::FromSeconds(30); 95 constexpr auto kSuggestedReclaimTime = base::TimeDelta::FromSeconds(30);
98 96
99 std::vector<base::SchedulerWorkerPoolParams> params_vector; 97 std::vector<base::SchedulerWorkerPoolParams> params_vector;
100 params_vector.emplace_back("RendererBackground", ThreadPriority::BACKGROUND, 98 params_vector.emplace_back("RendererBackground", ThreadPriority::BACKGROUND,
101 StandbyThreadPolicy::LAZY, 99 StandbyThreadPolicy::LAZY,
102 kMaxNumThreadsInBackgroundPool, 100 kMaxNumThreadsInBackgroundPool,
103 kSuggestedReclaimTime); 101 kSuggestedReclaimTime);
104 params_vector.emplace_back( 102 params_vector.emplace_back(
105 "RendererBackgroundFileIO", ThreadPriority::BACKGROUND, 103 "RendererBackgroundFileIO", ThreadPriority::BACKGROUND,
106 StandbyThreadPolicy::LAZY, kMaxNumThreadsInBackgroundFileIOPool, 104 StandbyThreadPolicy::LAZY, kMaxNumThreadsInBackgroundFileIOPool,
107 kSuggestedReclaimTime); 105 kSuggestedReclaimTime);
108 params_vector.emplace_back("RendererForeground", ThreadPriority::NORMAL, 106 params_vector.emplace_back("RendererForeground", ThreadPriority::NORMAL,
109 StandbyThreadPolicy::LAZY, 107 StandbyThreadPolicy::LAZY,
110 base::RecommendedMaxNumberOfThreadsInPool( 108 std::max(kMaxNumThreadsInForegroundPoolLowerBound,
111 kMaxNumThreadsInForegroundPoolLowerBound, 109 base::SysInfo::NumberOfProcessors()),
112 kMaxNumThreadsInForegroundPoolUpperBound,
113 kMaxNumThreadsInForegroundPoolCoresMultiplier,
114 kMaxNumThreadsInForegroundPoolOffset),
115 kSuggestedReclaimTime); 110 kSuggestedReclaimTime);
116 params_vector.emplace_back("RendererForegroundFileIO", ThreadPriority::NORMAL, 111 params_vector.emplace_back("RendererForegroundFileIO", ThreadPriority::NORMAL,
117 StandbyThreadPolicy::LAZY, 112 StandbyThreadPolicy::LAZY,
118 kMaxNumThreadsInForegroundFileIOPool, 113 kMaxNumThreadsInForegroundFileIOPool,
119 kSuggestedReclaimTime); 114 kSuggestedReclaimTime);
120 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size()); 115 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size());
121 return params_vector; 116 return params_vector;
122 } 117 }
123 118
124 // Returns the worker pool index for |traits| defaulting to FOREGROUND or 119 // Returns the worker pool index for |traits| defaulting to FOREGROUND or
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 index_to_traits_callback = 226 index_to_traits_callback =
232 base::Bind(&DefaultRendererWorkerPoolIndexForTraits); 227 base::Bind(&DefaultRendererWorkerPoolIndexForTraits);
233 } 228 }
234 DCHECK(index_to_traits_callback); 229 DCHECK(index_to_traits_callback);
235 230
236 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( 231 base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
237 params_vector, index_to_traits_callback); 232 params_vector, index_to_traits_callback);
238 } 233 }
239 234
240 } // namespace content 235 } // 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