Add throttling to HTTP inventory (bulk) fetching.

Call AIPerService::wantsMoreHTTPRequestsFor in
LLInventoryModelBackgroundFetch::bulkFetch to determine if curl is ready
for the next batch or not, instead of using inaccurate heuristic code
that is just guessing a bit.
This commit is contained in:
Aleric Inglewood
2013-04-30 20:36:00 +02:00
parent a1a019d319
commit 0c7e62ab59
2 changed files with 20 additions and 14 deletions

View File

@@ -37,6 +37,7 @@
#include "llviewermessage.h"
#include "llviewerregion.h"
#include "llviewerwindow.h"
#include "hippogridmanager.h"
class AIHTTPTimeoutPolicy;
extern AIHTTPTimeoutPolicy inventoryModelFetchDescendentsResponder_timeout;
@@ -201,10 +202,20 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
std::string url = region->getCapability("FetchInventory2");
if (gSavedSettings.getBOOL("UseHTTPInventory") && !url.empty())
{
if (!mPerServicePtr)
{
// One time initialization needed for bulkFetch().
std::string servicename = AIPerService::extract_canonical_servicename(url);
if (!servicename.empty())
{
llinfos << "Initialized service name for bulk inventory fetching with \"" << servicename << "\"." << llendl;
mPerServicePtr = AIPerService::instance(servicename);
}
}
bulkFetch();
return;
}
#if 1
//--------------------------------------------------------------------------------
// DEPRECATED OLD CODE
@@ -578,28 +589,20 @@ BOOL LLInventoryModelFetchDescendentsResponder::getIsRecursive(const LLUUID& cat
}
// Bundle up a bunch of requests to send all at once.
// static
void LLInventoryModelBackgroundFetch::bulkFetch()
{
//Background fetch is called from gIdleCallbacks in a loop until background fetch is stopped.
//If there are items in mFetchQueue, we want to check the time since the last bulkFetch was
//sent. If it exceeds our retry time, go ahead and fire off another batch.
LLViewerRegion* region = gAgent.getRegion();
if (!region) return;
if (gDisconnected || !region) return;
S16 max_concurrent_fetches=8;
F32 new_min_time = 0.5f; //HACK! Clean this up when old code goes away entirely.
if (mMinTimeBetweenFetches < new_min_time)
static LLCachedControl<F32> const throttle_bandwidth("HTTPThrottleBandwidth", 2000);
bool const no_bandwidth_throttling = gHippoGridManager->getConnectedGrid()->isAvination();
if (!AIPerService::wantsMoreHTTPRequestsFor(mPerServicePtr, throttle_bandwidth, no_bandwidth_throttling))
{
mMinTimeBetweenFetches=new_min_time; //HACK! See above.
return; // Wait.
}
if (gDisconnected ||
(mFetchCount > max_concurrent_fetches) ||
(mFetchTimer.getElapsedTimeF32() < mMinTimeBetweenFetches))
{
return; // just bail if we are disconnected
}
U32 item_count=0;
U32 folder_count=0;

View File

@@ -29,6 +29,7 @@
#include "llsingleton.h"
#include "lluuid.h"
#include "aicurlperservice.h"
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryModelBackgroundFetch
@@ -81,6 +82,8 @@ private:
BOOL mTimelyFetchPending;
S32 mNumFetchRetries;
AIPerServicePtr mPerServicePtr; // Pointer to the AIPerService corresponding to the FetchInventory2 capability.
LLFrameTimer mFetchTimer;
F32 mMinTimeBetweenFetches;
F32 mMaxTimeBetweenFetches;