diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-10-22 11:34:46 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-10-22 11:34:46 -0400 |
commit | b0645835595f3517223329ba62f46277d3e3a9dd (patch) | |
tree | a2b523c3beff518dcbec55663185d6ff70ae5097 /indra/llcommon/coro_scheduler.h | |
parent | 8e737a5d45157426cb84927170a78baea2106813 (diff) |
Make llcoro::scheduler log coros that run too long between yields.
Introduce LLCoros::CoroData::mHistogram, a map of cutoff times (bucket
breakpoints) with counts of occurrences. The idea is that mHistogram counts
how many times the real time taken by a particular coroutine resumption falls
into one of those buckets. Initialize the map with guessed buckets; these are
set in llcoros.cpp so they can be changed without requiring extensive rebuilds.
scheduler::pick_next() now records the timestamp and fiber context just before
the fiber manager resumes the next coroutine. If the next pick_next() call
reveals that the previous resumption took longer than the minimum bucket
breakpoint, it increments the appropriate bucket counter and logs the instance.
LLCoros::toplevel() reports nonzero mHistogram entries on coroutine
termination.
Diffstat (limited to 'indra/llcommon/coro_scheduler.h')
-rw-r--r-- | indra/llcommon/coro_scheduler.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/indra/llcommon/coro_scheduler.h b/indra/llcommon/coro_scheduler.h index eee2d746b5..7af90685dc 100644 --- a/indra/llcommon/coro_scheduler.h +++ b/indra/llcommon/coro_scheduler.h @@ -47,17 +47,20 @@ public: static void use(); private: - // This is the fiber::id of the main fiber. We use this to discover - // whether the fiber passed to awakened() is in fact the main fiber. + LL::WorkQueue::ptr_t getWorkQueue(); + + // This is the fiber::id of the main fiber. boost::fibers::fiber::id mMainID; - // This context* is nullptr until awakened() notices that the main fiber - // has become ready, at which point it contains the main fiber's context*. + // This context* is nullptr while the main fiber is running or suspended, + // but is set to the main fiber's context each time the main fiber is ready. boost::fibers::context* mMainCtx{}; - // Set when pick_next() returns the main fiber. - bool mMainRunning{ false }; + // Remember the context returned by the previous pick_next() call. + boost::fibers::context* mPrevCtx{}; // If it's been at least this long since the last time the main fiber got // control, jump it to the head of the queue. F64 mTimeslice{ DEFAULT_TIMESLICE }; + // Time when we resumed the most recently running fiber + F64 mResumeTime{ 0 }; // Timestamp as of the last time we suspended the main fiber. F64 mMainLast{ 0 }; // Timestamp of start time |