Add UMA for CreateShaderModule, CreateRenderPipeline, and CreateComputePipeline
These track both the time in microseconds, and whether the calls
suceeded or not.
Bug: dawn:1921
Change-Id: Ia59b5468a47973945ef476e30cc9c0b339cef7c5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/141228
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/CreatePipelineAsyncTask.cpp b/src/dawn/native/CreatePipelineAsyncTask.cpp
index f6291cf..ceaee38 100644
--- a/src/dawn/native/CreatePipelineAsyncTask.cpp
+++ b/src/dawn/native/CreatePipelineAsyncTask.cpp
@@ -22,6 +22,7 @@
#include "dawn/native/RenderPipeline.h"
#include "dawn/native/utils/WGPUHelpers.h"
#include "dawn/platform/DawnPlatform.h"
+#include "dawn/platform/metrics/HistogramMacros.h"
#include "dawn/platform/tracing/TraceEvent.h"
namespace dawn::native {
@@ -47,7 +48,14 @@
TRACE_EVENT1(device->GetPlatform(), General, "CreateComputePipelineAsyncTask::Run", "label",
eventLabel);
- MaybeError maybeError = mComputePipeline->Initialize();
+ MaybeError maybeError;
+ {
+ SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(device->GetPlatform(), "CreateComputePipelineUS");
+ maybeError = mComputePipeline->Initialize();
+ }
+ DAWN_HISTOGRAM_BOOLEAN(device->GetPlatform(), "CreateComputePipelineSuccess",
+ maybeError.IsSuccess());
+
if (maybeError.IsError()) {
device->AddComputePipelineAsyncCallbackTask(
maybeError.AcquireError(), mComputePipeline->GetLabel().c_str(), mCallback, mUserdata);
@@ -97,7 +105,14 @@
TRACE_EVENT1(device->GetPlatform(), General, "CreateRenderPipelineAsyncTask::Run", "label",
eventLabel);
- MaybeError maybeError = mRenderPipeline->Initialize();
+ MaybeError maybeError;
+ {
+ SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(device->GetPlatform(), "CreateRenderPipelineUS");
+ maybeError = mRenderPipeline->Initialize();
+ }
+ DAWN_HISTOGRAM_BOOLEAN(device->GetPlatform(), "CreateRenderPipelineSuccess",
+ maybeError.IsSuccess());
+
if (maybeError.IsError()) {
device->AddRenderPipelineAsyncCallbackTask(
maybeError.AcquireError(), mRenderPipeline->GetLabel().c_str(), mCallback, mUserdata);
diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp
index f920ead..2a77e66 100644
--- a/src/dawn/native/Device.cpp
+++ b/src/dawn/native/Device.cpp
@@ -54,6 +54,7 @@
#include "dawn/native/ValidationUtils_autogen.h"
#include "dawn/native/utils/WGPUHelpers.h"
#include "dawn/platform/DawnPlatform.h"
+#include "dawn/platform/metrics/HistogramMacros.h"
#include "dawn/platform/tracing/TraceEvent.h"
namespace dawn::native {
@@ -1039,7 +1040,6 @@
return GetOrCreate(
mCaches->shaderModules, &blueprint, [&]() -> ResultOrError<Ref<ShaderModuleBase>> {
- Ref<ShaderModuleBase> result;
if (!parseResult->HasParsedShader()) {
// We skip the parse on creation if validation isn't enabled which let's us quickly
// lookup in the cache without validating and parsing. We need the parsed module
@@ -1048,8 +1048,16 @@
DAWN_TRY(ValidateAndParseShaderModule(this, descriptor, parseResult,
compilationMessages));
}
- DAWN_TRY_ASSIGN(result,
- CreateShaderModuleImpl(descriptor, parseResult, compilationMessages));
+
+ ResultOrError<Ref<ShaderModuleBase>> result_or_error = [&] {
+ SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(GetPlatform(), "CreateShaderModuleUS");
+ return CreateShaderModuleImpl(descriptor, parseResult, compilationMessages);
+ }();
+ DAWN_HISTOGRAM_BOOLEAN(GetPlatform(), "CreateShaderModuleSuccess",
+ result_or_error.IsSuccess());
+
+ Ref<ShaderModuleBase> result;
+ DAWN_TRY_ASSIGN(result, std::move(result_or_error));
result->SetContentHash(blueprintHash);
return result;
});
@@ -1609,7 +1617,14 @@
return cachedComputePipeline;
}
- DAWN_TRY(uninitializedComputePipeline->Initialize());
+ MaybeError maybeError;
+ {
+ SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(GetPlatform(), "CreateComputePipelineUS");
+ maybeError = uninitializedComputePipeline->Initialize();
+ }
+ DAWN_HISTOGRAM_BOOLEAN(GetPlatform(), "CreateComputePipelineSuccess", maybeError.IsSuccess());
+
+ DAWN_TRY(std::move(maybeError));
return AddOrGetCachedComputePipeline(std::move(uninitializedComputePipeline));
}
@@ -1652,7 +1667,13 @@
void DeviceBase::InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> computePipeline,
WGPUCreateComputePipelineAsyncCallback callback,
void* userdata) {
- MaybeError maybeError = computePipeline->Initialize();
+ MaybeError maybeError;
+ {
+ SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(GetPlatform(), "CreateComputePipelineUS");
+ maybeError = computePipeline->Initialize();
+ }
+ DAWN_HISTOGRAM_BOOLEAN(GetPlatform(), "CreateComputePipelineSuccess", maybeError.IsSuccess());
+
if (maybeError.IsError()) {
AddComputePipelineAsyncCallbackTask(
maybeError.AcquireError(), computePipeline->GetLabel().c_str(), callback, userdata);
@@ -1666,7 +1687,13 @@
void DeviceBase::InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata) {
- MaybeError maybeError = renderPipeline->Initialize();
+ MaybeError maybeError;
+ {
+ SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(GetPlatform(), "CreateRenderPipelineUS");
+ maybeError = renderPipeline->Initialize();
+ }
+ DAWN_HISTOGRAM_BOOLEAN(GetPlatform(), "CreateRenderPipelineSuccess", maybeError.IsSuccess());
+
if (maybeError.IsError()) {
AddRenderPipelineAsyncCallbackTask(maybeError.AcquireError(),
renderPipeline->GetLabel().c_str(), callback, userdata);
@@ -1724,7 +1751,14 @@
return cachedRenderPipeline;
}
- DAWN_TRY(uninitializedRenderPipeline->Initialize());
+ MaybeError maybeError;
+ {
+ SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(GetPlatform(), "CreateRenderPipelineUS");
+ maybeError = uninitializedRenderPipeline->Initialize();
+ }
+ DAWN_HISTOGRAM_BOOLEAN(GetPlatform(), "CreateRenderPipelineSuccess", maybeError.IsSuccess());
+
+ DAWN_TRY(std::move(maybeError));
return AddOrGetCachedRenderPipeline(std::move(uninitializedRenderPipeline));
}