Bug 1691092 - add PROFILER category to make profiler overhead very visible, r=gerald.

Differential Revision: https://phabricator.services.mozilla.com/D104242
This commit is contained in:
Florian Quèze 2021-02-16 19:04:02 +00:00
parent 31380bc0c1
commit 7f356c706e
8 changed files with 16 additions and 0 deletions

View File

@ -3600,6 +3600,8 @@ bool profiler_capture_backtrace_into(ProfileChunkedBuffer& aChunkedBuffer,
UniquePtr<ProfileChunkedBuffer> profiler_capture_backtrace() {
MOZ_RELEASE_ASSERT(CorePS::Exists());
AUTO_BASE_PROFILER_LABEL("baseprofiler::profiler_capture_backtrace",
PROFILER);
// Quick is-active check before allocating a buffer.
if (!profiler_is_active()) {

View File

@ -44,6 +44,7 @@
#else // ndef MOZ_GECKO_PROFILER
# include "mozilla/BaseProfilerLabels.h"
# include "mozilla/TimeStamp.h"
# include "mozilla/Unused.h"
@ -67,6 +68,7 @@ ProfileBufferBlockIndex AddMarkerToBuffer(
const MarkerCategory& aCategory, MarkerOptions&& aOptions,
MarkerType aMarkerType, const PayloadArguments&... aPayloadArguments) {
Unused << aMarkerType; // Only the empty object type is useful.
AUTO_BASE_PROFILER_LABEL("baseprofiler::AddMarkerToBuffer", PROFILER);
return base_profiler_markers_detail::AddMarkerToBuffer<MarkerType>(
aBuffer, aName, aCategory, std::move(aOptions),
::mozilla::baseprofiler::profiler_capture_backtrace_into,

View File

@ -115,6 +115,9 @@
SUBCATEGORY(MEDIA, MEDIA_CUBEB, "Cubeb") \
SUBCATEGORY(MEDIA, MEDIA_PLAYBACK, "Playback") \
SUBCATEGORY(MEDIA, MEDIA_RT, "Real-time rendering") \
END_CATEGORY \
BEGIN_CATEGORY(PROFILER, "Profiler", "lightred") \
SUBCATEGORY(PROFILER, PROFILER, "Other") \
END_CATEGORY
// clang-format on

View File

@ -367,6 +367,7 @@ static void AllocCallback(void* aPtr, size_t aReqSize) {
// The next part of the function requires allocations, so block the memory
// hooks from recursing on any new allocations coming in.
AutoBlockIntercepts block(threadIntercept.ref());
AUTO_PROFILER_LABEL("AllocCallback", PROFILER);
// Perform a bernoulli trial, which will return true or false based on its
// configured probability. It takes into account the byte size so that
@ -412,6 +413,7 @@ static void FreeCallback(void* aPtr) {
// The next part of the function requires allocations, so block the memory
// hooks from recursing on any new allocations coming in.
AutoBlockIntercepts block(threadIntercept.ref());
AUTO_PROFILER_LABEL("FreeCallback", PROFILER);
// Perform a bernoulli trial, which will return true or false based on its
// configured probability. It takes into account the byte size so that

View File

@ -5511,6 +5511,7 @@ bool profiler_capture_backtrace_into(ProfileChunkedBuffer& aChunkedBuffer,
UniquePtr<ProfileChunkedBuffer> profiler_capture_backtrace() {
MOZ_RELEASE_ASSERT(CorePS::Exists());
AUTO_PROFILER_LABEL("profiler_capture_backtrace", PROFILER);
// Quick is-active check before allocating a buffer.
if (!profiler_is_active()) {

View File

@ -73,6 +73,7 @@ void ProfilerIOInterposeObserver::Observe(Observation& aObservation) {
return;
}
AUTO_PROFILER_LABEL("ProfilerIOInterposeObserver", PROFILER);
const bool doCaptureStack = !(features & ProfilerFeature::NoIOStacks);
if (IsMainThread()) {
// This is the main thread.

View File

@ -659,6 +659,7 @@ class MOZ_RAII AutoProfileRunnable {
return;
}
AUTO_PROFILER_LABEL("AutoProfileRunnable", PROFILER);
AUTO_PROFILER_STATS(AUTO_PROFILE_RUNNABLE);
profiler_add_marker("Runnable", ::mozilla::baseprofiler::category::OTHER,
MarkerTiming::IntervalUntilNowFrom(mStartTime),

View File

@ -47,6 +47,8 @@
#else // ndef MOZ_GECKO_PROFILER
# include "mozilla/ProfilerLabels.h"
// Forward-declaration. TODO: Move to more common header, see bug 1681416.
bool profiler_capture_backtrace_into(
mozilla::ProfileChunkedBuffer& aChunkedBuffer,
@ -68,6 +70,7 @@ mozilla::ProfileBufferBlockIndex AddMarkerToBuffer(
const mozilla::ProfilerString8View& aName,
const mozilla::MarkerCategory& aCategory, mozilla::MarkerOptions&& aOptions,
MarkerType aMarkerType, const PayloadArguments&... aPayloadArguments) {
AUTO_PROFILER_LABEL("AddMarkerToBuffer", PROFILER);
mozilla::Unused << aMarkerType; // Only the empty object type is useful.
return mozilla::base_profiler_markers_detail::AddMarkerToBuffer<MarkerType>(
aBuffer, aName, aCategory, std::move(aOptions),
@ -170,6 +173,7 @@ class MOZ_RAII AutoProfilerTextMarker {
}
~AutoProfilerTextMarker() {
AUTO_PROFILER_LABEL("TextMarker", PROFILER);
mOptions.TimingRef().SetIntervalEnd();
AUTO_PROFILER_STATS(AUTO_PROFILER_MARKER_TEXT);
profiler_add_marker(