Bug 1646613 - Rename profiler overhead variables to include their true unit - r=canaltinova

Differential Revision: https://phabricator.services.mozilla.com/D97993
This commit is contained in:
Gerald Squelart 2020-11-30 10:44:13 +00:00
Родитель 234f97f9c5
Коммит b9191bb2ce
8 изменённых файлов: 111 добавлений и 111 удалений

Просмотреть файл

@ -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<uint32_t>(*mEntries.BufferLength() /
8), // 8 bytes per entry.
mIntervalsNs,
mOverheadsNs,
mLockingsNs,
mCleaningsNs,
mCountersNs,
mThreadsNs};
mIntervalsUs,
mOverheadsUs,
mLockingsUs,
mCleaningsUs,
mCountersUs,
mThreadsUs};
}
/* ProfileBufferCollector */

Просмотреть файл

@ -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;
};
/**

Просмотреть файл

@ -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.

Просмотреть файл

@ -3497,28 +3497,28 @@ void TestProfiler() {
(static_cast<unsigned long long>(info->mRangeEnd) -
static_cast<unsigned long long>(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<char[]> profile = baseprofiler::profiler_get_profile();

Просмотреть файл

@ -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<uint32_t>(*mEntries.BufferLength() /
8), // 8 bytes per entry.
mIntervalsNs,
mOverheadsNs,
mLockingsNs,
mCleaningsNs,
mCountersNs,
mThreadsNs};
mIntervalsUs,
mOverheadsUs,
mLockingsUs,
mCleaningsUs,
mCountersUs,
mThreadsUs};
}
/* ProfileBufferCollector */

Просмотреть файл

@ -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;
};
/**

Просмотреть файл

@ -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.

Просмотреть файл

@ -1591,25 +1591,25 @@ TEST(GeckoProfiler, Markers)
(static_cast<unsigned long long>(info->mRangeEnd) -
static_cast<unsigned long long>(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();