SH-4407 Tuning to get new code working as well.

Fri, 16 Aug 2013 18:07:49 -0400

author
Monty Brandenberg <monty@lindenlab.com>
date
Fri, 16 Aug 2013 18:07:49 -0400
changeset 40707
6173865727da
parent 40706
fc62f596cc97
child 40708
88761ed1b6bc

SH-4407 Tuning to get new code working as well.
Do some runtime code avoidance and skip unnecessary libcurl and
syscall invocations.

indra/llcorehttp/_httplibcurl.cpp file | annotate | diff | revisions
indra/llcorehttp/_httplibcurl.h file | annotate | diff | revisions
indra/llcorehttp/_httppolicy.cpp file | annotate | diff | revisions
     1.1 --- a/indra/llcorehttp/_httplibcurl.cpp	Thu Aug 15 19:00:43 2013 -0400
     1.2 +++ b/indra/llcorehttp/_httplibcurl.cpp	Fri Aug 16 18:07:49 2013 -0400
     1.3 @@ -41,7 +41,8 @@
     1.4  HttpLibcurl::HttpLibcurl(HttpService * service)
     1.5  	: mService(service),
     1.6  	  mPolicyCount(0),
     1.7 -	  mMultiHandles(NULL)
     1.8 +	  mMultiHandles(NULL),
     1.9 +	  mActiveHandles(NULL)
    1.10  {}
    1.11  
    1.12  
    1.13 @@ -77,6 +78,9 @@
    1.14  
    1.15  		delete [] mMultiHandles;
    1.16  		mMultiHandles = NULL;
    1.17 +
    1.18 +		delete [] mActiveHandles;
    1.19 +		mActiveHandles = NULL;
    1.20  	}
    1.21  
    1.22  	mPolicyCount = 0;
    1.23 @@ -90,9 +94,12 @@
    1.24  	
    1.25  	mPolicyCount = policy_count;
    1.26  	mMultiHandles = new CURLM * [mPolicyCount];
    1.27 +	mActiveHandles = new int [mPolicyCount];
    1.28 +	
    1.29  	for (int policy_class(0); policy_class < mPolicyCount; ++policy_class)
    1.30  	{
    1.31  		mMultiHandles[policy_class] = curl_multi_init();
    1.32 +		mActiveHandles[policy_class] = 0;
    1.33  	}
    1.34  }
    1.35  
    1.36 @@ -110,8 +117,10 @@
    1.37  	// Give libcurl some cycles to do I/O & callbacks
    1.38  	for (int policy_class(0); policy_class < mPolicyCount; ++policy_class)
    1.39  	{
    1.40 -		if (! mMultiHandles[policy_class])
    1.41 +		if (! mActiveHandles[policy_class] || ! mMultiHandles[policy_class])
    1.42 +		{
    1.43  			continue;
    1.44 +		}
    1.45  		
    1.46  		int running(0);
    1.47  		CURLMcode status(CURLM_CALL_MULTI_PERFORM);
    1.48 @@ -191,6 +200,7 @@
    1.49  	
    1.50  	// On success, make operation active
    1.51  	mActiveOps.insert(op);
    1.52 +	++mActiveHandles[op->mReqPolicy];
    1.53  }
    1.54  
    1.55  
    1.56 @@ -212,6 +222,7 @@
    1.57  
    1.58  	// Drop references
    1.59  	mActiveOps.erase(it);
    1.60 +	--mActiveHandles[op->mReqPolicy];
    1.61  	op->release();
    1.62  
    1.63  	return true;
    1.64 @@ -273,6 +284,7 @@
    1.65  
    1.66  	// Deactivate request
    1.67  	mActiveOps.erase(it);
    1.68 +	--mActiveHandles[op->mReqPolicy];
    1.69  	op->mCurlActive = false;
    1.70  
    1.71  	// Set final status of request if it hasn't failed by other mechanisms yet
    1.72 @@ -334,19 +346,9 @@
    1.73  
    1.74  int HttpLibcurl::getActiveCountInClass(int policy_class) const
    1.75  {
    1.76 -	int count(0);
    1.77 -	
    1.78 -	for (active_set_t::const_iterator iter(mActiveOps.begin());
    1.79 -		 mActiveOps.end() != iter;
    1.80 -		 ++iter)
    1.81 -	{
    1.82 -		if ((*iter)->mReqPolicy == policy_class)
    1.83 -		{
    1.84 -			++count;
    1.85 -		}
    1.86 -	}
    1.87 -	
    1.88 -	return count;
    1.89 +	llassert_always(policy_class < mPolicyCount);
    1.90 +
    1.91 +	return mActiveHandles ? mActiveHandles[policy_class] : 0;
    1.92  }
    1.93  
    1.94  
     2.1 --- a/indra/llcorehttp/_httplibcurl.h	Thu Aug 15 19:00:43 2013 -0400
     2.2 +++ b/indra/llcorehttp/_httplibcurl.h	Fri Aug 16 18:07:49 2013 -0400
     2.3 @@ -133,6 +133,7 @@
     2.4  	active_set_t		mActiveOps;
     2.5  	int					mPolicyCount;
     2.6  	CURLM **			mMultiHandles;			// One handle per policy class
     2.7 +	int *				mActiveHandles;			// Active count per policy class
     2.8  }; // end class HttpLibcurl
     2.9  
    2.10  }  // end namespace LLCore
     3.1 --- a/indra/llcorehttp/_httppolicy.cpp	Thu Aug 15 19:00:43 2013 -0400
     3.2 +++ b/indra/llcorehttp/_httppolicy.cpp	Fri Aug 16 18:07:49 2013 -0400
     3.3 @@ -212,6 +212,14 @@
     3.4  	for (int policy_class(0); policy_class < mClasses.size(); ++policy_class)
     3.5  	{
     3.6  		ClassState & state(*mClasses[policy_class]);
     3.7 +		HttpRetryQueue & retryq(state.mRetryQueue);
     3.8 +		HttpReadyQueue & readyq(state.mReadyQueue);
     3.9 +
    3.10 +		if (retryq.empty() && readyq.empty())
    3.11 +		{
    3.12 +			continue;
    3.13 +		}
    3.14 +		
    3.15  		const bool throttle_enabled(state.mOptions.mThrottleRate > 0L);
    3.16  		const bool throttle_current(throttle_enabled && now < state.mThrottleEnd);
    3.17  
    3.18 @@ -225,9 +233,6 @@
    3.19  		int active(transport.getActiveCountInClass(policy_class));
    3.20  		int needed(state.mOptions.mConnectionLimit - active);		// Expect negatives here
    3.21  
    3.22 -		HttpRetryQueue & retryq(state.mRetryQueue);
    3.23 -		HttpReadyQueue & readyq(state.mReadyQueue);
    3.24 -
    3.25  		if (needed > 0)
    3.26  		{
    3.27  			// First see if we have any retries...

mercurial