diff options
author | sievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-17 13:31:54 +0000 |
---|---|---|
committer | sievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-17 13:31:54 +0000 |
commit | bb329a858543580a5e7661cc4fdcf64364329e84 (patch) | |
tree | 705b4109e24a60595fe6cb2173bc656798996540 /cc/resources | |
parent | dca278b617ec9f000387b25425db651171c4697f (diff) | |
download | chromium_src-bb329a858543580a5e7661cc4fdcf64364329e84.zip chromium_src-bb329a858543580a5e7661cc4fdcf64364329e84.tar.gz chromium_src-bb329a858543580a5e7661cc4fdcf64364329e84.tar.bz2 |
[cc] Android: Limit max pending upload bytes for low end
To avoid memory spikes tweak kMaxPendingUploadBytes for low end
devices. The current constant is an estimate based on Nexus 10 and
amounts to allowing ~14 megs of shared memory allocations for
raster+upload jobs.
BUG=272591,243703
NOTRY=True (flaky bots)
Review URL: https://chromiumcodereview.appspot.com/22861010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218163 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources')
-rw-r--r-- | cc/resources/pixel_buffer_raster_worker_pool.cc | 43 | ||||
-rw-r--r-- | cc/resources/pixel_buffer_raster_worker_pool.h | 1 |
2 files changed, 26 insertions, 18 deletions
diff --git a/cc/resources/pixel_buffer_raster_worker_pool.cc b/cc/resources/pixel_buffer_raster_worker_pool.cc index 7618803..2029866 100644 --- a/cc/resources/pixel_buffer_raster_worker_pool.cc +++ b/cc/resources/pixel_buffer_raster_worker_pool.cc @@ -11,6 +11,10 @@ #include "cc/resources/resource.h" #include "third_party/skia/include/core/SkDevice.h" +#if defined(OS_ANDROID) +#include "base/android/sys_utils.h" +#endif + namespace cc { namespace { @@ -62,22 +66,6 @@ class PixelBufferWorkerPoolTaskImpl : public internal::WorkerPoolTask { DISALLOW_COPY_AND_ASSIGN(PixelBufferWorkerPoolTaskImpl); }; -// If we raster too fast we become upload bound, and pending -// uploads consume memory. For maximum upload throughput, we would -// want to allow for upload_throughput * pipeline_time of pending -// uploads, after which we are just wasting memory. Since we don't -// know our upload throughput yet, this just caps our memory usage. -#if defined(OS_ANDROID) -// For reference Nexus10 can upload 1MB in about 2.5ms. -const size_t kMaxBytesUploadedPerMs = (2 * 1024 * 1024) / 5; -#else -// For reference Chromebook Pixel can upload 1MB in about 0.5ms. -const size_t kMaxBytesUploadedPerMs = 1024 * 1024 * 2; -#endif - -// Assuming a two frame deep pipeline. -const size_t kMaxPendingUploadBytes = 16 * 2 * kMaxBytesUploadedPerMs; - const int kCheckForCompletedRasterTasksDelayMs = 6; const size_t kMaxScheduledRasterTasks = 48; @@ -116,6 +104,25 @@ PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( should_notify_client_if_no_tasks_are_pending_(false), should_notify_client_if_no_tasks_required_for_activation_are_pending_( false) { +// If we raster too fast we become upload bound, and pending +// uploads consume memory. For maximum upload throughput, we would +// want to allow for upload_throughput * pipeline_time of pending +// uploads, after which we are just wasting memory. Since we don't +// know our upload throughput yet, this just caps our memory usage. +#if defined(OS_ANDROID) + size_t divider = 1; + if (base::android::SysUtils::IsLowEndDevice()) + divider = 3; + + // For reference Nexus10 can upload 1MB in about 2.5ms. + const size_t kMaxBytesUploadedPerMs = (2 * 1024 * 1024) / (5 * divider); +#else + // For reference Chromebook Pixel can upload 1MB in about 0.5ms. + const size_t kMaxBytesUploadedPerMs = 1024 * 1024 * 2; +#endif + + // Assuming a two frame deep pipeline. + max_bytes_pending_upload_ = 16 * 2 * kMaxBytesUploadedPerMs; } PixelBufferRasterWorkerPool::~PixelBufferRasterWorkerPool() { @@ -474,7 +481,7 @@ void PixelBufferRasterWorkerPool::ScheduleMoreTasks() { // All raster tasks need to be throttled by bytes of pending uploads. size_t new_bytes_pending_upload = bytes_pending_upload; new_bytes_pending_upload += task->resource()->bytes(); - if (new_bytes_pending_upload > kMaxPendingUploadBytes) + if (new_bytes_pending_upload > max_bytes_pending_upload_) break; internal::WorkerPoolTask* pixel_buffer_task = pixel_buffer_it->second.get(); @@ -677,7 +684,7 @@ scoped_ptr<base::Value> PixelBufferRasterWorkerPool::ThrottleStateAsValue() scoped_ptr<base::DictionaryValue> throttle_state(new base::DictionaryValue); throttle_state->SetInteger("bytes_available_for_upload", - kMaxPendingUploadBytes - bytes_pending_upload_); + max_bytes_pending_upload_ - bytes_pending_upload_); throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); throttle_state->SetInteger("scheduled_raster_task_count", scheduled_raster_task_count_); diff --git a/cc/resources/pixel_buffer_raster_worker_pool.h b/cc/resources/pixel_buffer_raster_worker_pool.h index 9e966d3..94a2f951 100644 --- a/cc/resources/pixel_buffer_raster_worker_pool.h +++ b/cc/resources/pixel_buffer_raster_worker_pool.h @@ -68,6 +68,7 @@ class CC_EXPORT PixelBufferRasterWorkerPool : public RasterWorkerPool { size_t scheduled_raster_task_count_; size_t bytes_pending_upload_; + size_t max_bytes_pending_upload_; bool has_performed_uploads_since_last_flush_; base::CancelableClosure check_for_completed_raster_tasks_callback_; bool check_for_completed_raster_tasks_pending_; |