Commit fb8bb92e authored by reveman's avatar reveman Committed by Commit bot

Re-land: content: Use NumberOfProcessors() / 2 raster threads.

4 raster threads improve performance on 8 core machines.
8 core machines might not be a priority but it seems
like an unnecessary limitation to have.

BUG=

Review URL: https://codereview.chromium.org/1143473002

Cr-Commit-Position: refs/heads/master@{#330555}
parent cf78929c
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "cc/base/math_util.h"
#include "cc/base/switches.h" #include "cc/base/switches.h"
#include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
...@@ -32,7 +33,7 @@ const char* kThreadedRasterizationFeatureName = "threaded_rasterization"; ...@@ -32,7 +33,7 @@ const char* kThreadedRasterizationFeatureName = "threaded_rasterization";
const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads";
const int kMinRasterThreads = 1; const int kMinRasterThreads = 1;
const int kMaxRasterThreads = 64; const int kMaxRasterThreads = 16;
const int kMinMSAASampleCount = 0; const int kMinMSAASampleCount = 0;
...@@ -210,20 +211,30 @@ bool IsImplSidePaintingEnabled() { ...@@ -210,20 +211,30 @@ bool IsImplSidePaintingEnabled() {
} }
int NumberOfRendererRasterThreads() { int NumberOfRendererRasterThreads() {
int num_raster_threads = 1; int num_raster_threads = base::SysInfo::NumberOfProcessors() / 2;
// Async uploads uses its own thread, so allow an extra thread when async // Async uploads is used when neither zero-copy nor one-copy is enabled and
// uploads is not in use. // it uses its own thread, so reduce the number of raster threads when async
bool allow_extra_thread = // uploads is in use.
IsZeroCopyUploadEnabled() || IsOneCopyUploadEnabled(); bool async_uploads_is_used =
if (base::SysInfo::NumberOfProcessors() >= 4 && allow_extra_thread) !IsZeroCopyUploadEnabled() && !IsOneCopyUploadEnabled();
num_raster_threads = 2; if (async_uploads_is_used)
--num_raster_threads;
int force_num_raster_threads = ForceNumberOfRendererRasterThreads(); const base::CommandLine& command_line =
if (force_num_raster_threads) *base::CommandLine::ForCurrentProcess();
num_raster_threads = force_num_raster_threads;
return num_raster_threads; if (command_line.HasSwitch(switches::kNumRasterThreads)) {
std::string string_value = command_line.GetSwitchValueASCII(
switches::kNumRasterThreads);
if (!base::StringToInt(string_value, &num_raster_threads)) {
DLOG(WARNING) << "Failed to parse switch " <<
switches::kNumRasterThreads << ": " << string_value;
}
}
return cc::MathUtil::ClampToRange(num_raster_threads, kMinRasterThreads,
kMaxRasterThreads);
} }
bool IsOneCopyUploadEnabled() { bool IsOneCopyUploadEnabled() {
...@@ -249,26 +260,6 @@ bool IsZeroCopyUploadEnabled() { ...@@ -249,26 +260,6 @@ bool IsZeroCopyUploadEnabled() {
return command_line.HasSwitch(switches::kEnableZeroCopy); return command_line.HasSwitch(switches::kEnableZeroCopy);
} }
int ForceNumberOfRendererRasterThreads() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (!command_line.HasSwitch(switches::kNumRasterThreads))
return 0;
std::string string_value =
command_line.GetSwitchValueASCII(switches::kNumRasterThreads);
int force_num_raster_threads = 0;
if (base::StringToInt(string_value, &force_num_raster_threads) &&
force_num_raster_threads >= kMinRasterThreads &&
force_num_raster_threads <= kMaxRasterThreads) {
return force_num_raster_threads;
} else {
DLOG(WARNING) << "Failed to parse switch " <<
switches::kNumRasterThreads << ": " << string_value;
return 0;
}
}
bool IsGpuRasterizationEnabled() { bool IsGpuRasterizationEnabled() {
const base::CommandLine& command_line = const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
...@@ -383,7 +374,9 @@ base::DictionaryValue* GetFeatureStatus() { ...@@ -383,7 +374,9 @@ base::DictionaryValue* GetFeatureStatus() {
status += "_force"; status += "_force";
} }
if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) { if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) {
if (ForceNumberOfRendererRasterThreads() > 0) const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kNumRasterThreads))
status += "_force"; status += "_force";
} }
if (gpu_feature_info.name == kThreadedRasterizationFeatureName || if (gpu_feature_info.name == kThreadedRasterizationFeatureName ||
......
...@@ -49,10 +49,6 @@ CONTENT_EXPORT bool IsForceGpuRasterizationEnabled(); ...@@ -49,10 +49,6 @@ CONTENT_EXPORT bool IsForceGpuRasterizationEnabled();
// Returns the number of raster threads to use for compositing. // Returns the number of raster threads to use for compositing.
CONTENT_EXPORT int NumberOfRendererRasterThreads(); CONTENT_EXPORT int NumberOfRendererRasterThreads();
// Returns the number of raster threads to use for compositing that are forced
// by the command line.
CONTENT_EXPORT int ForceNumberOfRendererRasterThreads();
// Returns true if using cc Surfaces is allowed. // Returns true if using cc Surfaces is allowed.
CONTENT_EXPORT bool UseSurfacesEnabled(); CONTENT_EXPORT bool UseSurfacesEnabled();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment