Bug 918825 - Add frame duration marker. r=ehsan

--HG--
extra : rebase_source : 25f51e88ee75f47eea51bcc94a7b60f31b9605af
This commit is contained in:
Benoit Girard 2013-09-27 12:08:45 -04:00
parent dcb5764ee4
commit 8add8ce2c1
17 changed files with 113 additions and 13 deletions

View File

@ -165,6 +165,7 @@ ClientLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback,
MOZ_LAYERS_LOG((" ----- (beginning paint)"));
Log();
#endif
profiler_tracing("Paint", "Rasterize", TRACING_INTERVAL_START);
NS_ASSERTION(InConstruction(), "Should be in construction phase");
mPhase = PHASE_DRAWING;

View File

@ -547,6 +547,7 @@ CompositorParent::Composite()
15 + (int)(TimeStamp::Now() - mExpectedComposeTime).ToMilliseconds());
}
#endif
profiler_tracing("Paint", "Composite", TRACING_INTERVAL_END);
}
void

View File

@ -187,6 +187,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
const bool& isFirstPaint,
InfallibleTArray<EditReply>* reply)
{
profiler_tracing("Paint", "Composite", TRACING_INTERVAL_START);
PROFILER_LABEL("LayerTransactionParent", "RecvUpdate");
#ifdef COMPOSITOR_PERFORMANCE_WARNING
TimeStamp updateStart = TimeStamp::Now();

View File

@ -539,6 +539,7 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
MOZ_LAYERS_LOG(("[LayersForwarder] syncing before send..."));
PlatformSyncBeforeUpdate();
profiler_tracing("Paint", "Rasterize", TRACING_INTERVAL_END);
if (mTxn->mSwapRequired) {
MOZ_LAYERS_LOG(("[LayersForwarder] sending transaction..."));
RenderTraceScope rendertrace3("Forward Transaction", "000093");

View File

@ -1059,6 +1059,8 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
return;
}
profiler_tracing("Paint", "RD", TRACING_INTERVAL_START);
/*
* The timer holds a reference to |this| while calling |Notify|.
* However, implementations of |WillRefresh| are permitted to destroy
@ -1073,6 +1075,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
if (!mPresContext || !mPresContext->GetPresShell()) {
StopTimer();
profiler_tracing("Paint", "RD", TRACING_INTERVAL_END);
return;
}
}
@ -1090,6 +1093,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
// readded as needed.
mFrameRequestCallbackDocs.Clear();
profiler_tracing("Paint", "Scripts", TRACING_INTERVAL_START);
int64_t eventTime = aNowEpoch / PR_USEC_PER_MSEC;
for (uint32_t i = 0; i < frameRequestCallbacks.Length(); ++i) {
const DocumentFrameCallbacks& docCallbacks = frameRequestCallbacks[i];
@ -1116,6 +1120,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
}
}
}
profiler_tracing("Paint", "Scripts", TRACING_INTERVAL_END);
// This is the Flush_Style case.
if (mPresContext && mPresContext->GetPresShell()) {
@ -1214,6 +1219,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
for (uint32_t i = 0; i < mPostRefreshObservers.Length(); ++i) {
mPostRefreshObservers[i]->DidRefresh();
}
profiler_tracing("Paint", "RD", TRACING_INTERVAL_END);
}
/* static */ PLDHashOperator

View File

@ -13,7 +13,7 @@
// Profiler
#include "PlatformMacros.h"
#include "GeckoProfilerImpl.h"
#include "GeckoProfiler.h"
#include "platform.h"
#include "nsXULAppAPI.h"
#include "nsThreadUtils.h"

View File

@ -56,6 +56,12 @@ namespace mozilla {
class TimeStamp;
}
enum TracingMetadata {
TRACING_DEFAULT,
TRACING_INTERVAL_START,
TRACING_INTERVAL_END
};
#ifndef MOZ_ENABLE_PROFILER_SPS
#include <stdint.h>
@ -82,6 +88,9 @@ class TimeStamp;
#define PROFILER_MAIN_THREAD_LABEL(name_space, info) do {} while (0)
#define PROFILER_MAIN_THREAD_LABEL_PRINTF(name_space, info, format, ...) do {} while (0)
static inline void profiler_tracing(const char* aCategory, const char* aInfo,
TracingMetadata metaData = TRACING_DEFAULT) {}
// Initilize the profiler TLS, signal handlers on linux. If MOZ_PROFILER_STARTUP
// is set the profiler will be started. This call must happen before any other
// sampler calls. Particularly sampler_label/sampler_marker.

View File

@ -78,5 +78,8 @@ double mozilla_sampler_time(const mozilla::TimeStamp& aTime);
/* Returns true if env var SPS_NEW is set to anything, else false. */
extern bool sps_version2();
void mozilla_sampler_tracing(const char* aCategory, const char* aInfo,
TracingMetadata aMetaData);
#endif

View File

@ -201,6 +201,21 @@ bool profiler_in_privacy_mode()
return stack->mPrivacyMode;
}
static inline void profiler_tracing(const char* aCategory, const char* aInfo,
TracingMetadata aMetaData = TRACING_DEFAULT)
{
if (!stack_key_initialized)
return;
// Don't insert a marker if we're not profiling to avoid
// the heap copy (malloc).
if (!profiler_is_active()) {
return;
}
mozilla_sampler_tracing(aCategory, aInfo, aMetaData);
}
// we want the class and function name but can't easily get that using preprocessor macros
// __func__ doesn't have the class name and __PRETTY_FUNCTION__ has the parameters
@ -210,11 +225,13 @@ bool profiler_in_privacy_mode()
#define PROFILER_LABEL(name_space, info) mozilla::SamplerStackFrameRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, __LINE__)
#define PROFILER_LABEL_PRINTF(name_space, info, ...) mozilla::SamplerStackFramePrintfRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, __LINE__, __VA_ARGS__)
#define PROFILER_MARKER(info) mozilla_sampler_add_marker(info)
#define PROFILER_MARKER_PAYLOAD(info, payload) mozilla_sampler_add_marker(info, payload)
#define PROFILER_MAIN_THREAD_MARKER(info) MOZ_ASSERT(NS_IsMainThread(), "This can only be called on the main thread"); mozilla_sampler_add_marker(info)
#define PROFILER_MAIN_THREAD_LABEL(name_space, info) MOZ_ASSERT(NS_IsMainThread(), "This can only be called on the main thread"); mozilla::SamplerStackFrameRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, __LINE__)
#define PROFILER_MAIN_THREAD_LABEL_PRINTF(name_space, info, ...) MOZ_ASSERT(NS_IsMainThread(), "This can only be called on the main thread"); mozilla::SamplerStackFramePrintfRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, __LINE__, __VA_ARGS__)
#define PROFILER_MAIN_THREAD_MARKER(info) MOZ_ASSERT(NS_IsMainThread(), "This can only be called on the main thread"); mozilla_sampler_add_marker(info)
/* FIXME/bug 789667: memory constraints wouldn't much of a problem for

View File

@ -4,7 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <ostream>
#include "GeckoProfilerImpl.h"
#include "platform.h"
#include "nsThreadUtils.h"
#include "nsXULAppAPI.h"
@ -157,10 +156,11 @@ ThreadProfile::ThreadProfile(const char* aName, int aEntrySize,
, mThreadId(aThreadId)
, mIsMainThread(aIsMainThread)
, mPlatformData(aPlatform)
, mGeneration(0)
, mPendingGenerationFlush(0)
, mStackTop(aStackTop)
{
mEntries = new ProfileEntry[mEntrySize];
mGeneration = 0;
}
ThreadProfile::~ThreadProfile()

View File

@ -8,7 +8,7 @@
#define MOZ_PROFILE_ENTRY_H
#include <ostream>
#include "GeckoProfilerImpl.h"
#include "GeckoProfiler.h"
#include "platform.h"
#include "ProfilerBacktrace.h"
#include "mozilla/Mutex.h"

View File

@ -16,9 +16,9 @@ ProfilerMarkerPayload::ProfilerMarkerPayload(ProfilerBacktrace* aStack)
ProfilerMarkerPayload::ProfilerMarkerPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
ProfilerBacktrace* aStack)
: mStartTime(aStartTime),
mEndTime(aEndTime),
mStack(aStack)
: mStartTime(aStartTime)
, mEndTime(aEndTime)
, mStack(aStack)
{}
ProfilerMarkerPayload::~ProfilerMarkerPayload()
@ -58,6 +58,37 @@ ProfilerMarkerPayload::prepareCommonProps<JSObjectBuilder>(
JSObjectBuilder& b,
JSObjectBuilder::ObjectHandle aObject);
ProfilerMarkerTracing::ProfilerMarkerTracing(const char* aCategory, TracingMetadata aMetaData)
: mCategory(aCategory)
, mMetaData(aMetaData)
{}
template<typename Builder>
typename Builder::Object
ProfilerMarkerTracing::preparePayloadImp(Builder& b)
{
typename Builder::RootedObject data(b.context(), b.CreateObject());
prepareCommonProps("tracing", b, data);
if (GetCategory()) {
b.DefineProperty(data, "category", GetCategory());
}
if (GetMetaData() != TRACING_DEFAULT) {
if (GetMetaData() == TRACING_INTERVAL_START) {
b.DefineProperty(data, "interval", "start");
} else if (GetMetaData() == TRACING_INTERVAL_END) {
b.DefineProperty(data, "interval", "end");
}
}
return data;
}
template JSCustomObjectBuilder::Object
ProfilerMarkerTracing::preparePayloadImp<JSCustomObjectBuilder>(JSCustomObjectBuilder& b);
template JSObjectBuilder::Object
ProfilerMarkerTracing::preparePayloadImp<JSObjectBuilder>(JSObjectBuilder& b);
ProfilerMarkerImagePayload::ProfilerMarkerImagePayload(gfxASurface *aImg)
: mImg(aImg)
{}

View File

@ -74,6 +74,30 @@ private:
ProfilerBacktrace* mStack;
};
class ProfilerMarkerTracing : public ProfilerMarkerPayload
{
public:
ProfilerMarkerTracing(const char* aCategory, TracingMetadata aMetaData);
const char *GetCategory() const { return mCategory; }
TracingMetadata GetMetaData() const { return mMetaData; }
protected:
virtual JSCustomObjectBuilder::Object
preparePayload(JSCustomObjectBuilder& b) { return preparePayloadImp(b); }
virtual JSObjectBuilder::Object
preparePayload(JSObjectBuilder& b) { return preparePayloadImp(b); }
private:
template<typename Builder>
typename Builder::Object preparePayloadImp(Builder& b);
private:
const char *mCategory;
TracingMetadata mMetaData;
};
class gfxASurface;
class ProfilerMarkerImagePayload : public ProfilerMarkerPayload
{
@ -89,7 +113,7 @@ protected:
private:
template<typename Builder>
typename Builder::Object preparePayloadImp(Builder& b);
nsRefPtr<gfxASurface> mImg;
};
@ -109,7 +133,7 @@ protected:
private:
template<typename Builder>
typename Builder::Object preparePayloadImp(Builder& b);
const char* mSource;
};

View File

@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "SaveProfileTask.h"
#include "GeckoProfilerImpl.h"
#include "GeckoProfiler.h"
static bool
WriteCallback(const jschar *buf, uint32_t len, void *data)

View File

@ -7,7 +7,7 @@
#include <stdio.h>
#include <fstream>
#include <sstream>
#include "GeckoProfilerImpl.h"
#include "GeckoProfiler.h"
#include "SaveProfileTask.h"
#include "ProfileEntry.h"
#include "SyncProfile.h"

View File

@ -66,7 +66,7 @@
#include <errno.h>
#include <stdarg.h>
#include "platform.h"
#include "GeckoProfilerImpl.h"
#include "GeckoProfiler.h"
#include "mozilla/Mutex.h"
#include "mozilla/Atomics.h"
#include "ProfileEntry.h"

View File

@ -788,6 +788,12 @@ void mozilla_sampler_free_backtrace(ProfilerBacktrace* aBacktrace)
delete aBacktrace;
}
void mozilla_sampler_tracing(const char* aCategory, const char* aInfo,
TracingMetadata aMetaData)
{
mozilla_sampler_add_marker(aInfo, new ProfilerMarkerTracing(aCategory, aMetaData));
}
// END externally visible functions
////////////////////////////////////////////////////////////////////////