summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-10-22 14:46:15 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-10-22 14:46:15 -0400
commitbfe759584f63c0587a2dc6a0086ad9d5b6c63a56 (patch)
tree84653a1211908c7dd2ce5bc4877e79f8e6515099 /indra/llmessage
parent62fc3ceaf5251458239f91192a05edc64bedf33b (diff)
parent394f7b37f2ec05c7cfb32c350432886f1c493c85 (diff)
Merge branch 'develop' into marchcat/xcode-16
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llcoproceduremanager.cpp24
-rw-r--r--indra/llmessage/llexperiencecache.cpp35
-rw-r--r--indra/llmessage/llexperiencecache.h11
3 files changed, 43 insertions, 27 deletions
diff --git a/indra/llmessage/llcoproceduremanager.cpp b/indra/llmessage/llcoproceduremanager.cpp
index 13972ad399..5539ca7b86 100644
--- a/indra/llmessage/llcoproceduremanager.cpp
+++ b/indra/llmessage/llcoproceduremanager.cpp
@@ -403,6 +403,7 @@ void LLCoprocedurePool::coprocedureInvokerCoro(
CoprocQueuePtr pendingCoprocs,
LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter)
{
+ std::string prevtask;
for (;;)
{
// It is VERY IMPORTANT that we instantiate a new ptr_t just before
@@ -424,10 +425,25 @@ void LLCoprocedurePool::coprocedureInvokerCoro(
// destroyed during pop_wait_for().
QueuedCoproc::ptr_t coproc;
boost::fibers::channel_op_status status;
+ // Each time control reaches our custom coroutine scheduler, we check
+ // how long the previous coroutine ran before yielding, and report
+ // coroutines longer than a certain cutoff. But these coprocedure pool
+ // coroutines are generic; the only way we know what work they're
+ // doing is the task 'status' set by LLCoros::setStatus(). But what if
+ // the coroutine runs the task to completion and returns to waiting?
+ // It does no good to report that "waiting" ran long. So each time we
+ // enter "waiting" status, also report the *previous* task name.
+ std::string waiting = "waiting", newstatus;
+ if (prevtask.empty())
{
- LLCoros::TempStatus st("waiting for work for 10s");
- status = pendingCoprocs->pop_wait_for(coproc, std::chrono::seconds(10));
+ newstatus = waiting;
}
+ else
+ {
+ newstatus = stringize("done ", prevtask, "; ", waiting);
+ }
+ LLCoros::setStatus(newstatus);
+ status = pendingCoprocs->pop_wait_for(coproc, std::chrono::seconds(10));
if (status == boost::fibers::channel_op_status::closed)
{
break;
@@ -436,6 +452,7 @@ void LLCoprocedurePool::coprocedureInvokerCoro(
if(status == boost::fibers::channel_op_status::timeout)
{
LL_DEBUGS_ONCE("CoProcMgr") << "pool '" << mPoolName << "' waiting." << LL_ENDL;
+ prevtask.clear();
continue;
}
// we actually popped an item
@@ -446,6 +463,9 @@ void LLCoprocedurePool::coprocedureInvokerCoro(
try
{
+ // set "status" of pool coroutine to the name of the coproc task
+ prevtask = coproc->mName;
+ LLCoros::setStatus(prevtask);
coproc->mProc(httpAdapter, coproc->mId);
}
catch (const LLCoros::Stop &e)
diff --git a/indra/llmessage/llexperiencecache.cpp b/indra/llmessage/llexperiencecache.cpp
index b5d0c93376..ea9475ed69 100644
--- a/indra/llmessage/llexperiencecache.cpp
+++ b/indra/llmessage/llexperiencecache.cpp
@@ -110,9 +110,8 @@ void LLExperienceCache::initSingleton()
LLCoprocedureManager::instance().initializePool("ExpCache");
- LLCoros::instance().launch("LLExperienceCache::idleCoro",
- boost::bind(&LLExperienceCache::idleCoro, this));
-
+ const F32 SECS_BETWEEN_REQUESTS = 0.5f;
+ mExpirationTimerHandle = LL::Timers::instance().scheduleEvery([this]() { expirationTimer(); return false; }, SECS_BETWEEN_REQUESTS);
}
void LLExperienceCache::cleanup()
@@ -125,6 +124,8 @@ void LLExperienceCache::cleanup()
cache_stream << (*this);
}
sShutdown = true;
+
+ LL::Timers::instance().cancel(mExpirationTimerHandle);
}
//-------------------------------------------------------------------------
@@ -392,30 +393,20 @@ void LLExperienceCache::setCapabilityQuery(LLExperienceCache::CapabilityQuery_t
}
-void LLExperienceCache::idleCoro()
+void LLExperienceCache::expirationTimer()
{
- const F32 SECS_BETWEEN_REQUESTS = 0.5f;
+ LL_PROFILE_ZONE_SCOPED;
const F32 ERASE_EXPIRED_TIMEOUT = 60.f; // seconds
- LL_INFOS("ExperienceCache") << "Launching Experience cache idle coro." << LL_ENDL;
- do
+ if (mEraseExpiredTimer.checkExpirationAndReset(ERASE_EXPIRED_TIMEOUT))
{
- if (mEraseExpiredTimer.checkExpirationAndReset(ERASE_EXPIRED_TIMEOUT))
- {
- eraseExpired();
- }
-
- if (!mRequestQueue.empty())
- {
- requestExperiences();
- }
-
- llcoro::suspendUntilTimeout(SECS_BETWEEN_REQUESTS);
-
- } while (!sShutdown);
+ eraseExpired();
+ }
- // The coroutine system will likely be shut down by the time we get to this point
- // (or at least no further cycling will occur on it since the user has decided to quit.)
+ if (!mRequestQueue.empty())
+ {
+ requestExperiences();
+ }
}
void LLExperienceCache::erase(const LLUUID& key)
diff --git a/indra/llmessage/llexperiencecache.h b/indra/llmessage/llexperiencecache.h
index 81e904107f..b10c24efe4 100644
--- a/indra/llmessage/llexperiencecache.h
+++ b/indra/llmessage/llexperiencecache.h
@@ -30,10 +30,13 @@
#define LL_LLEXPERIENCECACHE_H
#include "linden_common.h"
-#include "llsingleton.h"
+
+#include "llcallbacklist.h" // LL::Timers::handle_t
+#include "llcorehttputil.h"
#include "llframetimer.h"
+#include "llsingleton.h"
#include "llsd.h"
-#include "llcorehttputil.h"
+
#include <boost/signals2.hpp>
#include <boost/function.hpp>
@@ -144,7 +147,9 @@ private:
std::string mCacheFileName;
static bool sShutdown; // control for coroutines, they exist out of LLExperienceCache's scope, so they need a static control
- void idleCoro();
+ LL::Timers::handle_t mExpirationTimerHandle;
+ void expirationTimer();
+
void eraseExpired();
void requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, std::string, RequestQueue_t);
void requestExperiences();