aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2012-03-23 02:46:49 +0000
committerMelanie2012-03-23 02:46:49 +0000
commitfac89b66718990e4beda8280c5a7a2c84479db2b (patch)
treec786226e0ea2d39348e3598641af9cb9e91c5e58
parentMerge branch 'master' into careminster (diff)
parentAdd a scene maintenance thread in parallel to the heartbeat thread. The main... (diff)
downloadopensim-SC_OLD-fac89b66718990e4beda8280c5a7a2c84479db2b.zip
opensim-SC_OLD-fac89b66718990e4beda8280c5a7a2c84479db2b.tar.gz
opensim-SC_OLD-fac89b66718990e4beda8280c5a7a2c84479db2b.tar.bz2
opensim-SC_OLD-fac89b66718990e4beda8280c5a7a2c84479db2b.tar.xz
Merge branch 'master' into careminster
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs91
1 files changed, 77 insertions, 14 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 34ad58a..6e70c36 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -172,6 +172,11 @@ namespace OpenSim.Region.Framework.Scenes
172 } 172 }
173 173
174 /// <summary> 174 /// <summary>
175 /// Current maintenance run number
176 /// </summary>
177 public uint MaintenanceRun { get; private set; }
178
179 /// <summary>
175 /// The minimum length of time in seconds that will be taken for a scene frame. If the frame takes less time then we 180 /// The minimum length of time in seconds that will be taken for a scene frame. If the frame takes less time then we
176 /// will sleep for the remaining period. 181 /// will sleep for the remaining period.
177 /// </summary> 182 /// </summary>
@@ -181,6 +186,11 @@ namespace OpenSim.Region.Framework.Scenes
181 /// </remarks> 186 /// </remarks>
182 public float MinFrameTime { get; private set; } 187 public float MinFrameTime { get; private set; }
183 188
189 /// <summary>
190 /// The minimum length of time in seconds that will be taken for a maintenance run.
191 /// </summary>
192 public float MinMaintenanceTime { get; private set; }
193
184 private int m_update_physics = 1; 194 private int m_update_physics = 1;
185 private int m_update_entitymovement = 1; 195 private int m_update_entitymovement = 1;
186 private int m_update_objects = 1; 196 private int m_update_objects = 1;
@@ -210,6 +220,11 @@ namespace OpenSim.Region.Framework.Scenes
210 220
211 public bool CombineRegions = false; 221 public bool CombineRegions = false;
212 /// <summary> 222 /// <summary>
223 /// Tick at which the last maintenance run occurred.
224 /// </summary>
225 private int m_lastMaintenanceTick;
226
227 /// <summary>
213 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched 228 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched
214 /// asynchronously from the update loop. 229 /// asynchronously from the update loop.
215 /// </summary> 230 /// </summary>
@@ -582,6 +597,7 @@ namespace OpenSim.Region.Framework.Scenes
582 { 597 {
583 m_config = config; 598 m_config = config;
584 MinFrameTime = 0.089f; 599 MinFrameTime = 0.089f;
600 MinMaintenanceTime = 1;
585 601
586 Random random = new Random(); 602 Random random = new Random();
587 603
@@ -1275,6 +1291,10 @@ namespace OpenSim.Region.Framework.Scenes
1275 // don't turn on the watchdog alarm for this thread until the second frame, in order to prevent false 1291 // don't turn on the watchdog alarm for this thread until the second frame, in order to prevent false
1276 // alarms for scenes with many objects. 1292 // alarms for scenes with many objects.
1277 Update(1); 1293 Update(1);
1294
1295 Watchdog.StartThread(
1296 Maintenance, string.Format("Maintenance ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, true);
1297
1278 Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true; 1298 Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true;
1279 Update(-1); 1299 Update(-1);
1280 1300
@@ -1290,6 +1310,63 @@ namespace OpenSim.Region.Framework.Scenes
1290 Watchdog.RemoveThread(); 1310 Watchdog.RemoveThread();
1291 } 1311 }
1292 1312
1313 private void Maintenance()
1314 {
1315 DoMaintenance(-1);
1316
1317 Watchdog.RemoveThread();
1318 }
1319
1320 public void DoMaintenance(int runs)
1321 {
1322 long? endRun = null;
1323 int runtc;
1324 int previousMaintenanceTick;
1325
1326 if (runs >= 0)
1327 endRun = MaintenanceRun + runs;
1328
1329 List<Vector3> coarseLocations;
1330 List<UUID> avatarUUIDs;
1331
1332 while (!m_shuttingDown && (endRun == null || MaintenanceRun < endRun))
1333 {
1334 runtc = Util.EnvironmentTickCount();
1335 ++MaintenanceRun;
1336
1337 // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
1338 if (MaintenanceRun % (m_update_coarse_locations / 10) == 0)
1339 {
1340 SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
1341 // Send coarse locations to clients
1342 ForEachScenePresence(delegate(ScenePresence presence)
1343 {
1344 presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
1345 });
1346 }
1347
1348 Watchdog.UpdateThread();
1349
1350 previousMaintenanceTick = m_lastMaintenanceTick;
1351 m_lastMaintenanceTick = Util.EnvironmentTickCount();
1352 runtc = Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, runtc);
1353 runtc = (int)(MinMaintenanceTime * 1000) - runtc;
1354
1355 if (runtc > 0)
1356 Thread.Sleep(runtc);
1357
1358 // Optionally warn if a frame takes double the amount of time that it should.
1359 if (DebugUpdates
1360 && Util.EnvironmentTickCountSubtract(
1361 m_lastMaintenanceTick, previousMaintenanceTick) > (int)(MinMaintenanceTime * 1000 * 2))
1362 m_log.WarnFormat(
1363 "[SCENE]: Maintenance took {0} ms (desired max {1} ms) in {2}",
1364 Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, previousMaintenanceTick),
1365 MinMaintenanceTime * 1000,
1366 RegionInfo.RegionName);
1367 }
1368 }
1369
1293 public override void Update(int frames) 1370 public override void Update(int frames)
1294 { 1371 {
1295 long? endFrame = null; 1372 long? endFrame = null;
@@ -1301,8 +1378,6 @@ namespace OpenSim.Region.Framework.Scenes
1301 int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; 1378 int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS;
1302 int previousFrameTick; 1379 int previousFrameTick;
1303 int maintc; 1380 int maintc;
1304 List<Vector3> coarseLocations;
1305 List<UUID> avatarUUIDs;
1306 1381
1307 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1382 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1308 { 1383 {
@@ -1354,17 +1429,6 @@ namespace OpenSim.Region.Framework.Scenes
1354 if (Frame % m_update_presences == 0) 1429 if (Frame % m_update_presences == 0)
1355 m_sceneGraph.UpdatePresences(); 1430 m_sceneGraph.UpdatePresences();
1356 1431
1357 // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
1358 if (Frame % m_update_coarse_locations == 0)
1359 {
1360 SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
1361 // Send coarse locations to clients
1362 ForEachScenePresence(delegate(ScenePresence presence)
1363 {
1364 presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
1365 });
1366 }
1367
1368 agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS); 1432 agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS);
1369 1433
1370 // Delete temp-on-rez stuff 1434 // Delete temp-on-rez stuff
@@ -1472,7 +1536,6 @@ namespace OpenSim.Region.Framework.Scenes
1472 1536
1473 EventManager.TriggerRegionHeartbeatEnd(this); 1537 EventManager.TriggerRegionHeartbeatEnd(this);
1474 1538
1475 // Tell the watchdog that this thread is still alive
1476 Watchdog.UpdateThread(); 1539 Watchdog.UpdateThread();
1477 1540
1478 previousFrameTick = m_lastFrameTick; 1541 previousFrameTick = m_lastFrameTick;