From b9b483151fe6bc6b11c8181718c8a39e005cb41b Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Sep 2014 21:29:27 +0100
Subject: Eliminate a few unnecessary calculations in the maintenance loop.
Also uses wait event instead of sleep for periodicity control.
---
OpenSim/Region/Framework/Scenes/Scene.cs | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Region/Framework')
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
public float MinFrameSeconds { get; private set; }
///
- /// The minimum length of time in seconds that will be taken for a maintenance run.
+ /// The minimum length of time in milliseconds that will be taken for a scene frame. If the frame takes less time then we
+ /// will sleep for the remaining period.
///
- public float MinMaintenanceTime { get; private set; }
+ ///
+ /// One can tweak this number to experiment. One current effect of reducing it is to make avatar animations
+ /// occur too quickly (viewer 1) or with even more slide (viewer 2).
+ ///
+ public int MinMaintenanceTicks { get; set; }
private int m_update_physics = 1;
private int m_update_entitymovement = 1;
@@ -435,6 +440,11 @@ namespace OpenSim.Region.Framework.Scenes
///
private ManualResetEvent m_updateWaitEvent = new ManualResetEvent(false);
+ ///
+ /// Used to control maintenance thread runs.
+ ///
+ private ManualResetEvent m_maintenanceWaitEvent = new ManualResetEvent(false);
+
// TODO: Possibly stop other classes being able to manipulate this directly.
private SceneGraph m_sceneGraph;
private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
@@ -803,7 +813,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_config = config;
MinFrameTicks = 89;
- MinMaintenanceTime = 1;
+ MinMaintenanceTicks = 1000;
SeeIntoRegion = true;
Random random = new Random();
@@ -1571,19 +1581,19 @@ namespace OpenSim.Region.Framework.Scenes
previousMaintenanceTick = m_lastMaintenanceTick;
m_lastMaintenanceTick = Util.EnvironmentTickCount();
runtc = Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, runtc);
- runtc = (int)(MinMaintenanceTime * 1000) - runtc;
+ runtc = MinMaintenanceTicks - runtc;
if (runtc > 0)
- Thread.Sleep(runtc);
+ m_maintenanceWaitEvent.WaitOne(runtc);
// Optionally warn if a frame takes double the amount of time that it should.
if (DebugUpdates
&& Util.EnvironmentTickCountSubtract(
- m_lastMaintenanceTick, previousMaintenanceTick) > (int)(MinMaintenanceTime * 1000 * 2))
+ m_lastMaintenanceTick, previousMaintenanceTick) > MinMaintenanceTicks * 2)
m_log.WarnFormat(
"[SCENE]: Maintenance took {0} ms (desired max {1} ms) in {2}",
Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, previousMaintenanceTick),
- MinMaintenanceTime * 1000,
+ MinMaintenanceTicks,
RegionInfo.RegionName);
}
}
--
cgit v1.1