Bug 1339220 - Add telemetry probes to measure duration and max-area of animations in the compositor. r=botond,bsmedberg

MozReview-Commit-ID: KyvsNSTcxG8

--HG--
extra : rebase_source : 18626f70b714b5bfc815c16422b04258be03e02b
This commit is contained in:
Kartikaya Gupta 2017-02-16 14:40:37 -05:00
Родитель e8fcba4845
Коммит 1f59561281
6 изменённых файлов: 135 добавлений и 3 удалений

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

@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/layers/AnimationMetricsTracker.h"
#include <algorithm>
#include <inttypes.h>
#include "mozilla/Telemetry.h"
#define AMT_LOG(...)
// #define AMT_LOG(...) printf_stderr("AMT: " __VA_ARGS__)
namespace mozilla {
namespace layers {
AnimationMetricsTracker::AnimationMetricsTracker()
{
}
AnimationMetricsTracker::~AnimationMetricsTracker()
{
}
void
AnimationMetricsTracker::UpdateAnimationInProgress(bool aInProgress,
uint64_t aLayerArea)
{
MOZ_ASSERT(aInProgress || aLayerArea == 0);
if (mCurrentAnimationStart && !aInProgress) {
AnimationEnded();
mCurrentAnimationStart = TimeStamp();
mMaxLayerAreaAnimated = 0;
} else if (aInProgress) {
if (!mCurrentAnimationStart) {
mCurrentAnimationStart = TimeStamp::Now();
mMaxLayerAreaAnimated = aLayerArea;
AnimationStarted();
} else {
mMaxLayerAreaAnimated = std::max(mMaxLayerAreaAnimated, aLayerArea);
}
}
}
void
AnimationMetricsTracker::AnimationStarted()
{
}
void
AnimationMetricsTracker::AnimationEnded()
{
MOZ_ASSERT(mCurrentAnimationStart);
Telemetry::AccumulateTimeDelta(Telemetry::COMPOSITOR_ANIMATION_DURATION, mCurrentAnimationStart);
Telemetry::Accumulate(Telemetry::COMPOSITOR_ANIMATION_MAX_LAYER_AREA, mMaxLayerAreaAnimated);
AMT_LOG("Ended animation; duration: %f ms, area: %" PRIu64 "\n",
(TimeStamp::Now() - mCurrentAnimationStart).ToMilliseconds(),
mMaxLayerAreaAnimated);
}
} // namespace layers
} // namespace mozilla

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

@ -0,0 +1,40 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_layers_AnimationMetricsTracker_h
#define mozilla_layers_AnimationMetricsTracker_h
#include "mozilla/TimeStamp.h"
namespace mozilla {
namespace layers {
/**
* Tracks the start and end of compositor animations.
*/
class AnimationMetricsTracker {
public:
AnimationMetricsTracker();
~AnimationMetricsTracker();
/**
* This function should be called per composite, to inform the metrics
* tracker if any animation is in progress, and if so, what area is
* being animated. The aLayerArea is in Layer pixels squared.
*/
void UpdateAnimationInProgress(bool aInProgress, uint64_t aLayerArea);
private:
void AnimationStarted();
void AnimationEnded();
TimeStamp mCurrentAnimationStart;
uint64_t mMaxLayerAreaAnimated;
};
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_AnimationMetricsTracker_h

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

@ -634,13 +634,13 @@ ApplyAnimatedValue(Layer* aLayer,
}
static bool
SampleAnimations(Layer* aLayer, TimeStamp aPoint)
SampleAnimations(Layer* aLayer, TimeStamp aPoint, uint64_t* aLayerAreaAnimated)
{
bool activeAnimations = false;
ForEachNode<ForwardIterator>(
aLayer,
[&activeAnimations, &aPoint] (Layer* layer)
[&activeAnimations, &aPoint, &aLayerAreaAnimated] (Layer* layer)
{
bool hasInEffectAnimations = false;
StyleAnimationValue animationValue = layer->GetBaseAnimationStyle();
@ -656,6 +656,9 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
animation.property(),
animation.data(),
animationValue);
if (aLayerAreaAnimated) {
*aLayerAreaAnimated += (layer->GetVisibleRegion().Area());
}
}
});
return activeAnimations;
@ -1311,9 +1314,13 @@ AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame,
// more in sync with each other.
// On the initial frame we use aVsyncTimestamp here so the timestamp on the
// second frame are the same as the initial frame, but it does not matter.
uint64_t layerAreaAnimated = 0;
bool wantNextFrame = SampleAnimations(root,
!mPreviousFrameTimeStamp.IsNull() ?
mPreviousFrameTimeStamp : aCurrentFrame);
mPreviousFrameTimeStamp : aCurrentFrame,
&layerAreaAnimated);
mAnimationMetricsTracker.UpdateAnimationInProgress(
wantNextFrame, layerAreaAnimated);
// Reset the previous time stamp if we don't already have any running
// animations to avoid using the time which is far behind for newly

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

@ -14,6 +14,7 @@
#include "mozilla/dom/ScreenOrientation.h" // for ScreenOrientation
#include "mozilla/gfx/BasePoint.h" // for BasePoint
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/layers/AnimationMetricsTracker.h" // for AnimationMetricsTracker
#include "mozilla/layers/FrameUniformityData.h" // For FrameUniformityData
#include "mozilla/layers/LayersMessages.h" // for TargetConfig
#include "mozilla/RefPtr.h" // for nsRefPtr
@ -238,6 +239,7 @@ private:
LayerTransformRecorder mLayerTransformRecorder;
TimeStamp mPreviousFrameTimeStamp;
AnimationMetricsTracker mAnimationMetricsTracker;
#ifdef MOZ_WIDGET_ANDROID
// The following two fields are only needed on Fennec with C++ APZ, because

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

@ -142,6 +142,7 @@ EXPORTS.mozilla.layers += [
'client/TextureClientRecycleAllocator.h',
'client/TextureClientSharedSurface.h',
'client/TiledContentClient.h',
'composite/AnimationMetricsTracker.h',
'composite/AsyncCompositionManager.h',
'composite/CanvasLayerComposite.h',
'composite/ColorLayerComposite.h',
@ -322,6 +323,7 @@ UNIFIED_SOURCES += [
'client/TextureClientRecycleAllocator.cpp',
'client/TextureClientSharedSurface.cpp',
'client/TiledContentClient.cpp',
'composite/AnimationMetricsTracker.cpp',
'composite/AsyncCompositionManager.cpp',
'composite/CanvasLayerComposite.cpp',
'composite/ColorLayerComposite.cpp',

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

@ -257,6 +257,24 @@
"high": 1000,
"n_buckets": 50
},
"COMPOSITOR_ANIMATION_DURATION" : {
"expires_in_version": "58",
"description": "Duration of animations running on the compositor in milliseconds",
"kind": "exponential",
"high": 20000,
"n_buckets": 50,
"alert_emails": ["kgupta@mozilla.com"],
"bug_numbers": [1339220]
},
"COMPOSITOR_ANIMATION_MAX_LAYER_AREA" : {
"expires_in_version": "58",
"description": "High-watermark of layer area affected during a compositor animation. Units are layer pixels squared.",
"kind": "exponential",
"high": 8294400,
"n_buckets": 50,
"alert_emails": ["kgupta@mozilla.com"],
"bug_numbers": [1339220]
},
"CONTENT_PROCESS_LAUNCH_TIME_MS" : {
"alert_emails": ["bsmedberg@mozilla.com", "mconley@mozilla.com"],
"expires_in_version": "57",