diff options
| author | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-02-04 01:51:10 +0200 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-02-04 16:49:46 +0200 |
| commit | e182063bdea4219b780c2fa372db76de7162f2d1 (patch) | |
| tree | 3219c762de0f98bee92567abcd7a6ea2c0aa0348 /indra/newview | |
| parent | 4c8f8463d3e011cc4d1ca2c50123afc4faa6d8aa (diff) | |
#5358 Improve performance when processing inventory fetches in parallel
All tasks combined should not go over 10ms to not affect performance too much.
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llaisapi.cpp | 28 | ||||
| -rw-r--r-- | indra/newview/llaisapi.h | 14 |
2 files changed, 34 insertions, 8 deletions
diff --git a/indra/newview/llaisapi.cpp b/indra/newview/llaisapi.cpp index 9c76f56ef3..f67f2688a1 100644 --- a/indra/newview/llaisapi.cpp +++ b/indra/newview/llaisapi.cpp @@ -1019,6 +1019,9 @@ void AISAPI::InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t ht } //------------------------------------------------------------------------- +U32 AISUpdate::sBatchFrameCount = 0; +LLTimer AISUpdate::sBatchTimer; + AISUpdate::AISUpdate(const LLSD& update, AISAPI::COMMAND_TYPE type, const LLSD& request_body) : mType(type) { @@ -1036,8 +1039,16 @@ AISUpdate::AISUpdate(const LLSD& update, AISAPI::COMMAND_TYPE type, const LLSD& mFetchDepth = request_body["depth"].asInteger(); } - mTimer.setTimerExpirySec(AIS_EXPIRY_SECONDS); - mTimer.start(); + mTaskTimer.setTimerExpirySec(AIS_TASK_EXPIRY_SECONDS); + mTaskTimer.start(); + + U32 current_frame = LLFrameTimer::getFrameCount(); + if (sBatchFrameCount != current_frame) + { + sBatchTimer.setTimerExpirySec(AIS_BATCH_EXPIRY_SECONDS); + sBatchTimer.start(); + sBatchFrameCount = current_frame; + } parseUpdate(update); } @@ -1058,7 +1069,7 @@ void AISUpdate::clearParseResults() void AISUpdate::checkTimeout() { - if (mTimer.hasExpired()) + if (mTaskTimer.hasExpired() || sBatchTimer.hasExpired()) { // If we are taking too long, don't starve other tasks, // yield to mainloop. @@ -1067,7 +1078,16 @@ void AISUpdate::checkTimeout() // a chance, so wait for a frame tick instead. llcoro::suspendUntilNextFrame(); LLCoros::checkStop(); - mTimer.setTimerExpirySec(AIS_EXPIRY_SECONDS); + mTaskTimer.setTimerExpirySec(AIS_TASK_EXPIRY_SECONDS); + + U32 current_frame = LLFrameTimer::getFrameCount(); + if (sBatchFrameCount != current_frame) + { + // To give other tasks a chance batch timer + // has a longer delay. + sBatchTimer.setTimerExpirySec(AIS_BATCH_EXPIRY_SECONDS); + sBatchFrameCount = current_frame; + } } } diff --git a/indra/newview/llaisapi.h b/indra/newview/llaisapi.h index cfc286da2e..1dab0dd1f9 100644 --- a/indra/newview/llaisapi.h +++ b/indra/newview/llaisapi.h @@ -130,9 +130,13 @@ private: void clearParseResults(); void checkTimeout(); - // Fetch can return large packets of data, throttle it to not cause lags - // Todo: make throttle work over all fetch requests isntead of per-request - const F32 AIS_EXPIRY_SECONDS = 0.008f; + // Fetches can return large packets of data, + // throttle them individually to not get stuck + // on a single large task. And throttle sum total + // to not cause lags when multiple large fetches + // returned results. + const F32 AIS_TASK_EXPIRY_SECONDS = 0.008f; + const F32 AIS_BATCH_EXPIRY_SECONDS = 0.010f; typedef std::map<LLUUID,size_t> uuid_int_map_t; uuid_int_map_t mCatDescendentDeltas; @@ -154,7 +158,9 @@ private: uuid_list_t mCategoryIds; bool mFetch; S32 mFetchDepth; - LLTimer mTimer; + LLTimer mTaskTimer; + static LLTimer sBatchTimer; + static U32 sBatchFrameCount; AISAPI::COMMAND_TYPE mType; }; |
