Bug 1630872 - Removed 'BlocksRingBuffer' from some Base Profiler platform variables - r=canaltinova

Renamed some variables to be more generic. Their type is going to change in the next patch, and that type doesn't need to be in the names; also it will make the next patch easier to review.

Differential Revision: https://phabricator.services.mozilla.com/D71882
This commit is contained in:
Gerald Squelart 2020-04-24 06:21:10 +00:00
Родитель d83022dc79
Коммит c00a525a32
1 изменённых файлов: 20 добавлений и 23 удалений

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

@ -284,7 +284,7 @@ class CorePS {
// functions guarded by gPSMutex as well as others without safety (e.g., // functions guarded by gPSMutex as well as others without safety (e.g.,
// profiler_add_marker). It is *not* used inside the critical section of // profiler_add_marker). It is *not* used inside the critical section of
// the sampler, because mutexes cannot be used there. // the sampler, because mutexes cannot be used there.
mCoreBlocksRingBuffer(BlocksRingBuffer::ThreadSafety::WithMutex) mCoreBuffer(BlocksRingBuffer::ThreadSafety::WithMutex)
# ifdef USE_LUL_STACKWALK # ifdef USE_LUL_STACKWALK
, ,
mLul(nullptr) mLul(nullptr)
@ -349,7 +349,7 @@ class CorePS {
PS_GET_LOCKLESS(TimeStamp, ProcessStartTime) PS_GET_LOCKLESS(TimeStamp, ProcessStartTime)
// No PSLockRef is needed for this field because it's thread-safe. // No PSLockRef is needed for this field because it's thread-safe.
PS_GET_LOCKLESS(BlocksRingBuffer&, CoreBlocksRingBuffer) PS_GET_LOCKLESS(BlocksRingBuffer&, CoreBuffer)
PS_GET(const Vector<UniquePtr<RegisteredThread>>&, RegisteredThreads) PS_GET(const Vector<UniquePtr<RegisteredThread>>&, RegisteredThreads)
@ -458,16 +458,16 @@ class CorePS {
// The time that the process started. // The time that the process started.
const TimeStamp mProcessStartTime; const TimeStamp mProcessStartTime;
// The thread-safe blocks-oriented ring buffer into which all profiling data // The thread-safe blocks-oriented buffer into which all profiling data is
// is recorded. // recorded.
// ActivePS controls the lifetime of the underlying contents buffer: When // ActivePS controls the lifetime of the underlying contents buffer: When
// ActivePS does not exist, mCoreBlocksRingBuffer is empty and rejects all // ActivePS does not exist, mCoreBuffer is empty and rejects all reads&writes;
// reads&writes; see ActivePS for further details. // see ActivePS for further details.
// Note: This needs to live here outside of ActivePS, because some producers // Note: This needs to live here outside of ActivePS, because some producers
// are indirectly controlled (e.g., by atomic flags) and therefore may still // are indirectly controlled (e.g., by atomic flags) and therefore may still
// attempt to write some data shortly after ActivePS has shutdown and deleted // attempt to write some data shortly after ActivePS has shutdown and deleted
// the underlying buffer in memory. // the underlying buffer in memory.
BlocksRingBuffer mCoreBlocksRingBuffer; BlocksRingBuffer mCoreBuffer;
// Info on all the registered threads. // Info on all the registered threads.
// ThreadIds in mRegisteredThreads are unique. // ThreadIds in mRegisteredThreads are unique.
@ -532,7 +532,7 @@ class ActivePS {
mInterval(aInterval), mInterval(aInterval),
mFeatures(AdjustFeatures(aFeatures, aFilterCount)), mFeatures(AdjustFeatures(aFeatures, aFilterCount)),
// 8 bytes per entry. // 8 bytes per entry.
mProfileBuffer(CorePS::CoreBlocksRingBuffer(), mProfileBuffer(CorePS::CoreBuffer(),
PowerOfTwo32(aCapacity.Value() * 8)), PowerOfTwo32(aCapacity.Value() * 8)),
// The new sampler thread doesn't start sampling immediately because the // The new sampler thread doesn't start sampling immediately because the
// main loop within Run() is blocked until this function's caller // main loop within Run() is blocked until this function's caller
@ -2046,16 +2046,14 @@ void SamplerThread::Run() {
}(); }();
// Use local BlocksRingBuffer&ProfileBuffer to capture the stack. // Use local BlocksRingBuffer&ProfileBuffer to capture the stack.
// (This is to avoid touching the CorePS::BlocksRingBuffer lock while // (This is to avoid touching the CorePS::CoreBuffer lock while
// a thread is suspended, because that thread could be working with // a thread is suspended, because that thread could be working with
// the CorePS::BlocksRingBuffer as well.) // the CorePS::CoreBuffer as well.)
BlocksRingBuffer localBlocksRingBuffer( BlocksRingBuffer localBuffer(BlocksRingBuffer::ThreadSafety::WithoutMutex);
BlocksRingBuffer::ThreadSafety::WithoutMutex); ProfileBuffer localProfileBuffer(localBuffer, MakePowerOfTwo32<65536>());
ProfileBuffer localProfileBuffer(localBlocksRingBuffer,
MakePowerOfTwo32<65536>());
// Will be kept between collections, to know what each collection does. // Will be kept between collections, to know what each collection does.
auto previousState = localBlocksRingBuffer.GetState(); auto previousState = localBuffer.GetState();
// This will be positive if we are running behind schedule (sampling less // This will be positive if we are running behind schedule (sampling less
// frequently than desired) and negative if we are ahead of schedule. // frequently than desired) and negative if we are ahead of schedule.
@ -2155,7 +2153,7 @@ void SamplerThread::Run() {
}); });
// If data is complete, copy it into the global buffer. // If data is complete, copy it into the global buffer.
auto state = localBlocksRingBuffer.GetState(); auto state = localBuffer.GetState();
if (state.mClearedBlockCount != previousState.mClearedBlockCount) { if (state.mClearedBlockCount != previousState.mClearedBlockCount) {
LOG("Stack sample too big for local storage, needed %u bytes", LOG("Stack sample too big for local storage, needed %u bytes",
unsigned( unsigned(
@ -2164,19 +2162,18 @@ void SamplerThread::Run() {
} else if (state.mRangeEnd.ConvertToProfileBufferIndex() - } else if (state.mRangeEnd.ConvertToProfileBufferIndex() -
previousState.mRangeEnd previousState.mRangeEnd
.ConvertToProfileBufferIndex() >= .ConvertToProfileBufferIndex() >=
CorePS::CoreBlocksRingBuffer().BufferLength()->Value()) { CorePS::CoreBuffer().BufferLength()->Value()) {
LOG("Stack sample too big for profiler storage, needed %u bytes", LOG("Stack sample too big for profiler storage, needed %u bytes",
unsigned( unsigned(
state.mRangeEnd.ConvertToProfileBufferIndex() - state.mRangeEnd.ConvertToProfileBufferIndex() -
previousState.mRangeEnd.ConvertToProfileBufferIndex())); previousState.mRangeEnd.ConvertToProfileBufferIndex()));
} else { } else {
CorePS::CoreBlocksRingBuffer().AppendContents( CorePS::CoreBuffer().AppendContents(localBuffer);
localBlocksRingBuffer);
} }
// Clean up for the next run. // Clean up for the next run.
localBlocksRingBuffer.Clear(); localBuffer.Clear();
previousState = localBlocksRingBuffer.GetState(); previousState = localBuffer.GetState();
} }
} }
@ -3313,7 +3310,7 @@ static void racy_profiler_add_marker(const char* aMarkerName,
? aPayload->GetStartTime() ? aPayload->GetStartTime()
: TimeStamp::NowUnfuzzed(); : TimeStamp::NowUnfuzzed();
TimeDuration delta = origin - CorePS::ProcessStartTime(); TimeDuration delta = origin - CorePS::ProcessStartTime();
CorePS::CoreBlocksRingBuffer().PutObjects( CorePS::CoreBuffer().PutObjects(
ProfileBufferEntry::Kind::MarkerData, racyRegisteredThread->ThreadId(), ProfileBufferEntry::Kind::MarkerData, racyRegisteredThread->ThreadId(),
WrapProfileBufferUnownedCString(aMarkerName), WrapProfileBufferUnownedCString(aMarkerName),
static_cast<uint32_t>(aCategoryPair), aPayload, delta.ToMilliseconds()); static_cast<uint32_t>(aCategoryPair), aPayload, delta.ToMilliseconds());
@ -3376,7 +3373,7 @@ void profiler_add_marker_for_thread(int aThreadId,
? aPayload->GetStartTime() ? aPayload->GetStartTime()
: TimeStamp::NowUnfuzzed(); : TimeStamp::NowUnfuzzed();
TimeDuration delta = origin - CorePS::ProcessStartTime(); TimeDuration delta = origin - CorePS::ProcessStartTime();
CorePS::CoreBlocksRingBuffer().PutObjects( CorePS::CoreBuffer().PutObjects(
ProfileBufferEntry::Kind::MarkerData, aThreadId, ProfileBufferEntry::Kind::MarkerData, aThreadId,
WrapProfileBufferUnownedCString(aMarkerName), WrapProfileBufferUnownedCString(aMarkerName),
static_cast<uint32_t>(aCategoryPair), aPayload, delta.ToMilliseconds()); static_cast<uint32_t>(aCategoryPair), aPayload, delta.ToMilliseconds());