diff options
author | Ptolemy <ptolemy@lindenlab.com> | 2022-01-13 12:55:53 -0800 |
---|---|---|
committer | Ptolemy <ptolemy@lindenlab.com> | 2022-01-14 11:50:21 -0800 |
commit | b504c692554d492113a10ef45427fe0ab0d8a85d (patch) | |
tree | 742b5ba9642c2290cbd8aac6adabecce2af93b91 /indra | |
parent | bf0643e28ae67c46dd1fa4f01874907a60ab038f (diff) |
SL-16606: Add profiler category THREAD
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcommon/llmutex.cpp | 24 | ||||
-rw-r--r-- | indra/llcommon/llsingleton.h | 2 | ||||
-rw-r--r-- | indra/llcommon/llthread.cpp | 14 | ||||
-rw-r--r-- | indra/llcommon/llthreadsafequeue.h | 36 | ||||
-rw-r--r-- | indra/llcommon/threadsafeschedule.h | 44 | ||||
-rw-r--r-- | indra/llcommon/workqueue.cpp | 8 |
6 files changed, 64 insertions, 64 deletions
diff --git a/indra/llcommon/llmutex.cpp b/indra/llcommon/llmutex.cpp index a49002b5dc..0273dd5970 100644 --- a/indra/llcommon/llmutex.cpp +++ b/indra/llcommon/llmutex.cpp @@ -44,7 +44,7 @@ LLMutex::~LLMutex() void LLMutex::lock() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD if(isSelfLocked()) { //redundant lock mCount++; @@ -66,7 +66,7 @@ void LLMutex::lock() void LLMutex::unlock() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD if (mCount > 0) { //not the root unlock mCount--; @@ -87,7 +87,7 @@ void LLMutex::unlock() bool LLMutex::isLocked() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD if (!mMutex.try_lock()) { return true; @@ -111,7 +111,7 @@ LLThread::id_t LLMutex::lockingThread() const bool LLMutex::trylock() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD if(isSelfLocked()) { //redundant lock mCount++; @@ -150,20 +150,20 @@ LLCondition::~LLCondition() void LLCondition::wait() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD std::unique_lock< std::mutex > lock(mMutex); mCond.wait(lock); } void LLCondition::signal() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD mCond.notify_one(); } void LLCondition::broadcast() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD mCond.notify_all(); } @@ -173,7 +173,7 @@ LLMutexTrylock::LLMutexTrylock(LLMutex* mutex) : mMutex(mutex), mLocked(false) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD if (mMutex) mLocked = mMutex->trylock(); } @@ -182,7 +182,7 @@ LLMutexTrylock::LLMutexTrylock(LLMutex* mutex, U32 aTries, U32 delay_ms) : mMutex(mutex), mLocked(false) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD if (!mMutex) return; @@ -197,7 +197,7 @@ LLMutexTrylock::LLMutexTrylock(LLMutex* mutex, U32 aTries, U32 delay_ms) LLMutexTrylock::~LLMutexTrylock() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD if (mMutex && mLocked) mMutex->unlock(); } @@ -209,7 +209,7 @@ LLMutexTrylock::~LLMutexTrylock() // LLScopedLock::LLScopedLock(std::mutex* mutex) : mMutex(mutex) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD if(mutex) { mutex->lock(); @@ -228,7 +228,7 @@ LLScopedLock::~LLScopedLock() void LLScopedLock::unlock() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD if(mLocked) { mMutex->unlock(); diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 6042c0906c..51ef514cf7 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -455,7 +455,7 @@ public: static DERIVED_TYPE* getInstance() { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; // We know the viewer has LLSingleton dependency circularities. If you // feel strongly motivated to eliminate them, cheers and good luck. // (At that point we could consider a much simpler locking mechanism.) diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 11f5a015f1..a807acc56e 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -333,7 +333,7 @@ bool LLThread::runCondition(void) // Stop thread execution if requested until unpaused. void LLThread::checkPause() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD mDataLock->lock(); // This is in a while loop because the pthread API allows for spurious wakeups. @@ -365,20 +365,20 @@ void LLThread::setQuitting() // static LLThread::id_t LLThread::currentID() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD return std::this_thread::get_id(); } // static void LLThread::yield() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD std::this_thread::yield(); } void LLThread::wake() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD mDataLock->lock(); if(!shouldSleep()) { @@ -389,7 +389,7 @@ void LLThread::wake() void LLThread::wakeLocked() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD if(!shouldSleep()) { mRunCondition->signal(); @@ -398,13 +398,13 @@ void LLThread::wakeLocked() void LLThread::lockData() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD mDataLock->lock(); } void LLThread::unlockData() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD mDataLock->unlock(); } diff --git a/indra/llcommon/llthreadsafequeue.h b/indra/llcommon/llthreadsafequeue.h index 2806506550..68d79cdd12 100644 --- a/indra/llcommon/llthreadsafequeue.h +++ b/indra/llcommon/llthreadsafequeue.h @@ -275,7 +275,7 @@ template <typename ElementT, typename QueueT> template <typename CALLABLE> bool LLThreadSafeQueue<ElementT, QueueT>::tryLock(CALLABLE&& callable) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; lock_t lock1(mLock, std::defer_lock); if (!lock1.try_lock()) return false; @@ -292,7 +292,7 @@ bool LLThreadSafeQueue<ElementT, QueueT>::tryLockUntil( const std::chrono::time_point<Clock, Duration>& until, CALLABLE&& callable) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; lock_t lock1(mLock, std::defer_lock); if (!lock1.try_lock_until(until)) return false; @@ -306,7 +306,7 @@ template <typename ElementT, typename QueueT> template <typename T> bool LLThreadSafeQueue<ElementT, QueueT>::push_(lock_t& lock, T&& element) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; if (mStorage.size() >= mCapacity) return false; @@ -322,7 +322,7 @@ template <typename ElementT, typename QueueT> template <typename T> bool LLThreadSafeQueue<ElementT, QueueT>::pushIfOpen(T&& element) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; lock_t lock1(mLock); while (true) { @@ -345,7 +345,7 @@ template <typename ElementT, typename QueueT> template<typename T> void LLThreadSafeQueue<ElementT, QueueT>::push(T&& element) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; if (! pushIfOpen(std::forward<T>(element))) { LLTHROW(LLThreadSafeQueueInterrupt()); @@ -357,7 +357,7 @@ template<typename ElementT, typename QueueT> template<typename T> bool LLThreadSafeQueue<ElementT, QueueT>::tryPush(T&& element) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryLock( [this, element=std::move(element)](lock_t& lock) { @@ -374,7 +374,7 @@ bool LLThreadSafeQueue<ElementT, QueueT>::tryPushFor( const std::chrono::duration<Rep, Period>& timeout, T&& element) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; // Convert duration to time_point: passing the same timeout duration to // each of multiple calls is wrong. return tryPushUntil(std::chrono::steady_clock::now() + timeout, @@ -388,7 +388,7 @@ bool LLThreadSafeQueue<ElementT, QueueT>::tryPushUntil( const std::chrono::time_point<Clock, Duration>& until, T&& element) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryLockUntil( until, [this, until, element=std::move(element)](lock_t& lock) @@ -421,7 +421,7 @@ template <typename ElementT, typename QueueT> typename LLThreadSafeQueue<ElementT, QueueT>::pop_result LLThreadSafeQueue<ElementT, QueueT>::pop_(lock_t& lock, ElementT& element) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; // If mStorage is empty, there's no head element. if (mStorage.empty()) return mClosed? DONE : EMPTY; @@ -443,7 +443,7 @@ LLThreadSafeQueue<ElementT, QueueT>::pop_(lock_t& lock, ElementT& element) template<typename ElementT, typename QueueT> ElementT LLThreadSafeQueue<ElementT, QueueT>::pop(void) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; lock_t lock1(mLock); ElementT value; while (true) @@ -472,7 +472,7 @@ ElementT LLThreadSafeQueue<ElementT, QueueT>::pop(void) template<typename ElementT, typename QueueT> bool LLThreadSafeQueue<ElementT, QueueT>::tryPop(ElementT & element) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryLock( [this, &element](lock_t& lock) { @@ -490,7 +490,7 @@ bool LLThreadSafeQueue<ElementT, QueueT>::tryPopFor( const std::chrono::duration<Rep, Period>& timeout, ElementT& element) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; // Convert duration to time_point: passing the same timeout duration to // each of multiple calls is wrong. return tryPopUntil(std::chrono::steady_clock::now() + timeout, element); @@ -503,7 +503,7 @@ bool LLThreadSafeQueue<ElementT, QueueT>::tryPopUntil( const std::chrono::time_point<Clock, Duration>& until, ElementT& element) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryLockUntil( until, [this, until, &element](lock_t& lock) @@ -523,7 +523,7 @@ LLThreadSafeQueue<ElementT, QueueT>::tryPopUntil_( const std::chrono::time_point<Clock, Duration>& until, ElementT& element) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; while (true) { pop_result popped = pop_(lock, element); @@ -550,7 +550,7 @@ LLThreadSafeQueue<ElementT, QueueT>::tryPopUntil_( template<typename ElementT, typename QueueT> size_t LLThreadSafeQueue<ElementT, QueueT>::size(void) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; lock_t lock(mLock); return mStorage.size(); } @@ -559,7 +559,7 @@ size_t LLThreadSafeQueue<ElementT, QueueT>::size(void) template<typename ElementT, typename QueueT> void LLThreadSafeQueue<ElementT, QueueT>::close() { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; lock_t lock(mLock); mClosed = true; lock.unlock(); @@ -573,7 +573,7 @@ void LLThreadSafeQueue<ElementT, QueueT>::close() template<typename ElementT, typename QueueT> bool LLThreadSafeQueue<ElementT, QueueT>::isClosed() { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; lock_t lock(mLock); return mClosed; } @@ -582,7 +582,7 @@ bool LLThreadSafeQueue<ElementT, QueueT>::isClosed() template<typename ElementT, typename QueueT> bool LLThreadSafeQueue<ElementT, QueueT>::done() { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; lock_t lock(mLock); return mClosed && mStorage.empty(); } diff --git a/indra/llcommon/threadsafeschedule.h b/indra/llcommon/threadsafeschedule.h index 601681d550..3e0da94c02 100644 --- a/indra/llcommon/threadsafeschedule.h +++ b/indra/llcommon/threadsafeschedule.h @@ -98,14 +98,14 @@ namespace LL // we could minimize redundancy by breaking out a common base class... void push(const DataTuple& tuple) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; push(tuple_cons(Clock::now(), tuple)); } /// individually pass each component of the TimeTuple void push(const TimePoint& time, Args&&... args) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; push(TimeTuple(time, std::forward<Args>(args)...)); } @@ -116,7 +116,7 @@ namespace LL // and call that overload. void push(Args&&... args) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; push(Clock::now(), std::forward<Args>(args)...); } @@ -127,21 +127,21 @@ namespace LL /// DataTuple with implicit now bool tryPush(const DataTuple& tuple) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryPush(tuple_cons(Clock::now(), tuple)); } /// individually pass components bool tryPush(const TimePoint& time, Args&&... args) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryPush(TimeTuple(time, std::forward<Args>(args)...)); } /// individually pass components with implicit now bool tryPush(Args&&... args) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryPush(Clock::now(), std::forward<Args>(args)...); } @@ -154,7 +154,7 @@ namespace LL bool tryPushFor(const std::chrono::duration<Rep, Period>& timeout, const DataTuple& tuple) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryPushFor(timeout, tuple_cons(Clock::now(), tuple)); } @@ -163,7 +163,7 @@ namespace LL bool tryPushFor(const std::chrono::duration<Rep, Period>& timeout, const TimePoint& time, Args&&... args) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryPushFor(TimeTuple(time, std::forward<Args>(args)...)); } @@ -172,7 +172,7 @@ namespace LL bool tryPushFor(const std::chrono::duration<Rep, Period>& timeout, Args&&... args) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryPushFor(Clock::now(), std::forward<Args>(args)...); } @@ -185,7 +185,7 @@ namespace LL bool tryPushUntil(const std::chrono::time_point<Clock, Duration>& until, const DataTuple& tuple) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryPushUntil(until, tuple_cons(Clock::now(), tuple)); } @@ -194,7 +194,7 @@ namespace LL bool tryPushUntil(const std::chrono::time_point<Clock, Duration>& until, const TimePoint& time, Args&&... args) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryPushUntil(until, TimeTuple(time, std::forward<Args>(args)...)); } @@ -203,7 +203,7 @@ namespace LL bool tryPushUntil(const std::chrono::time_point<Clock, Duration>& until, Args&&... args) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tryPushUntil(until, Clock::now(), std::forward<Args>(args)...); } @@ -221,14 +221,14 @@ namespace LL // haven't yet jumped through those hoops. DataTuple pop() { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return tuple_cdr(popWithTime()); } /// pop TimeTuple by value TimeTuple popWithTime() { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; lock_t lock(super::mLock); // We can't just sit around waiting forever, given that there may // be items in the queue that are not yet ready but will *become* @@ -268,7 +268,7 @@ namespace LL /// tryPop(DataTuple&) bool tryPop(DataTuple& tuple) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; TimeTuple tt; if (! super::tryPop(tt)) return false; @@ -279,7 +279,7 @@ namespace LL /// for when Args has exactly one type bool tryPop(typename std::tuple_element<1, TimeTuple>::type& value) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; TimeTuple tt; if (! super::tryPop(tt)) return false; @@ -291,7 +291,7 @@ namespace LL template <typename Rep, typename Period, typename Tuple> bool tryPopFor(const std::chrono::duration<Rep, Period>& timeout, Tuple& tuple) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; // It's important to use OUR tryPopUntil() implementation, rather // than delegating immediately to our base class. return tryPopUntil(Clock::now() + timeout, tuple); @@ -302,7 +302,7 @@ namespace LL bool tryPopUntil(const std::chrono::time_point<Clock, Duration>& until, TimeTuple& tuple) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; // super::tryPopUntil() wakes up when an item becomes available or // we hit 'until', whichever comes first. Thing is, the current // head of the queue could become ready sooner than either of @@ -322,7 +322,7 @@ namespace LL pop_result tryPopUntil_(lock_t& lock, const TimePoint& until, TimeTuple& tuple) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; TimePoint adjusted = until; if (! super::mStorage.empty()) { @@ -350,7 +350,7 @@ namespace LL bool tryPopUntil(const std::chrono::time_point<Clock, Duration>& until, DataTuple& tuple) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; TimeTuple tt; if (! tryPopUntil(until, tt)) return false; @@ -363,7 +363,7 @@ namespace LL bool tryPopUntil(const std::chrono::time_point<Clock, Duration>& until, typename std::tuple_element<1, TimeTuple>::type& value) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; TimeTuple tt; if (! tryPopUntil(until, tt)) return false; @@ -387,7 +387,7 @@ namespace LL // considering whether to deliver the current head element bool canPop(const TimeTuple& head) const override { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; // an item with a future timestamp isn't yet ready to pop // (should we add some slop for overhead?) return std::get<0>(head) <= Clock::now(); diff --git a/indra/llcommon/workqueue.cpp b/indra/llcommon/workqueue.cpp index c74dada2e4..eb06890468 100644 --- a/indra/llcommon/workqueue.cpp +++ b/indra/llcommon/workqueue.cpp @@ -60,7 +60,7 @@ void LL::WorkQueue::runUntilClose() { for (;;) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; callWork(mQueue.pop()); } } @@ -71,7 +71,7 @@ void LL::WorkQueue::runUntilClose() bool LL::WorkQueue::runPending() { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; for (Work work; mQueue.tryPop(work); ) { callWork(work); @@ -91,7 +91,7 @@ bool LL::WorkQueue::runOne() bool LL::WorkQueue::runUntil(const TimePoint& until) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; // Should we subtract some slop to allow for typical Work execution time? // How much slop? // runUntil() is simply a time-bounded runPending(). @@ -129,7 +129,7 @@ void LL::WorkQueue::callWork(const Queue::DataTuple& work) void LL::WorkQueue::callWork(const Work& work) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; try { work(); |