aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2012-02-18 21:59:42 -0800
committerDiva Canto2012-02-18 21:59:42 -0800
commit2ffc055f7ead4e6b07b82bcc47748295595d350d (patch)
tree428145bf813a00aa63ba4a2cf9199481c3d33504
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-2ffc055f7ead4e6b07b82bcc47748295595d350d.zip
opensim-SC_OLD-2ffc055f7ead4e6b07b82bcc47748295595d350d.tar.gz
opensim-SC_OLD-2ffc055f7ead4e6b07b82bcc47748295595d350d.tar.bz2
opensim-SC_OLD-2ffc055f7ead4e6b07b82bcc47748295595d350d.tar.xz
This should smooth movement in heteregeneous networks by a lot: cache the region by position instead of looking it up all the time -- this was being done during the main update loop!
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs34
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs8
2 files changed, 40 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs
index 786e0b5..be8a9a2 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs
@@ -65,13 +65,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
65 } 65 }
66 } 66 }
67 67
68 internal struct ScopedRegionPosition
69 {
70 public UUID m_scopeID;
71 public ulong m_regionHandle;
72 public ScopedRegionPosition(UUID scopeID, ulong handle)
73 {
74 m_scopeID = scopeID;
75 m_regionHandle = handle;
76 }
77 }
78
68 private ExpiringCache<ScopedRegionUUID, GridRegion> m_UUIDCache; 79 private ExpiringCache<ScopedRegionUUID, GridRegion> m_UUIDCache;
69 private ExpiringCache<ScopedRegionName, ScopedRegionUUID> m_NameCache; 80 private ExpiringCache<ScopedRegionName, ScopedRegionUUID> m_NameCache;
81 private ExpiringCache<ScopedRegionPosition, GridRegion> m_PositionCache;
70 82
71 public RegionInfoCache() 83 public RegionInfoCache()
72 { 84 {
73 m_UUIDCache = new ExpiringCache<ScopedRegionUUID, GridRegion>(); 85 m_UUIDCache = new ExpiringCache<ScopedRegionUUID, GridRegion>();
74 m_NameCache = new ExpiringCache<ScopedRegionName, ScopedRegionUUID>(); 86 m_NameCache = new ExpiringCache<ScopedRegionName, ScopedRegionUUID>();
87 m_PositionCache = new ExpiringCache<ScopedRegionPosition, GridRegion>();
75 } 88 }
76 89
77 public void Cache(GridRegion rinfo) 90 public void Cache(GridRegion rinfo)
@@ -96,6 +109,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
96 { 109 {
97 ScopedRegionName name = new ScopedRegionName(scopeID,rinfo.RegionName); 110 ScopedRegionName name = new ScopedRegionName(scopeID,rinfo.RegionName);
98 m_NameCache.AddOrUpdate(name, id, CACHE_EXPIRATION_SECONDS); 111 m_NameCache.AddOrUpdate(name, id, CACHE_EXPIRATION_SECONDS);
112
113 ScopedRegionPosition pos = new ScopedRegionPosition(scopeID, rinfo.RegionHandle);
114 m_PositionCache.AddOrUpdate(pos, rinfo, CACHE_EXPIRATION_SECONDS);
99 } 115 }
100 } 116 }
101 117
@@ -114,6 +130,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
114 return null; 130 return null;
115 } 131 }
116 132
133 public GridRegion Get(UUID scopeID, ulong handle, out bool inCache)
134 {
135 inCache = false;
136
137 GridRegion rinfo = null;
138 ScopedRegionPosition pos = new ScopedRegionPosition(scopeID, handle);
139 if (m_PositionCache.TryGetValue(pos, out rinfo))
140 {
141 inCache = true;
142 return rinfo;
143 }
144
145 return null;
146 }
147
148
117 public GridRegion Get(UUID scopeID, string name, out bool inCache) 149 public GridRegion Get(UUID scopeID, string name, out bool inCache)
118 { 150 {
119 inCache = false; 151 inCache = false;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index 6f364ae..e6c89d7 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -186,10 +186,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
186 186
187 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 187 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
188 { 188 {
189 GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); 189 bool inCache = false;
190 GridRegion rinfo = m_RegionInfoCache.Get(scopeID, Util.UIntsToLong((uint)x, (uint)y), out inCache);
191 if (inCache)
192 return rinfo;
193
194 rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
190 if (rinfo == null) 195 if (rinfo == null)
191 rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y); 196 rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y);
192 197
198 m_RegionInfoCache.Cache(rinfo);
193 return rinfo; 199 return rinfo;
194 } 200 }
195 201