diff options
author | Mic Bowman | 2011-03-28 10:00:53 -0700 |
---|---|---|
committer | Mic Bowman | 2011-04-10 16:57:02 -0700 |
commit | 77cf9405de10f016d85d67b6016ed27d28ed898f (patch) | |
tree | 79b6561b1f9a5d70b40d59147bb2cc155a397b78 /OpenSim/Region/Framework/Scenes | |
parent | minor: remove mono compiler warnings (diff) | |
download | opensim-SC_OLD-77cf9405de10f016d85d67b6016ed27d28ed898f.zip opensim-SC_OLD-77cf9405de10f016d85d67b6016ed27d28ed898f.tar.gz opensim-SC_OLD-77cf9405de10f016d85d67b6016ed27d28ed898f.tar.bz2 opensim-SC_OLD-77cf9405de10f016d85d67b6016ed27d28ed898f.tar.xz |
Implements adaptive queue management and fair queueing for
improved networking performance.
Reprioritization algorithms need to be ported still. One is
in place.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Prioritizer.cs | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index f9599f5..2764b05 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
58 | 58 | ||
59 | public class Prioritizer | 59 | public class Prioritizer |
60 | { | 60 | { |
61 | // private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 61 | private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
62 | 62 | ||
63 | /// <summary> | 63 | /// <summary> |
64 | /// This is added to the priority of all child prims, to make sure that the root prim update is sent to the | 64 | /// This is added to the priority of all child prims, to make sure that the root prim update is sent to the |
@@ -76,7 +76,74 @@ namespace OpenSim.Region.Framework.Scenes | |||
76 | m_scene = scene; | 76 | m_scene = scene; |
77 | } | 77 | } |
78 | 78 | ||
79 | public double GetUpdatePriority(IClientAPI client, ISceneEntity entity) | 79 | //<mic> |
80 | public uint GetUpdatePriority(IClientAPI client, ISceneEntity entity) | ||
81 | { | ||
82 | if (entity == null) | ||
83 | { | ||
84 | m_log.WarnFormat("[PRIORITIZER] attempt to prioritize null entity"); | ||
85 | throw new InvalidOperationException("Prioritization entity not defined"); | ||
86 | } | ||
87 | |||
88 | // If this is an update for our own avatar give it the highest priority | ||
89 | if (client.AgentId == entity.UUID) | ||
90 | return 0; | ||
91 | |||
92 | // Get this agent's position | ||
93 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); | ||
94 | if (presence == null) | ||
95 | { | ||
96 | m_log.WarnFormat("[PRIORITIZER] attempt to prioritize agent no longer in the scene"); | ||
97 | throw new InvalidOperationException("Prioritization agent not defined"); | ||
98 | } | ||
99 | |||
100 | // Use group position for child prims | ||
101 | Vector3 entityPos = entity.AbsolutePosition; | ||
102 | if (entity is SceneObjectPart) | ||
103 | { | ||
104 | SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; | ||
105 | if (group != null) | ||
106 | entityPos = group.AbsolutePosition; | ||
107 | } | ||
108 | |||
109 | // Use the camera position for local agents and avatar position for remote agents | ||
110 | Vector3 presencePos = (presence.IsChildAgent) ? | ||
111 | presence.AbsolutePosition : | ||
112 | presence.CameraPosition; | ||
113 | |||
114 | // Compute the distance... | ||
115 | double distance = Vector3.Distance(presencePos, entityPos); | ||
116 | |||
117 | // And convert the distance to a priority queue, this computation gives queues | ||
118 | // at 10, 20, 40, 80, 160, 320, 640, and 1280m | ||
119 | uint pqueue = 1; | ||
120 | for (int i = 0; i < 8; i++) | ||
121 | { | ||
122 | if (distance < 10 * Math.Pow(2.0,i)) | ||
123 | break; | ||
124 | pqueue++; | ||
125 | } | ||
126 | |||
127 | // If this is a root agent, then determine front & back | ||
128 | // Bump up the priority queue for any objects behind the avatar | ||
129 | if (! presence.IsChildAgent) | ||
130 | { | ||
131 | // Root agent, decrease priority for objects behind us | ||
132 | Vector3 camPosition = presence.CameraPosition; | ||
133 | Vector3 camAtAxis = presence.CameraAtAxis; | ||
134 | |||
135 | // Plane equation | ||
136 | float d = -Vector3.Dot(camPosition, camAtAxis); | ||
137 | float p = Vector3.Dot(camAtAxis, entityPos) + d; | ||
138 | if (p < 0.0f) | ||
139 | pqueue++; | ||
140 | } | ||
141 | |||
142 | return pqueue; | ||
143 | } | ||
144 | //</mic> | ||
145 | |||
146 | public double bGetUpdatePriority(IClientAPI client, ISceneEntity entity) | ||
80 | { | 147 | { |
81 | double priority = 0; | 148 | double priority = 0; |
82 | 149 | ||