diff options
author | Dan Lake | 2010-06-08 16:30:51 -0700 |
---|---|---|
committer | John Hurliman | 2010-06-08 16:44:18 -0700 |
commit | ca2abc43ad440a99f17b43d32de89e77fdeef00e (patch) | |
tree | ac8787b8db9c38d4875cc4123245006084e35609 | |
parent | Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-ca2abc43ad440a99f17b43d32de89e77fdeef00e.zip opensim-SC-ca2abc43ad440a99f17b43d32de89e77fdeef00e.tar.gz opensim-SC-ca2abc43ad440a99f17b43d32de89e77fdeef00e.tar.bz2 opensim-SC-ca2abc43ad440a99f17b43d32de89e77fdeef00e.tar.xz |
Refactor SendCoarseLocations for better performance. Instead of computing list of all locations fresh for every scene presence on every frame, we will instead compute the list once every 50 frames and send to all connected presences at that time. Also, we only add 60 items to the list when there are more than 60 presences in the scene. For 1000 users, this change yields a 99.8% reduction in list processing and a 98% reduction in network bandwidth for coarse locations.
Diffstat (limited to '')
6 files changed, 59 insertions, 67 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 66631b5..fc5bb28 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -3426,7 +3426,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3426 | CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); | 3426 | CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); |
3427 | loc.Header.Reliable = false; | 3427 | loc.Header.Reliable = false; |
3428 | 3428 | ||
3429 | // Each packet can only hold around 62 avatar positions and the client clears the mini-map each time | 3429 | // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time |
3430 | // a CoarseLocationUpdate packet is received. Oh well. | 3430 | // a CoarseLocationUpdate packet is received. Oh well. |
3431 | int total = Math.Min(CoarseLocations.Count, 60); | 3431 | int total = Math.Min(CoarseLocations.Count, 60); |
3432 | 3432 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 1e3e0c9..0707119 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -865,9 +865,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
865 | 865 | ||
866 | CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); | 866 | CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); |
867 | 867 | ||
868 | // m_scene.SendKillObject(m_localId); | ||
869 | |||
870 | agent.Scene.NotifyMyCoarseLocationChange(); | ||
871 | // the user may change their profile information in other region, | 868 | // the user may change their profile information in other region, |
872 | // so the userinfo in UserProfileCache is not reliable any more, delete it | 869 | // so the userinfo in UserProfileCache is not reliable any more, delete it |
873 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | 870 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4e90d09..9a3b0c9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -348,6 +348,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
348 | private int m_update_backup = 200; | 348 | private int m_update_backup = 200; |
349 | private int m_update_terrain = 50; | 349 | private int m_update_terrain = 50; |
350 | private int m_update_land = 1; | 350 | private int m_update_land = 1; |
351 | private int m_update_coarse_locations = 50; | ||
351 | 352 | ||
352 | private int frameMS; | 353 | private int frameMS; |
353 | private int physicsMS2; | 354 | private int physicsMS2; |
@@ -1417,6 +1418,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1417 | if (m_frame % m_update_presences == 0) | 1418 | if (m_frame % m_update_presences == 0) |
1418 | m_sceneGraph.UpdatePresences(); | 1419 | m_sceneGraph.UpdatePresences(); |
1419 | 1420 | ||
1421 | if (m_frame % m_update_coarse_locations == 0) | ||
1422 | { | ||
1423 | List<Vector3> coarseLocations; | ||
1424 | List<UUID> avatarUUIDs; | ||
1425 | SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60); | ||
1426 | // Send coarse locations to clients | ||
1427 | ForEachScenePresence(delegate(ScenePresence presence) | ||
1428 | { | ||
1429 | presence.SendCoarseLocations(coarseLocations, avatarUUIDs); | ||
1430 | }); | ||
1431 | } | ||
1432 | |||
1420 | int tmpPhysicsMS2 = Util.EnvironmentTickCount(); | 1433 | int tmpPhysicsMS2 = Util.EnvironmentTickCount(); |
1421 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) | 1434 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) |
1422 | m_sceneGraph.UpdatePreparePhysics(); | 1435 | m_sceneGraph.UpdatePreparePhysics(); |
@@ -3301,9 +3314,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3301 | catch (NullReferenceException) { } | 3314 | catch (NullReferenceException) { } |
3302 | }); | 3315 | }); |
3303 | 3316 | ||
3304 | ForEachScenePresence( | ||
3305 | delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); | ||
3306 | |||
3307 | IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); | 3317 | IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); |
3308 | if (agentTransactions != null) | 3318 | if (agentTransactions != null) |
3309 | { | 3319 | { |
@@ -3355,14 +3365,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3355 | } | 3365 | } |
3356 | } | 3366 | } |
3357 | 3367 | ||
3358 | /// <summary> | ||
3359 | /// Inform all other ScenePresences on this Scene that someone else has changed position on the minimap. | ||
3360 | /// </summary> | ||
3361 | public void NotifyMyCoarseLocationChange() | ||
3362 | { | ||
3363 | ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); | ||
3364 | } | ||
3365 | |||
3366 | #endregion | 3368 | #endregion |
3367 | 3369 | ||
3368 | #region Entities | 3370 | #region Entities |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 5902080..673674d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -206,6 +206,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
206 | }); | 206 | }); |
207 | } | 207 | } |
208 | 208 | ||
209 | public void GetCoarseLocations(out List<Vector3> coarseLocations, out List<UUID> avatarUUIDs, uint maxLocations) | ||
210 | { | ||
211 | coarseLocations = new List<Vector3>(); | ||
212 | avatarUUIDs = new List<UUID>(); | ||
213 | |||
214 | List<ScenePresence> presences = GetScenePresences(); | ||
215 | for (int i = 0; i < Math.Min(presences.Count, maxLocations); ++i) | ||
216 | { | ||
217 | ScenePresence sp = presences[i]; | ||
218 | // If this presence is a child agent, we don't want its coarse locations | ||
219 | if (sp.IsChildAgent) | ||
220 | return; | ||
221 | |||
222 | if (sp.ParentID != 0) | ||
223 | { | ||
224 | // sitting avatar | ||
225 | SceneObjectPart sop = m_parentScene.GetSceneObjectPart(sp.ParentID); | ||
226 | if (sop != null) | ||
227 | { | ||
228 | coarseLocations.Add(sop.AbsolutePosition + sp.AbsolutePosition); | ||
229 | avatarUUIDs.Add(sp.UUID); | ||
230 | } | ||
231 | else | ||
232 | { | ||
233 | // we can't find the parent.. ! arg! | ||
234 | coarseLocations.Add(sp.AbsolutePosition); | ||
235 | avatarUUIDs.Add(sp.UUID); | ||
236 | } | ||
237 | } | ||
238 | else | ||
239 | { | ||
240 | coarseLocations.Add(sp.AbsolutePosition); | ||
241 | avatarUUIDs.Add(sp.UUID); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | |||
209 | #endregion | 246 | #endregion |
210 | 247 | ||
211 | #region Entity Methods | 248 | #region Entity Methods |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 45375b0..15b9446 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
65 | public ScriptControlled eventControls; | 65 | public ScriptControlled eventControls; |
66 | } | 66 | } |
67 | 67 | ||
68 | public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence); | 68 | public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs); |
69 | 69 | ||
70 | public class ScenePresence : EntityBase, ISceneEntity | 70 | public class ScenePresence : EntityBase, ISceneEntity |
71 | { | 71 | { |
@@ -173,8 +173,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
173 | 173 | ||
174 | public string JID = String.Empty; | 174 | public string JID = String.Empty; |
175 | 175 | ||
176 | // Agent moves with a PID controller causing a force to be exerted. | ||
177 | private bool m_newCoarseLocations = true; | ||
178 | private float m_health = 100f; | 176 | private float m_health = 100f; |
179 | 177 | ||
180 | // Default AV Height | 178 | // Default AV Height |
@@ -2296,12 +2294,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2296 | 2294 | ||
2297 | SendPrimUpdates(); | 2295 | SendPrimUpdates(); |
2298 | 2296 | ||
2299 | if (m_newCoarseLocations) | ||
2300 | { | ||
2301 | SendCoarseLocations(); | ||
2302 | m_newCoarseLocations = false; | ||
2303 | } | ||
2304 | |||
2305 | if (m_isChildAgent == false) | 2297 | if (m_isChildAgent == false) |
2306 | { | 2298 | { |
2307 | // PhysicsActor actor = m_physicsActor; | 2299 | // PhysicsActor actor = m_physicsActor; |
@@ -2375,12 +2367,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2375 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2367 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2376 | } | 2368 | } |
2377 | 2369 | ||
2378 | public void SendCoarseLocations() | 2370 | public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
2379 | { | 2371 | { |
2380 | SendCourseLocationsMethod d = m_sendCourseLocationsMethod; | 2372 | SendCourseLocationsMethod d = m_sendCourseLocationsMethod; |
2381 | if (d != null) | 2373 | if (d != null) |
2382 | { | 2374 | { |
2383 | d.Invoke(m_scene.RegionInfo.originRegionID, this); | 2375 | d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs); |
2384 | } | 2376 | } |
2385 | } | 2377 | } |
2386 | 2378 | ||
@@ -2390,50 +2382,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2390 | m_sendCourseLocationsMethod = d; | 2382 | m_sendCourseLocationsMethod = d; |
2391 | } | 2383 | } |
2392 | 2384 | ||
2393 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p) | 2385 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
2394 | { | 2386 | { |
2395 | m_perfMonMS = Util.EnvironmentTickCount(); | 2387 | m_perfMonMS = Util.EnvironmentTickCount(); |
2396 | 2388 | m_controllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); | |
2397 | List<Vector3> CoarseLocations = new List<Vector3>(); | ||
2398 | List<UUID> AvatarUUIDs = new List<UUID>(); | ||
2399 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) | ||
2400 | { | ||
2401 | if (sp.IsChildAgent) | ||
2402 | return; | ||
2403 | |||
2404 | if (sp.ParentID != 0) | ||
2405 | { | ||
2406 | // sitting avatar | ||
2407 | SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID); | ||
2408 | if (sop != null) | ||
2409 | { | ||
2410 | CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos); | ||
2411 | AvatarUUIDs.Add(sp.UUID); | ||
2412 | } | ||
2413 | else | ||
2414 | { | ||
2415 | // we can't find the parent.. ! arg! | ||
2416 | CoarseLocations.Add(sp.m_pos); | ||
2417 | AvatarUUIDs.Add(sp.UUID); | ||
2418 | } | ||
2419 | } | ||
2420 | else | ||
2421 | { | ||
2422 | CoarseLocations.Add(sp.m_pos); | ||
2423 | AvatarUUIDs.Add(sp.UUID); | ||
2424 | } | ||
2425 | }); | ||
2426 | |||
2427 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); | ||
2428 | |||
2429 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2389 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2430 | } | 2390 | } |
2431 | 2391 | ||
2432 | public void CoarseLocationChange() | ||
2433 | { | ||
2434 | m_newCoarseLocations = true; | ||
2435 | } | ||
2436 | |||
2437 | /// <summary> | 2392 | /// <summary> |
2438 | /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) | 2393 | /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) |
2439 | /// </summary> | 2394 | /// </summary> |
@@ -2668,7 +2623,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2668 | { | 2623 | { |
2669 | posLastSignificantMove = AbsolutePosition; | 2624 | posLastSignificantMove = AbsolutePosition; |
2670 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); | 2625 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); |
2671 | m_scene.NotifyMyCoarseLocationChange(); | ||
2672 | } | 2626 | } |
2673 | 2627 | ||
2674 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m | 2628 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m |
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 9cb349a..ff0e743 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | |||
@@ -696,7 +696,9 @@ namespace OpenSim.Region.RegionCombinerModule | |||
696 | presence.SetSendCourseLocationMethod(SendCourseLocationUpdates); | 696 | presence.SetSendCourseLocationMethod(SendCourseLocationUpdates); |
697 | } | 697 | } |
698 | 698 | ||
699 | private void SendCourseLocationUpdates(UUID sceneId, ScenePresence presence) | 699 | // This delegate was refactored for non-combined regions. |
700 | // This combined region version will not use the pre-compiled lists of locations and ids | ||
701 | private void SendCourseLocationUpdates(UUID sceneId, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) | ||
700 | { | 702 | { |
701 | RegionConnections connectiondata = null; | 703 | RegionConnections connectiondata = null; |
702 | lock (m_regions) | 704 | lock (m_regions) |