From b9191bb2ce327251f43c896d50359324f5749900 Mon Sep 17 00:00:00 2001 From: Gerald Squelart Date: Mon, 30 Nov 2020 10:44:13 +0000 Subject: [PATCH] Bug 1646613 - Rename profiler overhead variables to include their true unit - r=canaltinova Differential Revision: https://phabricator.services.mozilla.com/D97993 --- mozglue/baseprofiler/core/ProfileBuffer.cpp | 50 ++++++++++---------- mozglue/baseprofiler/core/ProfileBuffer.h | 32 ++++++------- mozglue/baseprofiler/public/BaseProfiler.h | 24 +++++----- mozglue/tests/TestBaseProfiler.cpp | 32 ++++++------- tools/profiler/core/ProfileBuffer.cpp | 30 ++++++------ tools/profiler/core/ProfileBuffer.h | 16 +++---- tools/profiler/public/GeckoProfiler.h | 12 ++--- tools/profiler/tests/gtest/GeckoProfiler.cpp | 26 +++++----- 8 files changed, 111 insertions(+), 111 deletions(-) diff --git a/mozglue/baseprofiler/core/ProfileBuffer.cpp b/mozglue/baseprofiler/core/ProfileBuffer.cpp index 908ba83b238d..f39244ee9113 100644 --- a/mozglue/baseprofiler/core/ProfileBuffer.cpp +++ b/mozglue/baseprofiler/core/ProfileBuffer.cpp @@ -133,39 +133,39 @@ void ProfileBuffer::CollectOverheadStats(TimeDuration aSamplingTime, TimeDuration aCleaning, TimeDuration aCounters, TimeDuration aThreads) { - double timeNs = aSamplingTime.ToMilliseconds() * 1000.0; - if (mFirstSamplingTimeNs == 0.0) { - mFirstSamplingTimeNs = timeNs; + double timeUs = aSamplingTime.ToMilliseconds() * 1000.0; + if (mFirstSamplingTimeUs == 0.0) { + mFirstSamplingTimeUs = timeUs; } else { // Note that we'll have 1 fewer interval than other numbers (because // we need both ends of an interval to know its duration). The final // difference should be insignificant over the expected many thousands // of iterations. - mIntervalsNs.Count(timeNs - mLastSamplingTimeNs); + mIntervalsUs.Count(timeUs - mLastSamplingTimeUs); } - mLastSamplingTimeNs = timeNs; + mLastSamplingTimeUs = timeUs; // Time to take the lock before sampling. - double lockingNs = aLocking.ToMilliseconds() * 1000.0; + double lockingUs = aLocking.ToMilliseconds() * 1000.0; // Time to discard expired data. - double cleaningNs = aCleaning.ToMilliseconds() * 1000.0; + double cleaningUs = aCleaning.ToMilliseconds() * 1000.0; // Time to gather all counters. - double countersNs = aCounters.ToMilliseconds() * 1000.0; + double countersUs = aCounters.ToMilliseconds() * 1000.0; // Time to sample all threads. - double threadsNs = aThreads.ToMilliseconds() * 1000.0; + double threadsUs = aThreads.ToMilliseconds() * 1000.0; // Add to our gathered stats. - mOverheadsNs.Count(lockingNs + cleaningNs + countersNs + threadsNs); - mLockingsNs.Count(lockingNs); - mCleaningsNs.Count(cleaningNs); - mCountersNs.Count(countersNs); - mThreadsNs.Count(threadsNs); + mOverheadsUs.Count(lockingUs + cleaningUs + countersUs + threadsUs); + mLockingsUs.Count(lockingUs); + mCleaningsUs.Count(cleaningUs); + mCountersUs.Count(countersUs); + mThreadsUs.Count(threadsUs); // Record details in buffer. - AddEntry(ProfileBufferEntry::ProfilerOverheadTime(timeNs)); - AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(lockingNs)); - AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(cleaningNs)); - AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(countersNs)); - AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(threadsNs)); + AddEntry(ProfileBufferEntry::ProfilerOverheadTime(timeUs)); + AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(lockingUs)); + AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(cleaningUs)); + AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(countersUs)); + AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(threadsUs)); } ProfilerBufferInfo ProfileBuffer::GetProfilerBufferInfo() const { @@ -173,12 +173,12 @@ ProfilerBufferInfo ProfileBuffer::GetProfilerBufferInfo() const { BufferRangeEnd(), static_cast(*mEntries.BufferLength() / 8), // 8 bytes per entry. - mIntervalsNs, - mOverheadsNs, - mLockingsNs, - mCleaningsNs, - mCountersNs, - mThreadsNs}; + mIntervalsUs, + mOverheadsUs, + mLockingsUs, + mCleaningsUs, + mCountersUs, + mThreadsUs}; } /* ProfileBufferCollector */ diff --git a/mozglue/baseprofiler/core/ProfileBuffer.h b/mozglue/baseprofiler/core/ProfileBuffer.h index 17f65e27fb2c..cc30b3692067 100644 --- a/mozglue/baseprofiler/core/ProfileBuffer.h +++ b/mozglue/baseprofiler/core/ProfileBuffer.h @@ -136,22 +136,22 @@ class ProfileBuffer final { ProfileBufferChunk::Create(ProfileBufferChunk::SizeofChunkMetadata() + WorkerBufferBytes.Value())}; - // Time from launch (ns) when first sampling was recorded. - double mFirstSamplingTimeNs = 0.0; - // Time from launch (ns) when last sampling was recorded. - double mLastSamplingTimeNs = 0.0; - // Sampling stats: Interval (ns) between successive samplings. - ProfilerStats mIntervalsNs; - // Sampling stats: Total duration (ns) of each sampling. (Split detail below.) - ProfilerStats mOverheadsNs; - // Sampling stats: Time (ns) to acquire the lock before sampling. - ProfilerStats mLockingsNs; - // Sampling stats: Time (ns) to discard expired data. - ProfilerStats mCleaningsNs; - // Sampling stats: Time (ns) to collect counter data. - ProfilerStats mCountersNs; - // Sampling stats: Time (ns) to sample thread stacks. - ProfilerStats mThreadsNs; + // Time from launch (us) when first sampling was recorded. + double mFirstSamplingTimeUs = 0.0; + // Time from launch (us) when last sampling was recorded. + double mLastSamplingTimeUs = 0.0; + // Sampling stats: Interval (us) between successive samplings. + ProfilerStats mIntervalsUs; + // Sampling stats: Total duration (us) of each sampling. (Split detail below.) + ProfilerStats mOverheadsUs; + // Sampling stats: Time (us) to acquire the lock before sampling. + ProfilerStats mLockingsUs; + // Sampling stats: Time (us) to discard expired data. + ProfilerStats mCleaningsUs; + // Sampling stats: Time (us) to collect counter data. + ProfilerStats mCountersUs; + // Sampling stats: Time (us) to sample thread stacks. + ProfilerStats mThreadsUs; }; /** diff --git a/mozglue/baseprofiler/public/BaseProfiler.h b/mozglue/baseprofiler/public/BaseProfiler.h index 47c976187927..d848f16e82b2 100644 --- a/mozglue/baseprofiler/public/BaseProfiler.h +++ b/mozglue/baseprofiler/public/BaseProfiler.h @@ -591,18 +591,18 @@ struct ProfilerBufferInfo { uint64_t mRangeEnd; // Buffer capacity in number of 8-byte entries. uint32_t mEntryCount; - // Sampling stats: Interval (ns) between successive samplings. - ProfilerStats mIntervalsNs; - // Sampling stats: Total duration (ns) of each sampling. (Split detail below.) - ProfilerStats mOverheadsNs; - // Sampling stats: Time (ns) to acquire the lock before sampling. - ProfilerStats mLockingsNs; - // Sampling stats: Time (ns) to discard expired data. - ProfilerStats mCleaningsNs; - // Sampling stats: Time (ns) to collect counter data. - ProfilerStats mCountersNs; - // Sampling stats: Time (ns) to sample thread stacks. - ProfilerStats mThreadsNs; + // Sampling stats: Interval (us) between successive samplings. + ProfilerStats mIntervalsUs; + // Sampling stats: Total duration (us) of each sampling. (Split detail below.) + ProfilerStats mOverheadsUs; + // Sampling stats: Time (us) to acquire the lock before sampling. + ProfilerStats mLockingsUs; + // Sampling stats: Time (us) to discard expired data. + ProfilerStats mCleaningsUs; + // Sampling stats: Time (us) to collect counter data. + ProfilerStats mCountersUs; + // Sampling stats: Time (us) to sample thread stacks. + ProfilerStats mThreadsUs; }; // Get information about the current buffer status. diff --git a/mozglue/tests/TestBaseProfiler.cpp b/mozglue/tests/TestBaseProfiler.cpp index 495b4d68cc7e..abc9b59d1572 100644 --- a/mozglue/tests/TestBaseProfiler.cpp +++ b/mozglue/tests/TestBaseProfiler.cpp @@ -3497,28 +3497,28 @@ void TestProfiler() { (static_cast(info->mRangeEnd) - static_cast(info->mRangeStart)) * 9); - printf("Stats: min(ns) .. mean(ns) .. max(ns) [count]\n"); + printf("Stats: min(us) .. mean(us) .. max(us) [count]\n"); printf("- Intervals: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mIntervalsNs.min, - info->mIntervalsNs.sum / info->mIntervalsNs.n, - info->mIntervalsNs.max, info->mIntervalsNs.n); + info->mIntervalsUs.min, + info->mIntervalsUs.sum / info->mIntervalsUs.n, + info->mIntervalsUs.max, info->mIntervalsUs.n); printf("- Overheads: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mOverheadsNs.min, - info->mOverheadsNs.sum / info->mOverheadsNs.n, - info->mOverheadsNs.max, info->mOverheadsNs.n); + info->mOverheadsUs.min, + info->mOverheadsUs.sum / info->mOverheadsUs.n, + info->mOverheadsUs.max, info->mOverheadsUs.n); printf(" - Locking: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mLockingsNs.min, info->mLockingsNs.sum / info->mLockingsNs.n, - info->mLockingsNs.max, info->mLockingsNs.n); + info->mLockingsUs.min, info->mLockingsUs.sum / info->mLockingsUs.n, + info->mLockingsUs.max, info->mLockingsUs.n); printf(" - Clearning: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mCleaningsNs.min, - info->mCleaningsNs.sum / info->mCleaningsNs.n, - info->mCleaningsNs.max, info->mCleaningsNs.n); + info->mCleaningsUs.min, + info->mCleaningsUs.sum / info->mCleaningsUs.n, + info->mCleaningsUs.max, info->mCleaningsUs.n); printf(" - Counters: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mCountersNs.min, info->mCountersNs.sum / info->mCountersNs.n, - info->mCountersNs.max, info->mCountersNs.n); + info->mCountersUs.min, info->mCountersUs.sum / info->mCountersUs.n, + info->mCountersUs.max, info->mCountersUs.n); printf(" - Threads: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mThreadsNs.min, info->mThreadsNs.sum / info->mThreadsNs.n, - info->mThreadsNs.max, info->mThreadsNs.n); + info->mThreadsUs.min, info->mThreadsUs.sum / info->mThreadsUs.n, + info->mThreadsUs.max, info->mThreadsUs.n); printf("baseprofiler_get_profile()...\n"); UniquePtr profile = baseprofiler::profiler_get_profile(); diff --git a/tools/profiler/core/ProfileBuffer.cpp b/tools/profiler/core/ProfileBuffer.cpp index 65e3335b1efe..3e391c0074bb 100644 --- a/tools/profiler/core/ProfileBuffer.cpp +++ b/tools/profiler/core/ProfileBuffer.cpp @@ -135,26 +135,26 @@ void ProfileBuffer::CollectOverheadStats(TimeDuration aSamplingTime, TimeDuration aCounters, TimeDuration aThreads) { double time = aSamplingTime.ToMilliseconds() * 1000.0; - if (mFirstSamplingTimeNs == 0.0) { - mFirstSamplingTimeNs = time; + if (mFirstSamplingTimeUs == 0.0) { + mFirstSamplingTimeUs = time; } else { // Note that we'll have 1 fewer interval than other numbers (because // we need both ends of an interval to know its duration). The final // difference should be insignificant over the expected many thousands // of iterations. - mIntervalsNs.Count(time - mLastSamplingTimeNs); + mIntervalsUs.Count(time - mLastSamplingTimeUs); } - mLastSamplingTimeNs = time; + mLastSamplingTimeUs = time; double locking = aLocking.ToMilliseconds() * 1000.0; double cleaning = aCleaning.ToMilliseconds() * 1000.0; double counters = aCounters.ToMilliseconds() * 1000.0; double threads = aThreads.ToMilliseconds() * 1000.0; - mOverheadsNs.Count(locking + cleaning + counters + threads); - mLockingsNs.Count(locking); - mCleaningsNs.Count(cleaning); - mCountersNs.Count(counters); - mThreadsNs.Count(threads); + mOverheadsUs.Count(locking + cleaning + counters + threads); + mLockingsUs.Count(locking); + mCleaningsUs.Count(cleaning); + mCountersUs.Count(counters); + mThreadsUs.Count(threads); AddEntry(ProfileBufferEntry::ProfilerOverheadTime(time)); AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(locking)); @@ -168,12 +168,12 @@ ProfilerBufferInfo ProfileBuffer::GetProfilerBufferInfo() const { BufferRangeEnd(), static_cast(*mEntries.BufferLength() / 8), // 8 bytes per entry. - mIntervalsNs, - mOverheadsNs, - mLockingsNs, - mCleaningsNs, - mCountersNs, - mThreadsNs}; + mIntervalsUs, + mOverheadsUs, + mLockingsUs, + mCleaningsUs, + mCountersUs, + mThreadsUs}; } /* ProfileBufferCollector */ diff --git a/tools/profiler/core/ProfileBuffer.h b/tools/profiler/core/ProfileBuffer.h index cdfc3423da95..a6fa79add61b 100644 --- a/tools/profiler/core/ProfileBuffer.h +++ b/tools/profiler/core/ProfileBuffer.h @@ -173,14 +173,14 @@ class ProfileBuffer final { mozilla::ProfileBufferChunk::SizeofChunkMetadata() + WorkerBufferBytes.Value())}; - double mFirstSamplingTimeNs = 0.0; - double mLastSamplingTimeNs = 0.0; - ProfilerStats mIntervalsNs; - ProfilerStats mOverheadsNs; - ProfilerStats mLockingsNs; - ProfilerStats mCleaningsNs; - ProfilerStats mCountersNs; - ProfilerStats mThreadsNs; + double mFirstSamplingTimeUs = 0.0; + double mLastSamplingTimeUs = 0.0; + ProfilerStats mIntervalsUs; + ProfilerStats mOverheadsUs; + ProfilerStats mLockingsUs; + ProfilerStats mCleaningsUs; + ProfilerStats mCountersUs; + ProfilerStats mThreadsUs; }; /** diff --git a/tools/profiler/public/GeckoProfiler.h b/tools/profiler/public/GeckoProfiler.h index 1fe85147ee88..8fe0bafbc3f0 100644 --- a/tools/profiler/public/GeckoProfiler.h +++ b/tools/profiler/public/GeckoProfiler.h @@ -732,17 +732,17 @@ struct ProfilerBufferInfo { // Buffer capacity in number of 8-byte entries. uint32_t mEntryCount; // Sampling stats: Interval between successive samplings. - ProfilerStats mIntervalsNs; + ProfilerStats mIntervalsUs; // Sampling stats: Total sampling duration. (Split detail below.) - ProfilerStats mOverheadsNs; + ProfilerStats mOverheadsUs; // Sampling stats: Time to acquire the lock before sampling. - ProfilerStats mLockingsNs; + ProfilerStats mLockingsUs; // Sampling stats: Time to discard expired data. - ProfilerStats mCleaningsNs; + ProfilerStats mCleaningsUs; // Sampling stats: Time to collect counter data. - ProfilerStats mCountersNs; + ProfilerStats mCountersUs; // Sampling stats: Time to sample thread stacks. - ProfilerStats mThreadsNs; + ProfilerStats mThreadsUs; }; // Get information about the current buffer status. diff --git a/tools/profiler/tests/gtest/GeckoProfiler.cpp b/tools/profiler/tests/gtest/GeckoProfiler.cpp index 0cab194b3904..cc84d4b80c71 100644 --- a/tools/profiler/tests/gtest/GeckoProfiler.cpp +++ b/tools/profiler/tests/gtest/GeckoProfiler.cpp @@ -1591,25 +1591,25 @@ TEST(GeckoProfiler, Markers) (static_cast(info->mRangeEnd) - static_cast(info->mRangeStart)) * 9); - printf("Stats: min(ns) .. mean(ns) .. max(ns) [count]\n"); + printf("Stats: min(us) .. mean(us) .. max(us) [count]\n"); printf("- Intervals: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mIntervalsNs.min, info->mIntervalsNs.sum / info->mIntervalsNs.n, - info->mIntervalsNs.max, info->mIntervalsNs.n); + info->mIntervalsUs.min, info->mIntervalsUs.sum / info->mIntervalsUs.n, + info->mIntervalsUs.max, info->mIntervalsUs.n); printf("- Overheads: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mOverheadsNs.min, info->mOverheadsNs.sum / info->mOverheadsNs.n, - info->mOverheadsNs.max, info->mOverheadsNs.n); + info->mOverheadsUs.min, info->mOverheadsUs.sum / info->mOverheadsUs.n, + info->mOverheadsUs.max, info->mOverheadsUs.n); printf(" - Locking: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mLockingsNs.min, info->mLockingsNs.sum / info->mLockingsNs.n, - info->mLockingsNs.max, info->mLockingsNs.n); + info->mLockingsUs.min, info->mLockingsUs.sum / info->mLockingsUs.n, + info->mLockingsUs.max, info->mLockingsUs.n); printf(" - Clearning: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mCleaningsNs.min, info->mCleaningsNs.sum / info->mCleaningsNs.n, - info->mCleaningsNs.max, info->mCleaningsNs.n); + info->mCleaningsUs.min, info->mCleaningsUs.sum / info->mCleaningsUs.n, + info->mCleaningsUs.max, info->mCleaningsUs.n); printf(" - Counters: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mCountersNs.min, info->mCountersNs.sum / info->mCountersNs.n, - info->mCountersNs.max, info->mCountersNs.n); + info->mCountersUs.min, info->mCountersUs.sum / info->mCountersUs.n, + info->mCountersUs.max, info->mCountersUs.n); printf(" - Threads: %7.1f .. %7.1f .. %7.1f [%u]\n", - info->mThreadsNs.min, info->mThreadsNs.sum / info->mThreadsNs.n, - info->mThreadsNs.max, info->mThreadsNs.n); + info->mThreadsUs.min, info->mThreadsUs.sum / info->mThreadsUs.n, + info->mThreadsUs.max, info->mThreadsUs.n); profiler_stop();