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 "llviewermessage.h"
#include "llviewerregion.h" #include "llviewerregion.h"
#include "llviewerwindow.h" #include "llviewerwindow.h"
#include "hippogridmanager.h"
class AIHTTPTimeoutPolicy; class AIHTTPTimeoutPolicy;
extern AIHTTPTimeoutPolicy inventoryModelFetchDescendentsResponder_timeout; extern AIHTTPTimeoutPolicy inventoryModelFetchDescendentsResponder_timeout;
@@ -201,6 +202,16 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
std::string url = region->getCapability("FetchInventory2"); std::string url = region->getCapability("FetchInventory2");
if (gSavedSettings.getBOOL("UseHTTPInventory") && !url.empty()) 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(); bulkFetch();
return; return;
} }
@@ -578,27 +589,19 @@ BOOL LLInventoryModelFetchDescendentsResponder::getIsRecursive(const LLUUID& cat
} }
// Bundle up a bunch of requests to send all at once. // Bundle up a bunch of requests to send all at once.
// static
void LLInventoryModelBackgroundFetch::bulkFetch() void LLInventoryModelBackgroundFetch::bulkFetch()
{ {
//Background fetch is called from gIdleCallbacks in a loop until background fetch is stopped. //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 //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. //sent. If it exceeds our retry time, go ahead and fire off another batch.
LLViewerRegion* region = gAgent.getRegion(); LLViewerRegion* region = gAgent.getRegion();
if (!region) return; if (gDisconnected || !region) return;
S16 max_concurrent_fetches=8; static LLCachedControl<F32> const throttle_bandwidth("HTTPThrottleBandwidth", 2000);
F32 new_min_time = 0.5f; //HACK! Clean this up when old code goes away entirely. bool const no_bandwidth_throttling = gHippoGridManager->getConnectedGrid()->isAvination();
if (mMinTimeBetweenFetches < new_min_time) 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 item_count=0;

View File

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