зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset ccf1b5218169 (bug 1843534) for bustages on ProfilerMarkers.h . CLOSED TREE
This commit is contained in:
Родитель
9c4b9bb36d
Коммит
ef9a0d3c1a
|
@ -323,7 +323,7 @@ class PerformanceRecorderImpl : public PerformanceRecorderBase {
|
|||
MOZ_ASSERT(elapsedTimeUs >= 0, "Elapsed time can't be less than 0!");
|
||||
aStageMutator(stage);
|
||||
AUTO_PROFILER_STATS(PROFILER_MARKER_UNTYPED);
|
||||
profiler_add_marker(
|
||||
::profiler_add_marker(
|
||||
stage.Name(), stage.Category(),
|
||||
MarkerOptions(MarkerTiming::Interval(startTime, now)));
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ inline mozilla::ProfileBufferBlockIndex AddMarkerToBuffer(
|
|||
// - aPayloadArguments: Arguments expected by this marker type's
|
||||
// ` StreamJSONMarkerData` function.
|
||||
template <typename MarkerType, typename... PayloadArguments>
|
||||
mozilla::ProfileBufferBlockIndex profiler_add_marker_impl(
|
||||
mozilla::ProfileBufferBlockIndex profiler_add_marker(
|
||||
const mozilla::ProfilerString8View& aName,
|
||||
const mozilla::MarkerCategory& aCategory, mozilla::MarkerOptions&& aOptions,
|
||||
MarkerType aMarkerType, const PayloadArguments&... aPayloadArguments) {
|
||||
|
@ -161,48 +161,31 @@ mozilla::ProfileBufferBlockIndex profiler_add_marker_impl(
|
|||
}
|
||||
|
||||
// Add a marker (without payload) to the Gecko Profiler buffer.
|
||||
inline mozilla::ProfileBufferBlockIndex profiler_add_marker_impl(
|
||||
inline mozilla::ProfileBufferBlockIndex profiler_add_marker(
|
||||
const mozilla::ProfilerString8View& aName,
|
||||
const mozilla::MarkerCategory& aCategory,
|
||||
mozilla::MarkerOptions&& aOptions = {}) {
|
||||
return profiler_add_marker_impl(aName, aCategory, std::move(aOptions),
|
||||
mozilla::baseprofiler::markers::NoPayload{});
|
||||
return profiler_add_marker(aName, aCategory, std::move(aOptions),
|
||||
mozilla::baseprofiler::markers::NoPayload{});
|
||||
}
|
||||
|
||||
// `profiler_add_marker` is a macro rather than a function so that arguments to
|
||||
// it aren't unconditionally evaluated when not profiled. Some of the arguments
|
||||
// might be non-trivial, see bug 1843534.
|
||||
//
|
||||
// The check used around `::profiler_add_marker_impl()` is a bit subtle.
|
||||
// Naively, you might want to do
|
||||
// `profiler_thread_is_being_profiled_for_markers()`, but markers can be
|
||||
// targeted to different threads.
|
||||
// So we do a cheaper `profiler_is_active_and_unpaused()` check instead to
|
||||
// avoid any marker overhead when not profiling.
|
||||
#define profiler_add_marker(...) \
|
||||
do { \
|
||||
if (profiler_is_active_and_unpaused()) { \
|
||||
::profiler_add_marker_impl(__VA_ARGS__); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
// Same as `profiler_add_marker()` (without payload). This macro is safe to use
|
||||
// even if MOZ_GECKO_PROFILER is not #defined.
|
||||
#define PROFILER_MARKER_UNTYPED(markerName, categoryName, ...) \
|
||||
do { \
|
||||
AUTO_PROFILER_STATS(PROFILER_MARKER_UNTYPED); \
|
||||
profiler_add_marker(markerName, ::geckoprofiler::category::categoryName, \
|
||||
##__VA_ARGS__); \
|
||||
#define PROFILER_MARKER_UNTYPED(markerName, categoryName, ...) \
|
||||
do { \
|
||||
AUTO_PROFILER_STATS(PROFILER_MARKER_UNTYPED); \
|
||||
::profiler_add_marker(markerName, ::geckoprofiler::category::categoryName, \
|
||||
##__VA_ARGS__); \
|
||||
} while (false)
|
||||
|
||||
// Same as `profiler_add_marker()` (with payload). This macro is safe to use
|
||||
// even if MOZ_GECKO_PROFILER is not #defined.
|
||||
#define PROFILER_MARKER(markerName, categoryName, options, MarkerType, ...) \
|
||||
do { \
|
||||
AUTO_PROFILER_STATS(PROFILER_MARKER_with_##MarkerType); \
|
||||
profiler_add_marker(markerName, ::geckoprofiler::category::categoryName, \
|
||||
options, ::geckoprofiler::markers::MarkerType{}, \
|
||||
##__VA_ARGS__); \
|
||||
#define PROFILER_MARKER(markerName, categoryName, options, MarkerType, ...) \
|
||||
do { \
|
||||
AUTO_PROFILER_STATS(PROFILER_MARKER_with_##MarkerType); \
|
||||
::profiler_add_marker(markerName, ::geckoprofiler::category::categoryName, \
|
||||
options, ::geckoprofiler::markers::MarkerType{}, \
|
||||
##__VA_ARGS__); \
|
||||
} while (false)
|
||||
|
||||
namespace geckoprofiler::markers {
|
||||
|
@ -213,12 +196,12 @@ using Tracing = mozilla::baseprofiler::markers::Tracing;
|
|||
|
||||
// Add a text marker. This macro is safe to use even if MOZ_GECKO_PROFILER is
|
||||
// not #defined.
|
||||
#define PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
|
||||
do { \
|
||||
AUTO_PROFILER_STATS(PROFILER_MARKER_TEXT); \
|
||||
profiler_add_marker(markerName, ::geckoprofiler::category::categoryName, \
|
||||
options, ::geckoprofiler::markers::TextMarker{}, \
|
||||
text); \
|
||||
#define PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
|
||||
do { \
|
||||
AUTO_PROFILER_STATS(PROFILER_MARKER_TEXT); \
|
||||
::profiler_add_marker(markerName, ::geckoprofiler::category::categoryName, \
|
||||
options, ::geckoprofiler::markers::TextMarker{}, \
|
||||
text); \
|
||||
} while (false)
|
||||
|
||||
// RAII object that adds a PROFILER_MARKER_TEXT when destroyed; the marker's
|
||||
|
@ -277,6 +260,9 @@ class MOZ_RAII AutoProfilerTracing {
|
|||
mMarkerName(aMarkerName),
|
||||
mCategoryPair(aCategoryPair),
|
||||
mInnerWindowID(aInnerWindowID) {
|
||||
if (!profiler_thread_is_being_profiled_for_markers()) {
|
||||
return;
|
||||
}
|
||||
profiler_add_marker(
|
||||
mozilla::ProfilerString8View::WrapNullTerminatedString(mMarkerName),
|
||||
mCategoryPair,
|
||||
|
@ -296,6 +282,9 @@ class MOZ_RAII AutoProfilerTracing {
|
|||
mMarkerName(aMarkerName),
|
||||
mCategoryPair(aCategoryPair),
|
||||
mInnerWindowID(aInnerWindowID) {
|
||||
if (!profiler_thread_is_being_profiled_for_markers()) {
|
||||
return;
|
||||
}
|
||||
profiler_add_marker(
|
||||
mozilla::ProfilerString8View::WrapNullTerminatedString(mMarkerName),
|
||||
mCategoryPair,
|
||||
|
@ -308,6 +297,9 @@ class MOZ_RAII AutoProfilerTracing {
|
|||
}
|
||||
|
||||
~AutoProfilerTracing() {
|
||||
if (!profiler_thread_is_being_profiled_for_markers()) {
|
||||
return;
|
||||
}
|
||||
profiler_add_marker(
|
||||
mozilla::ProfilerString8View::WrapNullTerminatedString(mMarkerName),
|
||||
mCategoryPair,
|
||||
|
@ -353,17 +345,17 @@ extern template mozilla::ProfileBufferBlockIndex AddMarkerToBuffer(
|
|||
const mozilla::MarkerCategory&, mozilla::MarkerOptions&&,
|
||||
mozilla::baseprofiler::markers::TextMarker, const std::string&);
|
||||
|
||||
extern template mozilla::ProfileBufferBlockIndex profiler_add_marker_impl(
|
||||
extern template mozilla::ProfileBufferBlockIndex profiler_add_marker(
|
||||
const mozilla::ProfilerString8View&, const mozilla::MarkerCategory&,
|
||||
mozilla::MarkerOptions&&, mozilla::baseprofiler::markers::TextMarker,
|
||||
const std::string&);
|
||||
|
||||
extern template mozilla::ProfileBufferBlockIndex profiler_add_marker_impl(
|
||||
extern template mozilla::ProfileBufferBlockIndex profiler_add_marker(
|
||||
const mozilla::ProfilerString8View&, const mozilla::MarkerCategory&,
|
||||
mozilla::MarkerOptions&&, mozilla::baseprofiler::markers::TextMarker,
|
||||
const nsCString&);
|
||||
|
||||
extern template mozilla::ProfileBufferBlockIndex profiler_add_marker_impl(
|
||||
extern template mozilla::ProfileBufferBlockIndex profiler_add_marker(
|
||||
const mozilla::ProfilerString8View&, const mozilla::MarkerCategory&,
|
||||
mozilla::MarkerOptions&&, mozilla::baseprofiler::markers::Tracing,
|
||||
const mozilla::ProfilerString8View&);
|
||||
|
|
|
@ -2389,9 +2389,9 @@ TEST(GeckoProfiler, Markers)
|
|||
longstrCut[kMax - 1] = '\0';
|
||||
|
||||
// Test basic markers 2.0.
|
||||
EXPECT_TRUE(profiler_add_marker_impl(
|
||||
"default-templated markers 2.0 with empty options",
|
||||
geckoprofiler::category::OTHER, {}));
|
||||
EXPECT_TRUE(
|
||||
profiler_add_marker("default-templated markers 2.0 with empty options",
|
||||
geckoprofiler::category::OTHER, {}));
|
||||
|
||||
PROFILER_MARKER_UNTYPED(
|
||||
"default-templated markers 2.0 with option", OTHER,
|
||||
|
@ -2400,7 +2400,7 @@ TEST(GeckoProfiler, Markers)
|
|||
PROFILER_MARKER("explicitly-default-templated markers 2.0 with empty options",
|
||||
OTHER, {}, NoPayload);
|
||||
|
||||
EXPECT_TRUE(profiler_add_marker_impl(
|
||||
EXPECT_TRUE(profiler_add_marker(
|
||||
"explicitly-default-templated markers 2.0 with option",
|
||||
geckoprofiler::category::OTHER, {},
|
||||
::geckoprofiler::markers::NoPayload{}));
|
||||
|
@ -2421,10 +2421,10 @@ TEST(GeckoProfiler, Markers)
|
|||
|
||||
// Keep this one first! (It's used to record `ts1` and `ts2`, to compare
|
||||
// to serialized numbers in other markers.)
|
||||
EXPECT_TRUE(profiler_add_marker_impl(
|
||||
"FirstMarker", geckoprofiler::category::OTHER,
|
||||
MarkerTiming::Interval(ts1, ts2), geckoprofiler::markers::TextMarker{},
|
||||
"First Marker"));
|
||||
EXPECT_TRUE(profiler_add_marker("FirstMarker", geckoprofiler::category::OTHER,
|
||||
MarkerTiming::Interval(ts1, ts2),
|
||||
geckoprofiler::markers::TextMarker{},
|
||||
"First Marker"));
|
||||
|
||||
// User-defined marker type with different properties, and fake schema.
|
||||
struct GtestMarker {
|
||||
|
@ -2483,10 +2483,10 @@ TEST(GeckoProfiler, Markers)
|
|||
return schema;
|
||||
}
|
||||
};
|
||||
EXPECT_TRUE(profiler_add_marker_impl(
|
||||
"Gtest custom marker", geckoprofiler::category::OTHER,
|
||||
MarkerTiming::Interval(ts1, ts2), GtestMarker{}, 42, 43.0, "gtest text",
|
||||
"gtest unique text", ts1));
|
||||
EXPECT_TRUE(
|
||||
profiler_add_marker("Gtest custom marker", geckoprofiler::category::OTHER,
|
||||
MarkerTiming::Interval(ts1, ts2), GtestMarker{}, 42,
|
||||
43.0, "gtest text", "gtest unique text", ts1));
|
||||
|
||||
// User-defined marker type with no data, special frontend schema.
|
||||
struct GtestSpecialMarker {
|
||||
|
@ -2499,9 +2499,9 @@ TEST(GeckoProfiler, Markers)
|
|||
return mozilla::MarkerSchema::SpecialFrontendLocation{};
|
||||
}
|
||||
};
|
||||
EXPECT_TRUE(profiler_add_marker_impl("Gtest special marker",
|
||||
geckoprofiler::category::OTHER, {},
|
||||
GtestSpecialMarker{}));
|
||||
EXPECT_TRUE(profiler_add_marker("Gtest special marker",
|
||||
geckoprofiler::category::OTHER, {},
|
||||
GtestSpecialMarker{}));
|
||||
|
||||
// User-defined marker type that is never used, so it shouldn't appear in the
|
||||
// output.
|
||||
|
@ -2693,11 +2693,11 @@ TEST(GeckoProfiler, Markers)
|
|||
/* uint64_t aRedirectChannelId = 0 */
|
||||
);
|
||||
|
||||
EXPECT_TRUE(profiler_add_marker_impl(
|
||||
EXPECT_TRUE(profiler_add_marker(
|
||||
"Text in main thread with stack", geckoprofiler::category::OTHER,
|
||||
{MarkerStack::Capture(), MarkerTiming::Interval(ts1, ts2)},
|
||||
geckoprofiler::markers::TextMarker{}, ""));
|
||||
EXPECT_TRUE(profiler_add_marker_impl(
|
||||
EXPECT_TRUE(profiler_add_marker(
|
||||
"Text from main thread with stack", geckoprofiler::category::OTHER,
|
||||
MarkerOptions(MarkerThreadId::MainThread(), MarkerStack::Capture()),
|
||||
geckoprofiler::markers::TextMarker{}, ""));
|
||||
|
@ -2705,11 +2705,11 @@ TEST(GeckoProfiler, Markers)
|
|||
std::thread registeredThread([]() {
|
||||
AUTO_PROFILER_REGISTER_THREAD("Marker test sub-thread");
|
||||
// Marker in non-profiled thread won't be stored.
|
||||
EXPECT_FALSE(profiler_add_marker_impl(
|
||||
EXPECT_FALSE(profiler_add_marker(
|
||||
"Text in registered thread with stack", geckoprofiler::category::OTHER,
|
||||
MarkerStack::Capture(), geckoprofiler::markers::TextMarker{}, ""));
|
||||
// Marker will be stored in main thread, with stack from registered thread.
|
||||
EXPECT_TRUE(profiler_add_marker_impl(
|
||||
EXPECT_TRUE(profiler_add_marker(
|
||||
"Text from registered thread with stack",
|
||||
geckoprofiler::category::OTHER,
|
||||
MarkerOptions(MarkerThreadId::MainThread(), MarkerStack::Capture()),
|
||||
|
@ -2719,13 +2719,13 @@ TEST(GeckoProfiler, Markers)
|
|||
|
||||
std::thread unregisteredThread([]() {
|
||||
// Marker in unregistered thread won't be stored.
|
||||
EXPECT_FALSE(profiler_add_marker_impl(
|
||||
"Text in unregistered thread with stack",
|
||||
geckoprofiler::category::OTHER, MarkerStack::Capture(),
|
||||
geckoprofiler::markers::TextMarker{}, ""));
|
||||
EXPECT_FALSE(profiler_add_marker("Text in unregistered thread with stack",
|
||||
geckoprofiler::category::OTHER,
|
||||
MarkerStack::Capture(),
|
||||
geckoprofiler::markers::TextMarker{}, ""));
|
||||
// Marker will be stored in main thread, but stack cannot be captured in an
|
||||
// unregistered thread.
|
||||
EXPECT_TRUE(profiler_add_marker_impl(
|
||||
EXPECT_TRUE(profiler_add_marker(
|
||||
"Text from unregistered thread with stack",
|
||||
geckoprofiler::category::OTHER,
|
||||
MarkerOptions(MarkerThreadId::MainThread(), MarkerStack::Capture()),
|
||||
|
@ -2733,22 +2733,22 @@ TEST(GeckoProfiler, Markers)
|
|||
});
|
||||
unregisteredThread.join();
|
||||
|
||||
EXPECT_TRUE(
|
||||
profiler_add_marker_impl("Tracing", geckoprofiler::category::OTHER, {},
|
||||
geckoprofiler::markers::Tracing{}, "category"));
|
||||
EXPECT_TRUE(profiler_add_marker("Tracing", geckoprofiler::category::OTHER, {},
|
||||
geckoprofiler::markers::Tracing{},
|
||||
"category"));
|
||||
|
||||
EXPECT_TRUE(profiler_add_marker_impl("Text", geckoprofiler::category::OTHER,
|
||||
{}, geckoprofiler::markers::TextMarker{},
|
||||
"Text text"));
|
||||
EXPECT_TRUE(profiler_add_marker("Text", geckoprofiler::category::OTHER, {},
|
||||
geckoprofiler::markers::TextMarker{},
|
||||
"Text text"));
|
||||
|
||||
// Ensure that we evaluate to false for markers with very long texts by
|
||||
// testing against a ~3mb string. A string of this size should exceed the
|
||||
// available buffer chunks (max: 2) that are available and be discarded.
|
||||
EXPECT_FALSE(profiler_add_marker_impl(
|
||||
"Text", geckoprofiler::category::OTHER, {},
|
||||
geckoprofiler::markers::TextMarker{}, std::string(3 * 1024 * 1024, 'x')));
|
||||
EXPECT_FALSE(profiler_add_marker("Text", geckoprofiler::category::OTHER, {},
|
||||
geckoprofiler::markers::TextMarker{},
|
||||
std::string(3 * 1024 * 1024, 'x')));
|
||||
|
||||
EXPECT_TRUE(profiler_add_marker_impl(
|
||||
EXPECT_TRUE(profiler_add_marker(
|
||||
"MediaSample", geckoprofiler::category::OTHER, {},
|
||||
geckoprofiler::markers::MediaSampleMarker{}, 123, 456, 789));
|
||||
|
||||
|
@ -4947,9 +4947,9 @@ TEST(GeckoProfiler, FailureHandling)
|
|||
return mozilla::MarkerSchema::SpecialFrontendLocation{};
|
||||
}
|
||||
};
|
||||
EXPECT_TRUE(profiler_add_marker_impl("Gtest failing marker",
|
||||
geckoprofiler::category::OTHER, {},
|
||||
GtestFailingMarker{}));
|
||||
EXPECT_TRUE(profiler_add_marker("Gtest failing marker",
|
||||
geckoprofiler::category::OTHER, {},
|
||||
GtestFailingMarker{}));
|
||||
|
||||
ASSERT_EQ(WaitForSamplingState(), SamplingState::SamplingCompleted);
|
||||
profiler_pause();
|
||||
|
@ -5022,7 +5022,7 @@ TEST(GeckoProfiler, NoMarkerStacks)
|
|||
ASSERT_TRUE(!profiler_capture_backtrace());
|
||||
|
||||
// Add a marker with a stack to test.
|
||||
EXPECT_TRUE(profiler_add_marker_impl(
|
||||
EXPECT_TRUE(profiler_add_marker(
|
||||
"Text with stack", geckoprofiler::category::OTHER, MarkerStack::Capture(),
|
||||
geckoprofiler::markers::TextMarker{}, ""));
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче