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

Unified Diff: content/common/gpu/client/command_buffer_metrics.cc

Issue 1095893002: gpu: Fix some context lost marking glitches+leaks and add UMA stats (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: histogram descriptions Created 5 years, 8 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/common/gpu/client/command_buffer_metrics.cc
diff --git a/content/common/gpu/client/command_buffer_metrics.cc b/content/common/gpu/client/command_buffer_metrics.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4718db3b50769b41a5f826a589ce27e1bbe5a390
--- /dev/null
+++ b/content/common/gpu/client/command_buffer_metrics.cc
@@ -0,0 +1,140 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/gpu/client/command_buffer_metrics.h"
+
+#include "base/metrics/histogram.h"
+
+namespace content {
+
+namespace {
+
+enum CommandBufferContextLostReason {
+ // Don't add new values here.
+ CONTEXT_INIT_FAILED,
+ CONTEXT_LOST_GPU_CHANNEL_ERROR,
+ CONTEXT_PARSE_ERROR_INVALID_SIZE,
+ CONTEXT_PARSE_ERROR_OUT_OF_BOUNDS,
+ CONTEXT_PARSE_ERROR_UNKNOWN_COMMAND,
+ CONTEXT_PARSE_ERROR_INVALID_ARGS,
+ CONTEXT_PARSE_ERROR_GENERIC_ERROR,
+ CONTEXT_LOST_GUILTY,
+ CONTEXT_LOST_INNOCENT,
+ CONTEXT_LOST_UNKNOWN,
+ CONTEXT_LOST_OUT_OF_MEMORY,
+ CONTEXT_LOST_MAKECURRENT_FAILED,
+ // Add new values here and update _MAX_ENUM.
+ CONTEXT_LOST_REASON_MAX_ENUM = CONTEXT_LOST_MAKECURRENT_FAILED
+};
+
+CommandBufferContextLostReason GetContextLostReason(
+ gpu::error::Error error,
+ gpu::error::ContextLostReason reason) {
+ if (error == gpu::error::kLostContext) {
+ switch (reason) {
+ case gpu::error::kGuilty:
+ return CONTEXT_LOST_GUILTY;
+ case gpu::error::kInnocent:
+ return CONTEXT_LOST_INNOCENT;
+ case gpu::error::kUnknown:
+ return CONTEXT_LOST_UNKNOWN;
+ case gpu::error::kOutOfMemory:
+ return CONTEXT_LOST_OUT_OF_MEMORY;
+ case gpu::error::kMakeCurrentFailed:
+ return CONTEXT_LOST_MAKECURRENT_FAILED;
+ }
+ }
+ switch (error) {
+ case gpu::error::kInvalidSize:
+ return CONTEXT_PARSE_ERROR_INVALID_SIZE;
+ case gpu::error::kOutOfBounds:
+ return CONTEXT_PARSE_ERROR_OUT_OF_BOUNDS;
+ case gpu::error::kUnknownCommand:
+ return CONTEXT_PARSE_ERROR_UNKNOWN_COMMAND;
+ case gpu::error::kInvalidArguments:
+ return CONTEXT_PARSE_ERROR_INVALID_ARGS;
+ case gpu::error::kGenericError:
+ return CONTEXT_PARSE_ERROR_GENERIC_ERROR;
+ case gpu::error::kDeferCommandUntilLater:
+ case gpu::error::kNoError:
+ case gpu::error::kLostContext:
+ NOTREACHED();
+ return CONTEXT_LOST_UNKNOWN;
+ }
+ NOTREACHED();
+ return CONTEXT_LOST_UNKNOWN;
+}
+
+const char* GetHistogramName(CommandBufferContextType type) {
+ switch (type) {
+ case BROWSER_COMPOSITOR_ONSCREEN_CONTEXT:
+ return "GPU.ContextLost.BrowserCompositor";
+ case BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT:
+ return "GPU.ContextLost.BrowserMainThread";
+ case RENDER_COMPOSITOR_CONTEXT:
+ return "GPU.ContextLost.RenderCompositor";
+ case RENDER_WORKER_CONTEXT:
+ return "GPU.ContextLost.RenderWorker";
+ case RENDERER_MAINTHREAD_CONTEXT:
+ return "GPU.ContextLost.RenderMainThread";
+ case GPU_VIDEO_ACCELERATOR_CONTEXT:
+ return "GPU.ContextLost.VideoAccelerator";
+ case OFFSCREEN_VIDEO_CAPTURE_CONTEXT:
+ return "GPU.ContextLost.VideoCapture";
+ case OFFSCREEN_CONTEXT_FOR_WEBGL:
+ return "GPU.ContextLost.WebGL";
+ case CONTEXT_TYPE_UNKNOWN:
+ return "GPU.ContextLost.Unknown";
+ }
+}
+
+} // anonymous namespace
+
+std::string CommandBufferContextTypeToString(CommandBufferContextType type) {
+ switch (type) {
+ case OFFSCREEN_CONTEXT_FOR_TESTING:
+ return "Context-For-Testing";
+ case BROWSER_COMPOSITOR_ONSCREEN_CONTEXT:
+ return "Compositor";
+ case BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT:
+ return "Offscreen-MainThread";
+ case RENDER_COMPOSITOR_CONTEXT:
+ return "RenderCompositor";
+ case RENDER_WORKER_CONTEXT:
+ return "RenderWorker";
+ case RENDERER_MAINTHREAD_CONTEXT:
+ return "Offscreen-MainThread";
+ case GPU_VIDEO_ACCELERATOR_CONTEXT:
+ return "GPU-VideoAccelerator-Offscreen";
+ case OFFSCREEN_VIDEO_CAPTURE_CONTEXT:
+ return "Offscreen-CaptureThread";
+ case OFFSCREEN_CONTEXT_FOR_WEBGL:
+ return "Offscreen-For-WebGL";
+ default:
+ NOTREACHED();
+ return "unknown";
+ }
+}
+
+void UmaRecordContextInitFailed(CommandBufferContextType type) {
+ const char* histogram_name = GetHistogramName(type);
+ if (histogram_name) {
+ UMA_HISTOGRAM_ENUMERATION(histogram_name, CONTEXT_INIT_FAILED,
+ CONTEXT_LOST_REASON_MAX_ENUM);
Alexei Svitkine (slow) 2015/04/24 19:31:58 Unfortunately this won't work. The UMA histogram
no sievers 2015/04/24 19:56:42 Thanks for catching that. Fixed.
+ }
+}
+
+void UmaRecordContextLost(CommandBufferContextType type,
+ gpu::error::Error error,
+ gpu::error::ContextLostReason reason) {
+ const char* histogram_name = GetHistogramName(type);
+ if (histogram_name) {
+ CommandBufferContextLostReason converted_reason =
+ GetContextLostReason(error, reason);
+ UMA_HISTOGRAM_ENUMERATION(histogram_name, converted_reason,
+ CONTEXT_LOST_REASON_MAX_ENUM);
+ }
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698