mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1578327 - Discard old data just before streaming - r=gregtatum
Since all profiler data is now stored inside ProfileBuffer, there is no real need to continuously discard old data during sampling (this was particularly useful to reclaim memory taken by old markers&payloads). Instead, we can now just discard the old data once, just before starting to stream it to JSON. Differential Revision: https://phabricator.services.mozilla.com/D44433 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
79e1b2e357
commit
7d435fc17a
@ -1622,10 +1622,17 @@ static void locked_profiler_stream_json_for_this_process(
|
|||||||
|
|
||||||
AUTO_PROFILER_STATS(base_locked_profiler_stream_json_for_this_process);
|
AUTO_PROFILER_STATS(base_locked_profiler_stream_json_for_this_process);
|
||||||
|
|
||||||
double collectionStart = profiler_time();
|
const double collectionStartMs = profiler_time();
|
||||||
|
|
||||||
ProfileBuffer& buffer = ActivePS::Buffer(aLock);
|
ProfileBuffer& buffer = ActivePS::Buffer(aLock);
|
||||||
|
|
||||||
|
// If there is a set "Window length", discard older data.
|
||||||
|
Maybe<double> durationS = ActivePS::Duration(aLock);
|
||||||
|
if (durationS.isSome()) {
|
||||||
|
const double durationStartMs = collectionStartMs - *durationS * 1000;
|
||||||
|
buffer.DiscardSamplesBeforeTime(durationStartMs);
|
||||||
|
}
|
||||||
|
|
||||||
if (!aOnlyThreads) {
|
if (!aOnlyThreads) {
|
||||||
// Put shared library info
|
// Put shared library info
|
||||||
aWriter.StartArrayProperty("libs");
|
aWriter.StartArrayProperty("libs");
|
||||||
@ -1672,15 +1679,15 @@ static void locked_profiler_stream_json_for_this_process(
|
|||||||
aWriter.EndArray();
|
aWriter.EndArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
double collectionEnd = profiler_time();
|
const double collectionEndMs = profiler_time();
|
||||||
|
|
||||||
// Record timestamps for the collection into the buffer, so that consumers
|
// Record timestamps for the collection into the buffer, so that consumers
|
||||||
// know why we didn't collect any samples for its duration.
|
// know why we didn't collect any samples for its duration.
|
||||||
// We put these entries into the buffer after we've collected the profile,
|
// We put these entries into the buffer after we've collected the profile,
|
||||||
// so they'll be visible for the *next* profile collection (if they haven't
|
// so they'll be visible for the *next* profile collection (if they haven't
|
||||||
// been overwritten due to buffer wraparound by then).
|
// been overwritten due to buffer wraparound by then).
|
||||||
buffer.AddEntry(ProfileBufferEntry::CollectionStart(collectionStart));
|
buffer.AddEntry(ProfileBufferEntry::CollectionStart(collectionStartMs));
|
||||||
buffer.AddEntry(ProfileBufferEntry::CollectionEnd(collectionEnd));
|
buffer.AddEntry(ProfileBufferEntry::CollectionEnd(collectionEndMs));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool profiler_stream_json_for_this_process(SpliceableJSONWriter& aWriter,
|
bool profiler_stream_json_for_this_process(SpliceableJSONWriter& aWriter,
|
||||||
@ -2093,14 +2100,6 @@ void SamplerThread::Run() {
|
|||||||
countersSampled - expiredMarkersCleaned,
|
countersSampled - expiredMarkersCleaned,
|
||||||
threadsSampled - countersSampled);
|
threadsSampled - countersSampled);
|
||||||
}
|
}
|
||||||
|
|
||||||
Maybe<double> duration = ActivePS::Duration(lock);
|
|
||||||
if (duration) {
|
|
||||||
ActivePS::Buffer(lock).DiscardSamplesBeforeTime(
|
|
||||||
(TimeStamp::NowUnfuzzed() - TimeDuration::FromSeconds(*duration) -
|
|
||||||
CorePS::ProcessStartTime())
|
|
||||||
.ToMilliseconds());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// gPSMutex is not held after this point.
|
// gPSMutex is not held after this point.
|
||||||
|
|
||||||
|
@ -2126,10 +2126,17 @@ static void locked_profiler_stream_json_for_this_process(
|
|||||||
|
|
||||||
AUTO_PROFILER_STATS(locked_profiler_stream_json_for_this_process);
|
AUTO_PROFILER_STATS(locked_profiler_stream_json_for_this_process);
|
||||||
|
|
||||||
double collectionStart = profiler_time();
|
const double collectionStartMs = profiler_time();
|
||||||
|
|
||||||
ProfileBuffer& buffer = ActivePS::Buffer(aLock);
|
ProfileBuffer& buffer = ActivePS::Buffer(aLock);
|
||||||
|
|
||||||
|
// If there is a set "Window length", discard older data.
|
||||||
|
Maybe<double> durationS = ActivePS::Duration(aLock);
|
||||||
|
if (durationS.isSome()) {
|
||||||
|
const double durationStartMs = collectionStartMs - *durationS * 1000;
|
||||||
|
buffer.DiscardSamplesBeforeTime(durationStartMs);
|
||||||
|
}
|
||||||
|
|
||||||
// Put shared library info
|
// Put shared library info
|
||||||
aWriter.StartArrayProperty("libs");
|
aWriter.StartArrayProperty("libs");
|
||||||
AppendSharedLibraries(aWriter);
|
AppendSharedLibraries(aWriter);
|
||||||
@ -2224,15 +2231,15 @@ static void locked_profiler_stream_json_for_this_process(
|
|||||||
{ buffer.StreamPausedRangesToJSON(aWriter, aSinceTime); }
|
{ buffer.StreamPausedRangesToJSON(aWriter, aSinceTime); }
|
||||||
aWriter.EndArray();
|
aWriter.EndArray();
|
||||||
|
|
||||||
double collectionEnd = profiler_time();
|
const double collectionEndMs = profiler_time();
|
||||||
|
|
||||||
// Record timestamps for the collection into the buffer, so that consumers
|
// Record timestamps for the collection into the buffer, so that consumers
|
||||||
// know why we didn't collect any samples for its duration.
|
// know why we didn't collect any samples for its duration.
|
||||||
// We put these entries into the buffer after we've collected the profile,
|
// We put these entries into the buffer after we've collected the profile,
|
||||||
// so they'll be visible for the *next* profile collection (if they haven't
|
// so they'll be visible for the *next* profile collection (if they haven't
|
||||||
// been overwritten due to buffer wraparound by then).
|
// been overwritten due to buffer wraparound by then).
|
||||||
buffer.AddEntry(ProfileBufferEntry::CollectionStart(collectionStart));
|
buffer.AddEntry(ProfileBufferEntry::CollectionStart(collectionStartMs));
|
||||||
buffer.AddEntry(ProfileBufferEntry::CollectionEnd(collectionEnd));
|
buffer.AddEntry(ProfileBufferEntry::CollectionEnd(collectionEndMs));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool profiler_stream_json_for_this_process(
|
bool profiler_stream_json_for_this_process(
|
||||||
@ -2659,14 +2666,6 @@ void SamplerThread::Run() {
|
|||||||
countersSampled - expiredMarkersCleaned,
|
countersSampled - expiredMarkersCleaned,
|
||||||
threadsSampled - countersSampled);
|
threadsSampled - countersSampled);
|
||||||
}
|
}
|
||||||
|
|
||||||
Maybe<double> duration = ActivePS::Duration(lock);
|
|
||||||
if (duration) {
|
|
||||||
ActivePS::Buffer(lock).DiscardSamplesBeforeTime(
|
|
||||||
(TimeStamp::NowUnfuzzed() - TimeDuration::FromSeconds(*duration) -
|
|
||||||
CorePS::ProcessStartTime())
|
|
||||||
.ToMilliseconds());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// gPSMutex is not held after this point.
|
// gPSMutex is not held after this point.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user