Bug 1470901 - Record scene build, scene swap, and render times in telemetry. r=sotaro

MozReview-Commit-ID: 1a6pqa0sSrU

--HG--
extra : rebase_source : d00f3f4d8d8df889d4b3dc62dd1d5f797093c07a
This commit is contained in:
Kartikaya Gupta 2018-07-04 07:52:22 -04:00
Родитель e587476146
Коммит 7dd8ea5edc
4 изменённых файлов: 60 добавлений и 5 удалений

Просмотреть файл

@ -29,6 +29,7 @@
#include "mozilla/layers/AsyncImagePipelineManager.h"
#include "mozilla/layers/WebRenderImageHost.h"
#include "mozilla/layers/WebRenderTextureHost.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Unused.h"
#include "mozilla/webrender/RenderThread.h"
@ -124,6 +125,26 @@ gecko_profiler_unregister_thread()
PROFILER_UNREGISTER_THREAD();
}
void
record_telemetry_time(mozilla::wr::TelemetryProbe aProbe, uint64_t aTimeNs)
{
uint32_t time_ms = (uint32_t)(aTimeNs / 1000000);
switch (aProbe) {
case mozilla::wr::TelemetryProbe::SceneBuildTime:
mozilla::Telemetry::Accumulate(mozilla::Telemetry::WR_SCENEBUILD_TIME, time_ms);
break;
case mozilla::wr::TelemetryProbe::SceneSwapTime:
mozilla::Telemetry::Accumulate(mozilla::Telemetry::WR_SCENESWAP_TIME, time_ms);
break;
case mozilla::wr::TelemetryProbe::RenderTime:
mozilla::Telemetry::Accumulate(mozilla::Telemetry::WR_RENDER_TIME, time_ms);
break;
default:
MOZ_ASSERT(false);
break;
}
}
namespace mozilla {
namespace layers {

Просмотреть файл

@ -462,6 +462,13 @@ fn get_proc_address(glcontext_ptr: *mut c_void,
symbol as *const _
}
#[repr(C)]
pub enum TelemetryProbe {
SceneBuildTime = 0,
SceneSwapTime = 1,
RenderTime = 2,
}
extern "C" {
fn is_in_compositor_thread() -> bool;
fn is_in_render_thread() -> bool;
@ -481,6 +488,7 @@ extern "C" {
#[allow(dead_code)]
fn gfx_critical_error(msg: *const c_char);
fn gfx_critical_note(msg: *const c_char);
fn record_telemetry_time(probe: TelemetryProbe, time_ns: u64);
}
struct CppNotifier {
@ -515,8 +523,11 @@ impl RenderNotifier for CppNotifier {
_: DocumentId,
_scrolled: bool,
composite_needed: bool,
_render_time_ns: Option<u64>) {
render_time_ns: Option<u64>) {
unsafe {
if let Some(time) = render_time_ns {
record_telemetry_time(TelemetryProbe::RenderTime, time);
}
if composite_needed {
wr_notifier_new_frame_ready(self.window_id);
} else {
@ -718,13 +729,19 @@ impl SceneBuilderHooks for APZCallbacks {
unsafe { apz_register_updater(self.window_id) }
}
fn pre_scene_swap(&self, _scenebuild_time: u64) {
unsafe { apz_pre_scene_swap(self.window_id) }
fn pre_scene_swap(&self, scenebuild_time: u64) {
unsafe {
record_telemetry_time(TelemetryProbe::SceneBuildTime, scenebuild_time);
apz_pre_scene_swap(self.window_id);
}
}
fn post_scene_swap(&self, info: PipelineInfo, _sceneswap_time: u64) {
fn post_scene_swap(&self, info: PipelineInfo, sceneswap_time: u64) {
let info = WrPipelineInfo::new(info);
unsafe { apz_post_scene_swap(self.window_id, info) }
unsafe {
record_telemetry_time(TelemetryProbe::SceneSwapTime, sceneswap_time);
apz_post_scene_swap(self.window_id, info);
}
// After a scene swap we should schedule a render for the next vsync,
// otherwise there's no guarantee that the new scene will get rendered

Просмотреть файл

@ -127,4 +127,10 @@ void apz_deregister_sampler(mozilla::wr::WrWindowId aWindowId);
#undef WR_FUNC
#undef WR_DESTRUCTOR_SAFE_FUNC
// More functions invoked from Rust code. These are down here because they
// refer to data structures from webrender_ffi_generated.h
extern "C" {
void record_telemetry_time(mozilla::wr::TelemetryProbe aProbe, uint64_t aTimeNs);
}
#endif // WR_h

Просмотреть файл

@ -152,6 +152,14 @@ enum class RepeatMode : uint32_t {
Sentinel /* this must be last for serialization purposes. */
};
enum class TelemetryProbe {
SceneBuildTime = 0,
SceneSwapTime = 1,
RenderTime = 2,
Sentinel /* this must be last for serialization purposes. */
};
enum class TransformStyle : uint32_t {
Flat = 0,
Preserve3D = 1,
@ -1005,6 +1013,9 @@ extern bool is_in_main_thread();
extern bool is_in_render_thread();
extern void record_telemetry_time(TelemetryProbe aProbe,
uint64_t aTimeNs);
WR_INLINE
bool remove_program_binary_disk_cache(const nsAString *aProfPath)
WR_FUNC;