diff options
author | Justin Clark-Casey (justincc) | 2014-09-26 21:29:27 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-11-25 23:18:38 +0000 |
commit | b9b483151fe6bc6b11c8181718c8a39e005cb41b (patch) | |
tree | fd483712ca1c063db0b86b55e595ee7200484f89 | |
parent | Fix recent minor regression where the default frame time wasn't being set if ... (diff) | |
download | opensim-SC_OLD-b9b483151fe6bc6b11c8181718c8a39e005cb41b.zip opensim-SC_OLD-b9b483151fe6bc6b11c8181718c8a39e005cb41b.tar.gz opensim-SC_OLD-b9b483151fe6bc6b11c8181718c8a39e005cb41b.tar.bz2 opensim-SC_OLD-b9b483151fe6bc6b11c8181718c8a39e005cb41b.tar.xz |
Eliminate a few unnecessary calculations in the maintenance loop.
Also uses wait event instead of sleep for periodicity control.
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index dc2f0bc..9c4aea0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -387,9 +387,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
387 | public float MinFrameSeconds { get; private set; } | 387 | public float MinFrameSeconds { get; private set; } |
388 | 388 | ||
389 | /// <summary> | 389 | /// <summary> |
390 | /// The minimum length of time in seconds that will be taken for a maintenance run. | 390 | /// The minimum length of time in milliseconds that will be taken for a scene frame. If the frame takes less time then we |
391 | /// will sleep for the remaining period. | ||
391 | /// </summary> | 392 | /// </summary> |
392 | public float MinMaintenanceTime { get; private set; } | 393 | /// <remarks> |
394 | /// One can tweak this number to experiment. One current effect of reducing it is to make avatar animations | ||
395 | /// occur too quickly (viewer 1) or with even more slide (viewer 2). | ||
396 | /// </remarks> | ||
397 | public int MinMaintenanceTicks { get; set; } | ||
393 | 398 | ||
394 | private int m_update_physics = 1; | 399 | private int m_update_physics = 1; |
395 | private int m_update_entitymovement = 1; | 400 | private int m_update_entitymovement = 1; |
@@ -435,6 +440,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
435 | /// </summary> | 440 | /// </summary> |
436 | private ManualResetEvent m_updateWaitEvent = new ManualResetEvent(false); | 441 | private ManualResetEvent m_updateWaitEvent = new ManualResetEvent(false); |
437 | 442 | ||
443 | /// <summary> | ||
444 | /// Used to control maintenance thread runs. | ||
445 | /// </summary> | ||
446 | private ManualResetEvent m_maintenanceWaitEvent = new ManualResetEvent(false); | ||
447 | |||
438 | // TODO: Possibly stop other classes being able to manipulate this directly. | 448 | // TODO: Possibly stop other classes being able to manipulate this directly. |
439 | private SceneGraph m_sceneGraph; | 449 | private SceneGraph m_sceneGraph; |
440 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 450 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
@@ -803,7 +813,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
803 | { | 813 | { |
804 | m_config = config; | 814 | m_config = config; |
805 | MinFrameTicks = 89; | 815 | MinFrameTicks = 89; |
806 | MinMaintenanceTime = 1; | 816 | MinMaintenanceTicks = 1000; |
807 | SeeIntoRegion = true; | 817 | SeeIntoRegion = true; |
808 | 818 | ||
809 | Random random = new Random(); | 819 | Random random = new Random(); |
@@ -1571,19 +1581,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1571 | previousMaintenanceTick = m_lastMaintenanceTick; | 1581 | previousMaintenanceTick = m_lastMaintenanceTick; |
1572 | m_lastMaintenanceTick = Util.EnvironmentTickCount(); | 1582 | m_lastMaintenanceTick = Util.EnvironmentTickCount(); |
1573 | runtc = Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, runtc); | 1583 | runtc = Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, runtc); |
1574 | runtc = (int)(MinMaintenanceTime * 1000) - runtc; | 1584 | runtc = MinMaintenanceTicks - runtc; |
1575 | 1585 | ||
1576 | if (runtc > 0) | 1586 | if (runtc > 0) |
1577 | Thread.Sleep(runtc); | 1587 | m_maintenanceWaitEvent.WaitOne(runtc); |
1578 | 1588 | ||
1579 | // Optionally warn if a frame takes double the amount of time that it should. | 1589 | // Optionally warn if a frame takes double the amount of time that it should. |
1580 | if (DebugUpdates | 1590 | if (DebugUpdates |
1581 | && Util.EnvironmentTickCountSubtract( | 1591 | && Util.EnvironmentTickCountSubtract( |
1582 | m_lastMaintenanceTick, previousMaintenanceTick) > (int)(MinMaintenanceTime * 1000 * 2)) | 1592 | m_lastMaintenanceTick, previousMaintenanceTick) > MinMaintenanceTicks * 2) |
1583 | m_log.WarnFormat( | 1593 | m_log.WarnFormat( |
1584 | "[SCENE]: Maintenance took {0} ms (desired max {1} ms) in {2}", | 1594 | "[SCENE]: Maintenance took {0} ms (desired max {1} ms) in {2}", |
1585 | Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, previousMaintenanceTick), | 1595 | Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, previousMaintenanceTick), |
1586 | MinMaintenanceTime * 1000, | 1596 | MinMaintenanceTicks, |
1587 | RegionInfo.RegionName); | 1597 | RegionInfo.RegionName); |
1588 | } | 1598 | } |
1589 | } | 1599 | } |