Bug 1726657 - Only record sampling overheads if MOZ_PROFILER_RECORD_OVERHEADS is set - r=florian

Sampling overheads are very rarely useful, but they occupy some space during profiling, but also a lot of space in the final JSON profile.
So now they will only be recorded if the environment variable "MOZ_PROFILER_RECORD_OVERHEADS" is set to any non-empty value.

Differential Revision: https://phabricator.services.mozilla.com/D123303
This commit is contained in:
Gerald Squelart 2021-08-23 22:23:34 +00:00
parent 8d7a78b944
commit 1cf3bc392a
2 changed files with 23 additions and 11 deletions

View File

@ -161,12 +161,18 @@ void ProfileBuffer::CollectOverheadStats(TimeDuration aSamplingTime,
mCountersUs.Count(countersUs);
mThreadsUs.Count(threadsUs);
// Record details in buffer.
AddEntry(ProfileBufferEntry::ProfilerOverheadTime(timeUs));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(lockingUs));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(cleaningUs));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(countersUs));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(threadsUs));
// Record details in buffer, if requested.
static const bool sRecordSamplingOverhead = []() {
const char* recordOverheads = getenv("MOZ_PROFILER_RECORD_OVERHEADS");
return recordOverheads && recordOverheads[0] != '\0';
}();
if (sRecordSamplingOverhead) {
AddEntry(ProfileBufferEntry::ProfilerOverheadTime(timeUs));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(lockingUs));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(cleaningUs));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(countersUs));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(threadsUs));
}
}
ProfilerBufferInfo ProfileBuffer::GetProfilerBufferInfo() const {

View File

@ -156,11 +156,17 @@ void ProfileBuffer::CollectOverheadStats(double aSamplingTimeMs,
mCountersUs.Count(counters);
mThreadsUs.Count(threads);
AddEntry(ProfileBufferEntry::ProfilerOverheadTime(aSamplingTimeMs));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(locking));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(cleaning));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(counters));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(threads));
static const bool sRecordSamplingOverhead = []() {
const char* recordOverheads = getenv("MOZ_PROFILER_RECORD_OVERHEADS");
return recordOverheads && recordOverheads[0] != '\0';
}();
if (sRecordSamplingOverhead) {
AddEntry(ProfileBufferEntry::ProfilerOverheadTime(aSamplingTimeMs));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(locking));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(cleaning));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(counters));
AddEntry(ProfileBufferEntry::ProfilerOverheadDuration(threads));
}
}
ProfilerBufferInfo ProfileBuffer::GetProfilerBufferInfo() const {