Skip to content

Commit e182063

Browse files
committed
#5358 Improve performance when processing inventory fetches in parallel
All tasks combined should not go over 10ms to not affect performance too much.
1 parent 4c8f846 commit e182063

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

indra/newview/llaisapi.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,9 @@ void AISAPI::InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t ht
10191019
}
10201020

10211021
//-------------------------------------------------------------------------
1022+
U32 AISUpdate::sBatchFrameCount = 0;
1023+
LLTimer AISUpdate::sBatchTimer;
1024+
10221025
AISUpdate::AISUpdate(const LLSD& update, AISAPI::COMMAND_TYPE type, const LLSD& request_body)
10231026
: mType(type)
10241027
{
@@ -1036,8 +1039,16 @@ AISUpdate::AISUpdate(const LLSD& update, AISAPI::COMMAND_TYPE type, const LLSD&
10361039
mFetchDepth = request_body["depth"].asInteger();
10371040
}
10381041

1039-
mTimer.setTimerExpirySec(AIS_EXPIRY_SECONDS);
1040-
mTimer.start();
1042+
mTaskTimer.setTimerExpirySec(AIS_TASK_EXPIRY_SECONDS);
1043+
mTaskTimer.start();
1044+
1045+
U32 current_frame = LLFrameTimer::getFrameCount();
1046+
if (sBatchFrameCount != current_frame)
1047+
{
1048+
sBatchTimer.setTimerExpirySec(AIS_BATCH_EXPIRY_SECONDS);
1049+
sBatchTimer.start();
1050+
sBatchFrameCount = current_frame;
1051+
}
10411052
parseUpdate(update);
10421053
}
10431054

@@ -1058,7 +1069,7 @@ void AISUpdate::clearParseResults()
10581069

10591070
void AISUpdate::checkTimeout()
10601071
{
1061-
if (mTimer.hasExpired())
1072+
if (mTaskTimer.hasExpired() || sBatchTimer.hasExpired())
10621073
{
10631074
// If we are taking too long, don't starve other tasks,
10641075
// yield to mainloop.
@@ -1067,7 +1078,16 @@ void AISUpdate::checkTimeout()
10671078
// a chance, so wait for a frame tick instead.
10681079
llcoro::suspendUntilNextFrame();
10691080
LLCoros::checkStop();
1070-
mTimer.setTimerExpirySec(AIS_EXPIRY_SECONDS);
1081+
mTaskTimer.setTimerExpirySec(AIS_TASK_EXPIRY_SECONDS);
1082+
1083+
U32 current_frame = LLFrameTimer::getFrameCount();
1084+
if (sBatchFrameCount != current_frame)
1085+
{
1086+
// To give other tasks a chance batch timer
1087+
// has a longer delay.
1088+
sBatchTimer.setTimerExpirySec(AIS_BATCH_EXPIRY_SECONDS);
1089+
sBatchFrameCount = current_frame;
1090+
}
10711091
}
10721092
}
10731093

indra/newview/llaisapi.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,13 @@ class AISUpdate
130130
void clearParseResults();
131131
void checkTimeout();
132132

133-
// Fetch can return large packets of data, throttle it to not cause lags
134-
// Todo: make throttle work over all fetch requests isntead of per-request
135-
const F32 AIS_EXPIRY_SECONDS = 0.008f;
133+
// Fetches can return large packets of data,
134+
// throttle them individually to not get stuck
135+
// on a single large task. And throttle sum total
136+
// to not cause lags when multiple large fetches
137+
// returned results.
138+
const F32 AIS_TASK_EXPIRY_SECONDS = 0.008f;
139+
const F32 AIS_BATCH_EXPIRY_SECONDS = 0.010f;
136140

137141
typedef std::map<LLUUID,size_t> uuid_int_map_t;
138142
uuid_int_map_t mCatDescendentDeltas;
@@ -154,7 +158,9 @@ class AISUpdate
154158
uuid_list_t mCategoryIds;
155159
bool mFetch;
156160
S32 mFetchDepth;
157-
LLTimer mTimer;
161+
LLTimer mTaskTimer;
162+
static LLTimer sBatchTimer;
163+
static U32 sBatchFrameCount;
158164
AISAPI::COMMAND_TYPE mType;
159165
};
160166

0 commit comments

Comments
 (0)