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

Unified Diff: content/renderer/gpu/render_widget_compositor.cc

Issue 22900018: cc: Set the mapped memory reclaim limit for the renderer compositor on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/gpu/render_widget_compositor.cc
diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc
index e7a7e3e0f5957e9b99ffc5f6c7c6e9b9e2f1b987..34e1e39cd6468ede545410a01c67c1141ada7da6 100644
--- a/content/renderer/gpu/render_widget_compositor.cc
+++ b/content/renderer/gpu/render_widget_compositor.cc
@@ -7,6 +7,10 @@
#include <limits>
#include <string>
+#if defined(OS_ANDROID)
+#include "base/android/sys_utils.h"
+#endif
+
#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
@@ -286,6 +290,28 @@ scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create(
}
#endif
+// 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.
+ const size_t kMsPerFrame = 16;
+ settings.max_bytes_pending_upload = 2 * kMsPerFrame * kMaxBytesUploadedPerMs;
+ compositor->SetMaxBytesPendingUpload(settings.max_bytes_pending_upload);
+
if (!compositor->initialize(settings))
return scoped_ptr<RenderWidgetCompositor>();
@@ -296,7 +322,8 @@ RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget,
bool threaded)
: threaded_(threaded),
suppress_schedule_composite_(false),
- widget_(widget) {
+ widget_(widget),
+ max_bytes_pending_upload_(0) {
}
RenderWidgetCompositor::~RenderWidgetCompositor() {}
@@ -552,7 +579,7 @@ void RenderWidgetCompositor::ApplyScrollAndScale(gfx::Vector2d scroll_delta,
scoped_ptr<cc::OutputSurface> RenderWidgetCompositor::CreateOutputSurface(
bool fallback) {
- return widget_->CreateOutputSurface(fallback);
+ return widget_->CreateOutputSurface(fallback, max_bytes_pending_upload_);
}
void RenderWidgetCompositor::DidInitializeOutputSurface(bool success) {
@@ -593,4 +620,9 @@ RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() {
OffscreenContextProviderForCompositorThread();
}
+void RenderWidgetCompositor::SetMaxBytesPendingUpload(
+ size_t max_bytes_pending_upload) {
+ max_bytes_pending_upload_ = max_bytes_pending_upload;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698