SH-4312 Clumsy configuration coordination between mesh and corehttp

Fri, 28 Jun 2013 20:08:29 -0400

author
Monty Brandenberg <monty@lindenlab.com>
date
Fri, 28 Jun 2013 20:08:29 -0400
changeset 40689
db8a294b2cab
parent 40688
56954bea245d
child 40690
749d1e12fc55
child 40691
0dc3766d2ff3

SH-4312 Clumsy configuration coordination between mesh and corehttp
Taught llappcorehttp to register signals on the settings values
that chagne behavior. Have initialization and settings changes
sweep through settings and change them. Dynamic changes are tried
but have no effect (produce a warning message) as dynamic settings
still aren't supported but the plumbing is now connected. Just
need to change llcorehttp. Bounced the 'teleport started' signal
around and it ended up back where it started with some cleanup.
This is making me less angry...

indra/newview/llappcorehttp.cpp file | annotate | diff | revisions
indra/newview/llappcorehttp.h file | annotate | diff | revisions
indra/newview/llmeshrepository.cpp file | annotate | diff | revisions
     1.1 --- a/indra/newview/llappcorehttp.cpp	Fri Jun 28 17:57:57 2013 -0400
     1.2 +++ b/indra/newview/llappcorehttp.cpp	Fri Jun 28 20:08:29 2013 -0400
     1.3 @@ -28,10 +28,52 @@
     1.4  
     1.5  #include "llappcorehttp.h"
     1.6  
     1.7 +#include "llappviewer.h"
     1.8  #include "llviewercontrol.h"
     1.9  
    1.10  
    1.11  const F64 LLAppCoreHttp::MAX_THREAD_WAIT_TIME(10.0);
    1.12 +static const struct
    1.13 +{
    1.14 +	LLAppCoreHttp::EAppPolicy	mPolicy;
    1.15 +	U32							mDefault;
    1.16 +	U32							mMin;
    1.17 +	U32							mMax;
    1.18 +	U32							mDivisor;
    1.19 +	std::string					mKey;
    1.20 +	const char *				mUsage;
    1.21 +} init_data[] =					//  Default and dynamic values for classes
    1.22 +{
    1.23 +	{
    1.24 +		LLAppCoreHttp::AP_TEXTURE,			8,		1,		12,		1,
    1.25 +		"TextureFetchConcurrency",
    1.26 +		"texture fetch"
    1.27 +	},
    1.28 +	{
    1.29 +		LLAppCoreHttp::AP_MESH1,			32,		1,		128,	1,
    1.30 +		"MeshMaxConcurrentRequests",
    1.31 +		"mesh fetch"
    1.32 +	},
    1.33 +	{
    1.34 +		LLAppCoreHttp::AP_MESH2,			8,		1,		32,		4,
    1.35 +		"MeshMaxConcurrentRequests",
    1.36 +		"mesh2 fetch"
    1.37 +	},
    1.38 +	{
    1.39 +		LLAppCoreHttp::AP_LARGE_MESH,		2,		1,		8,		1,
    1.40 +		"",
    1.41 +		"large mesh fetch"
    1.42 +	},
    1.43 +	{
    1.44 +		LLAppCoreHttp::AP_UPLOADS,			2,		1,		8,		1,
    1.45 +		"",
    1.46 +		"asset upload"
    1.47 +	}
    1.48 +};
    1.49 +
    1.50 +static void teleport_started();
    1.51 +static void setting_changed();
    1.52 +
    1.53  
    1.54  LLAppCoreHttp::LLAppCoreHttp()
    1.55  	: mRequest(NULL),
    1.56 @@ -42,6 +84,7 @@
    1.57  	for (int i(0); i < LL_ARRAY_SIZE(mPolicies); ++i)
    1.58  	{
    1.59  		mPolicies[i] = LLCore::HttpRequest::DEFAULT_POLICY_ID;
    1.60 +		mSettings[i] = 0U;
    1.61  	}
    1.62  }
    1.63  
    1.64 @@ -55,45 +98,6 @@
    1.65  
    1.66  void LLAppCoreHttp::init()
    1.67  {
    1.68 -	static const struct
    1.69 -	{
    1.70 -		EAppPolicy		mPolicy;
    1.71 -		U32				mDefault;
    1.72 -		U32				mMin;
    1.73 -		U32				mMax;
    1.74 -		U32				mDivisor;
    1.75 -		std::string		mKey;
    1.76 -		const char *	mUsage;
    1.77 -	} init_data[] =					//  Default and dynamic values for classes
    1.78 -		  {
    1.79 -			  {
    1.80 -				  AP_TEXTURE,			8,		1,		12,		1,
    1.81 -				  "TextureFetchConcurrency",
    1.82 -				  "texture fetch"
    1.83 -			  },
    1.84 -			  {
    1.85 -				  // *FIXME:  Should become 32, 1, 32, 1 before release
    1.86 -				  AP_MESH1,				8,		1,		32,		4,
    1.87 -				  "MeshMaxConcurrentRequests",
    1.88 -				  "mesh fetch"
    1.89 -			  },
    1.90 -			  {
    1.91 -				  AP_MESH2,				8,		1,		32,		4,
    1.92 -				  "MeshMaxConcurrentRequests",
    1.93 -				  "mesh2 fetch"
    1.94 -			  },
    1.95 -			  {
    1.96 -				  AP_LARGE_MESH,		2,		1,		8,		1,
    1.97 -				  "",
    1.98 -				  "large mesh fetch"
    1.99 -			  },
   1.100 -			  {
   1.101 -				  AP_UPLOADS,			2,		1,		8,		1,
   1.102 -				  "",
   1.103 -				  "asset upload"
   1.104 -			  }
   1.105 -		  };
   1.106 -		
   1.107  	LLCore::HttpStatus status = LLCore::HttpRequest::createService();
   1.108  	if (! status)
   1.109  	{
   1.110 @@ -110,14 +114,12 @@
   1.111  						<< LL_ENDL;
   1.112  	}
   1.113  
   1.114 -	// Establish HTTP Proxy.  "LLProxy" is a special string which directs
   1.115 -	// the code to use LLProxy::applyProxySettings() to establish any
   1.116 -	// HTTP or SOCKS proxy for http operations.
   1.117 +	// Establish HTTP Proxy, if desired.
   1.118  	status = LLCore::HttpRequest::setPolicyGlobalOption(LLCore::HttpRequest::GP_LLPROXY, 1);
   1.119  	if (! status)
   1.120  	{
   1.121 -		LL_ERRS("Init") << "Failed to set HTTP proxy for HTTP services.  Reason:  " << status.toString()
   1.122 -						<< LL_ENDL;
   1.123 +		LL_WARNS("Init") << "Failed to set HTTP proxy for HTTP services.  Reason:  " << status.toString()
   1.124 +						 << LL_ENDL;
   1.125  	}
   1.126  
   1.127  	// Tracing levels for library & libcurl (note that 2 & 3 are beyond spammy):
   1.128 @@ -137,7 +139,6 @@
   1.129  	mPolicies[AP_DEFAULT] = LLCore::HttpRequest::DEFAULT_POLICY_ID;
   1.130  
   1.131  	// Setup additional policies based on table and some special rules
   1.132 -	// *TODO:  Make these configurations dynamic later
   1.133  	for (int i(0); i < LL_ARRAY_SIZE(init_data); ++i)
   1.134  	{
   1.135  		const EAppPolicy policy(init_data[i].mPolicy);
   1.136 @@ -162,40 +163,10 @@
   1.137  				continue;
   1.138  			}
   1.139  		}
   1.140 +	}
   1.141  
   1.142 -		// Get target connection concurrency value
   1.143 -		U32 setting(init_data[i].mDefault);
   1.144 -		if (! init_data[i].mKey.empty() && gSavedSettings.controlExists(init_data[i].mKey))
   1.145 -		{
   1.146 -			U32 new_setting(gSavedSettings.getU32(init_data[i].mKey));
   1.147 -			if (new_setting)
   1.148 -			{
   1.149 -				// Treat zero settings as an ask for default
   1.150 -				setting = new_setting / init_data[i].mDivisor;
   1.151 -				setting = llclamp(setting, init_data[i].mMin, init_data[i].mMax);
   1.152 -			}
   1.153 -		}
   1.154 -
   1.155 -		// Set it and report
   1.156 -		// *TODO:  These are intended to be per-host limits when we can
   1.157 -		// support that in llcorehttp/libcurl.
   1.158 -		LLCore::HttpStatus status;
   1.159 -		status = LLCore::HttpRequest::setPolicyClassOption(mPolicies[policy],
   1.160 -														   LLCore::HttpRequest::CP_CONNECTION_LIMIT,
   1.161 -														   setting);
   1.162 -		if (! status)
   1.163 -		{
   1.164 -			LL_WARNS("Init") << "Unable to set " << init_data[i].mUsage
   1.165 -							 << " concurrency.  Reason:  " << status.toString()
   1.166 -							 << LL_ENDL;
   1.167 -		}
   1.168 -		else if (setting != init_data[i].mDefault)
   1.169 -		{
   1.170 -			LL_INFOS("Init") << "Application settings overriding default " << init_data[i].mUsage
   1.171 -							 << " concurrency.  New value:  " << setting
   1.172 -							 << LL_ENDL;
   1.173 -		}
   1.174 -	}
   1.175 +	// Apply initial settings
   1.176 +	refreshSettings(true);
   1.177  	
   1.178  	// Kick the thread
   1.179  	status = LLCore::HttpRequest::startThread();
   1.180 @@ -206,6 +177,30 @@
   1.181  	}
   1.182  
   1.183  	mRequest = new LLCore::HttpRequest;
   1.184 +
   1.185 +	// Register signals for settings and state changes
   1.186 +	for (int i(0); i < LL_ARRAY_SIZE(init_data); ++i)
   1.187 +	{
   1.188 +		if (! init_data[i].mKey.empty() && gSavedSettings.controlExists(init_data[i].mKey))
   1.189 +		{
   1.190 +			LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(init_data[i].mKey);
   1.191 +			if (cntrl_ptr.isNull())
   1.192 +			{
   1.193 +				LL_WARNS("Init") << "Unable to set signal on global setting '" << init_data[i].mKey
   1.194 +								 << "'" << LL_ENDL;
   1.195 +			}
   1.196 +			else
   1.197 +			{
   1.198 +				mSettingsSignal[i] = cntrl_ptr->getCommitSignal()->connect(boost::bind(&setting_changed));
   1.199 +			}
   1.200 +		}
   1.201 +	}
   1.202 +}
   1.203 +
   1.204 +
   1.205 +void setting_changed()
   1.206 +{
   1.207 +	LLAppViewer::instance()->getAppCoreHttp().refreshSettings(false);
   1.208  }
   1.209  
   1.210  
   1.211 @@ -248,6 +243,11 @@
   1.212  		}
   1.213  	}
   1.214  
   1.215 +	for (int i(0); i < LL_ARRAY_SIZE(init_data); ++i)
   1.216 +	{
   1.217 +		mSettingsSignal[i].disconnect();
   1.218 +	}
   1.219 +	
   1.220  	delete mRequest;
   1.221  	mRequest = NULL;
   1.222  
   1.223 @@ -260,6 +260,60 @@
   1.224  	}
   1.225  }
   1.226  
   1.227 +void LLAppCoreHttp::refreshSettings(bool initial)
   1.228 +{
   1.229 +	for (int i(0); i < LL_ARRAY_SIZE(init_data); ++i)
   1.230 +	{
   1.231 +		const EAppPolicy policy(init_data[i].mPolicy);
   1.232 +
   1.233 +		// Get target connection concurrency value
   1.234 +		U32 setting(init_data[i].mDefault);
   1.235 +		if (! init_data[i].mKey.empty() && gSavedSettings.controlExists(init_data[i].mKey))
   1.236 +		{
   1.237 +			U32 new_setting(gSavedSettings.getU32(init_data[i].mKey));
   1.238 +			if (new_setting)
   1.239 +			{
   1.240 +				// Treat zero settings as an ask for default
   1.241 +				setting = new_setting / init_data[i].mDivisor;
   1.242 +				setting = llclamp(setting, init_data[i].mMin, init_data[i].mMax);
   1.243 +			}
   1.244 +		}
   1.245 +
   1.246 +		if (! initial && setting == mSettings[policy])
   1.247 +		{
   1.248 +			// Unchanged, try next setting
   1.249 +			continue;
   1.250 +		}
   1.251 +		
   1.252 +		// Set it and report
   1.253 +		// *TODO:  These are intended to be per-host limits when we can
   1.254 +		// support that in llcorehttp/libcurl.
   1.255 +		LLCore::HttpStatus status;
   1.256 +		status = LLCore::HttpRequest::setPolicyClassOption(mPolicies[policy],
   1.257 +														   LLCore::HttpRequest::CP_CONNECTION_LIMIT,
   1.258 +														   setting);
   1.259 +		if (! status)
   1.260 +		{
   1.261 +			LL_WARNS("Init") << "Unable to set " << init_data[i].mUsage
   1.262 +							 << " concurrency.  Reason:  " << status.toString()
   1.263 +							 << LL_ENDL;
   1.264 +		}
   1.265 +		else
   1.266 +		{
   1.267 +			LL_DEBUGS("Init") << "Changed " << init_data[i].mUsage
   1.268 +							  << " concurrency.  New value:  " << setting
   1.269 +							  << LL_ENDL;
   1.270 +			mSettings[policy] = setting;
   1.271 +			if (initial && setting != init_data[i].mDefault)
   1.272 +			{
   1.273 +				LL_INFOS("Init") << "Application settings overriding default " << init_data[i].mUsage
   1.274 +								 << " concurrency.  New value:  " << setting
   1.275 +								 << LL_ENDL;
   1.276 +			}
   1.277 +		}
   1.278 +	}
   1.279 +}
   1.280 +
   1.281  
   1.282  void LLAppCoreHttp::onCompleted(LLCore::HttpHandle, LLCore::HttpResponse *)
   1.283  {
     2.1 --- a/indra/newview/llappcorehttp.h	Fri Jun 28 17:57:57 2013 -0400
     2.2 +++ b/indra/newview/llappcorehttp.h	Fri Jun 28 20:08:29 2013 -0400
     2.3 @@ -85,16 +85,21 @@
     2.4  		{
     2.5  			return mPolicies[policy];
     2.6  		}
     2.7 +
     2.8 +	// Apply initial or new settings from the environment.
     2.9 +	void refreshSettings(bool initial);
    2.10  	
    2.11  private:
    2.12  	static const F64			MAX_THREAD_WAIT_TIME;
    2.13  	
    2.14  private:
    2.15 -	LLCore::HttpRequest *		mRequest;
    2.16 +	LLCore::HttpRequest *		mRequest;						// Request queue to issue shutdowns
    2.17  	LLCore::HttpHandle			mStopHandle;
    2.18  	F64							mStopRequested;
    2.19  	bool						mStopped;
    2.20 -	policy_t					mPolicies[AP_COUNT];
    2.21 +	policy_t					mPolicies[AP_COUNT];			// Policy class id for each connection set
    2.22 +	U32							mSettings[AP_COUNT];
    2.23 +	boost::signals2::connection mSettingsSignal[AP_COUNT];		// Signals to global settings that affect us
    2.24  };
    2.25  
    2.26  
     3.1 --- a/indra/newview/llmeshrepository.cpp	Fri Jun 28 17:57:57 2013 -0400
     3.2 +++ b/indra/newview/llmeshrepository.cpp	Fri Jun 28 20:08:29 2013 -0400
     3.3 @@ -259,10 +259,9 @@
     3.4  
     3.5  // Static data and functions to measure mesh load
     3.6  // time metrics for a new region scene.
     3.7 -static bool metrics_inited(false);
     3.8 -static boost::signals2::connection metrics_teleport_connection;
     3.9  static unsigned int metrics_teleport_start_count(0);
    3.10 -static void metrics_teleport_started();
    3.11 +boost::signals2::connection metrics_teleport_started_signal;
    3.12 +static void teleport_started();
    3.13  static bool is_retryable(LLCore::HttpStatus status);
    3.14  
    3.15  //get the number of bytes resident in memory for given volume
    3.16 @@ -2667,29 +2666,18 @@
    3.17  		apr_sleep(100);
    3.18  	}
    3.19  
    3.20 -	
    3.21 +	metrics_teleport_started_signal = LLViewerMessage::getInstance()->setTeleportStartedCallback(teleport_started);
    3.22  	
    3.23  	mThread = new LLMeshRepoThread();
    3.24  	mThread->start();
    3.25  
    3.26 -	if (! metrics_inited)
    3.27 -	{
    3.28 -		// Get teleport started signals to restart timings.
    3.29 -		metrics_teleport_connection = LLViewerMessage::getInstance()->
    3.30 -			setTeleportStartedCallback(metrics_teleport_started);
    3.31 -		metrics_inited = true;
    3.32 -	}
    3.33  }
    3.34  
    3.35  void LLMeshRepository::shutdown()
    3.36  {
    3.37  	llinfos << "Shutting down mesh repository." << llendl;
    3.38  
    3.39 -	if (metrics_inited)
    3.40 -	{
    3.41 -		metrics_teleport_connection.disconnect();
    3.42 -		metrics_inited = false;
    3.43 -	}
    3.44 +	metrics_teleport_started_signal.disconnect();
    3.45  
    3.46  	for (U32 i = 0; i < mUploads.size(); ++i)
    3.47  	{
    3.48 @@ -4109,6 +4097,7 @@
    3.49  // static
    3.50  void LLMeshRepository::metricsStart()
    3.51  {
    3.52 +	++metrics_teleport_start_count;
    3.53  	sQuiescentTimer.start(0);
    3.54  }
    3.55  
    3.56 @@ -4127,7 +4116,6 @@
    3.57  
    3.58  	if (first_start)
    3.59  	{
    3.60 -		++metrics_teleport_start_count;
    3.61  		metricsStart();
    3.62  		first_start = false;
    3.63  	}
    3.64 @@ -4157,19 +4145,13 @@
    3.65  	}
    3.66  }
    3.67  
    3.68 -// Will use a request to start a teleport as a signal to
    3.69 -// restart a timing sequence.  We don't get one of these
    3.70 -// for login so initial start is done above.
    3.71 -//
    3.72  // Threading:  main thread only
    3.73  // static
    3.74 -void metrics_teleport_started()
    3.75 +void teleport_started()
    3.76  {
    3.77  	LLMeshRepository::metricsStart();
    3.78 -	++metrics_teleport_start_count;
    3.79  }
    3.80  
    3.81 -
    3.82  // This comes from an edit in viewer-cat.  Unify this once that's
    3.83  // available everywhere.
    3.84  bool is_retryable(LLCore::HttpStatus status)

mercurial