Backed out changeset 859ae92f4110 (bug 1608556) for bustages on ProfilerMarkerPayload.h. CLOSED TREE

--HG--
extra : histedit_source : 297a94849cc019db6bc32ecadfdd119347da4ac8
This commit is contained in:
Narcis Beleuzu 2020-04-03 21:58:02 +03:00
parent f6ebb84618
commit 1aa55f1914
7 changed files with 14 additions and 128 deletions

View File

@ -2293,13 +2293,13 @@ BrowserGlue.prototype = {
ChromeUtils.idleDispatch(
() => {
if (!Services.startup.shuttingDown) {
let startTime = Cu.now();
if (Services.profiler) {
Services.profiler.AddMarker("startupIdleTask");
}
try {
task.task();
} catch (ex) {
Cu.reportError(ex);
} finally {
ChromeUtils.addProfilerMarker("startupIdleTask", startTime);
}
}
},
@ -2372,13 +2372,13 @@ BrowserGlue.prototype = {
for (let task of idleTasks) {
ChromeUtils.idleDispatch(() => {
if (!Services.startup.shuttingDown) {
let startTime = Cu.now();
if (Services.profiler) {
Services.profiler.AddMarker("startupLateIdleTask");
}
try {
task();
} catch (ex) {
Cu.reportError(ex);
} finally {
ChromeUtils.addProfilerMarker("startupLateIdleTask", startTime);
}
}
});

View File

@ -31,7 +31,6 @@
#include "mozilla/dom/MediaControlService.h"
#include "mozilla/dom/MediaMetadata.h"
#include "mozilla/dom/MediaSessionBinding.h"
#include "mozilla/dom/Performance.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ReportingHeader.h"
#include "mozilla/dom/UnionTypes.h"
@ -45,9 +44,6 @@
#include "nsThreadUtils.h"
#include "mozJSComponentLoader.h"
#include "GeckoProfiler.h"
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
#endif
#include "nsIException.h"
namespace mozilla {
@ -188,57 +184,6 @@ void ChromeUtils::ReleaseAssert(GlobalObject& aGlobal, bool aCondition,
messageUtf8.get(), filenameUtf8.get(), lineNo);
}
/* static */
void ChromeUtils::AddProfilerMarker(
GlobalObject& aGlobal, const nsACString& aName,
const Optional<DOMHighResTimeStamp>& aStartTime,
const Optional<nsACString>& aText) {
#ifdef MOZ_GECKO_PROFILER
const nsCString& name = PromiseFlatCString(aName);
if (!aText.WasPassed() && !aStartTime.WasPassed()) {
profiler_add_js_marker(name.get());
return;
}
TimeStamp now = mozilla::TimeStamp::NowUnfuzzed();
TimeStamp startTime = now;
if (aStartTime.WasPassed()) {
RefPtr<Performance> performance;
if (NS_IsMainThread()) {
nsCOMPtr<nsPIDOMWindowInner> ownerWindow =
do_QueryInterface(aGlobal.GetAsSupports());
if (ownerWindow) {
performance = ownerWindow->GetPerformance();
}
} else {
JSContext* cx = aGlobal.Context();
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
if (workerPrivate) {
performance = workerPrivate->GlobalScope()->GetPerformance();
}
}
if (performance) {
startTime = performance->CreationTimeStamp() +
TimeDuration::FromMilliseconds(aStartTime.Value());
} else {
startTime = TimeStamp::ProcessCreation() +
TimeDuration::FromMilliseconds(aStartTime.Value());
}
}
if (aText.WasPassed()) {
profiler_add_text_marker(name.get(), aText.Value(),
JS::ProfilingCategoryPair::JS, startTime, now);
} else {
profiler_add_marker(name.get(), JS::ProfilingCategoryPair::JS,
TimingMarkerPayload(startTime, now));
}
#endif
}
/* static */
void ChromeUtils::WaiveXrays(GlobalObject& aGlobal, JS::HandleValue aVal,
JS::MutableHandleValue aRetval, ErrorResult& aRv) {

View File

@ -11,7 +11,6 @@
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/ChromeUtilsBinding.h"
#include "mozilla/ErrorResult.h"
#include "nsDOMNavigationTiming.h" // for DOMHighResTimeStamp
#include "nsIContentChild.h"
namespace mozilla {
@ -79,10 +78,6 @@ class ChromeUtils {
static void ReleaseAssert(GlobalObject& aGlobal, bool aCondition,
const nsAString& aMessage);
static void AddProfilerMarker(GlobalObject& aGlobal, const nsACString& aName,
const Optional<DOMHighResTimeStamp>& aStartTime,
const Optional<nsACString>& text);
static void OriginAttributesToSuffix(
GlobalObject& aGlobal, const dom::OriginAttributesDictionary& aAttrs,
nsCString& aSuffix);

View File

@ -157,22 +157,6 @@ namespace ChromeUtils {
void clearRecentJSDevError();
#endif // NIGHTLY_BUILD
/**
* If the profiler is currently running and recording the current thread,
* add a marker for the current thread. No-op otherwise.
*
* @param name The name of the marker.
* @param startTime The timestamp to use as the start of the marker.
* If omitted, the marker will have no duration.
* In window and ChromeWorker contexts, use a
* timestamp from `performance.now()`.
* In JS modules, use `Cu.now()` to get a timestamp.
* @param text Text to associate with the marker.
*/
void addProfilerMarker(UTF8String name,
optional DOMHighResTimeStamp startTime,
optional UTF8String text);
/**
* IF YOU ADD NEW METHODS HERE, MAKE SURE THEY ARE THREAD-SAFE.
*/

View File

@ -29,21 +29,22 @@ if (this.Components) {
let worker = new PromiseWorker.AbstractWorker();
worker.dispatch = function(method, args = []) {
let startTime = performance.now();
let prefix = "OS.File " + method;
performance.mark(prefix + "-start");
try {
return Agent[method](...args);
} finally {
let text = method;
let name = prefix;
if (args.length && args[0] instanceof Object && args[0].string) {
// Including the path in the marker text here means it will be part of
// Including the path in the marker name here means it will be part of
// profiles. It's fine to include personally identifiable information
// in profiles, because when a profile is captured only the user will
// see it, and before uploading it a sanitization step will be offered.
// The 'OS.File' name will help the profiler know that these markers
// should be sanitized.
text += " — " + args[0].string;
// The 'OS.File ' prefix will help the profiler know that these marker
// names should be sanitized.
name += " — " + args[0].string;
}
ChromeUtils.addProfilerMarker("OS.File", startTime, text);
performance.measure(name, prefix + "-start");
}
};
worker.log = LOG;

View File

@ -300,32 +300,6 @@ void UserTimingMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
}
}
ProfileBufferEntryWriter::Length TimingMarkerPayload::TagAndSerializationBytes()
const {
return CommonPropsTagAndSerializationBytes();
}
void TimingMarkerPayload::SerializeTagAndPayload(
ProfileBufferEntryWriter& aEntryWriter) const {
static const DeserializerTag tag = TagForDeserializer(Deserialize);
SerializeTagAndCommonProps(tag, aEntryWriter);
}
// static
UniquePtr<ProfilerMarkerPayload> TimingMarkerPayload::Deserialize(
ProfileBufferEntryReader& aEntryReader) {
ProfilerMarkerPayload::CommonProps props =
DeserializeCommonProps(aEntryReader);
return UniquePtr<ProfilerMarkerPayload>(
new TimingMarkerPayload(std::move(props)));
}
void TimingMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks) const {
StreamCommonProps("Timing", aWriter, aProcessStartTime, aUniqueStacks);
}
ProfileBufferEntryWriter::Length TextMarkerPayload::TagAndSerializationBytes()
const {
return CommonPropsTagAndSerializationBytes() +

View File

@ -578,19 +578,6 @@ class LongTaskMarkerPayload : public ProfilerMarkerPayload {
: ProfilerMarkerPayload(std::move(aCommonProps)) {}
};
class TimingMarkerPayload : public ProfilerMarkerPayload {
public:
TimingMarkerPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime)
: ProfilerMarkerPayload(aStartTime, aEndTime) {}
DECL_STREAM_PAYLOAD
private:
TimingMarkerPayload(CommonProps&& aCommonProps)
: ProfilerMarkerPayload(std::move(aCommonProps)) {}
};
class TextMarkerPayload : public ProfilerMarkerPayload {
public:
TextMarkerPayload(const nsACString& aText,