aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie Thielker2009-05-02 00:14:04 +0000
committerMelanie Thielker2009-05-02 00:14:04 +0000
commitac944def3fbea9cbad58780e3996e4c586237ab5 (patch)
tree3c8551f27e2d3ef7d19011575ab9f77464d1b08d /OpenSim
parentAdd a tweakable for the prim queue preload (diff)
downloadopensim-SC-ac944def3fbea9cbad58780e3996e4c586237ab5.zip
opensim-SC-ac944def3fbea9cbad58780e3996e4c586237ab5.tar.gz
opensim-SC-ac944def3fbea9cbad58780e3996e4c586237ab5.tar.bz2
opensim-SC-ac944def3fbea9cbad58780e3996e4c586237ab5.tar.xz
Fix the issue that stopped the packet pool from working. Add a mechanism
to recycley data blocs within a packet. Recycle the ObjectUpdate* data blocks. Speeds up loading even more. This may mean that the packet pool is now viable.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/PacketPool.cs66
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs13
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs2
4 files changed, 77 insertions, 10 deletions
diff --git a/OpenSim/Framework/PacketPool.cs b/OpenSim/Framework/PacketPool.cs
index a4f7d96..4d9591e 100644
--- a/OpenSim/Framework/PacketPool.cs
+++ b/OpenSim/Framework/PacketPool.cs
@@ -34,6 +34,7 @@ using log4net;
34 34
35namespace OpenSim.Framework 35namespace OpenSim.Framework
36{ 36{
37
37 public sealed class PacketPool 38 public sealed class PacketPool
38 { 39 {
39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -44,6 +45,9 @@ namespace OpenSim.Framework
44 45
45 private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>(); 46 private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>();
46 47
48 private static Dictionary<Type, List<Object>> DataBlocks =
49 new Dictionary<Type, List<Object>>();
50
47 static PacketPool() 51 static PacketPool()
48 { 52 {
49 } 53 }
@@ -136,6 +140,28 @@ namespace OpenSim.Framework
136 /// <param name="packet"></param> 140 /// <param name="packet"></param>
137 public void ReturnPacket(Packet packet) 141 public void ReturnPacket(Packet packet)
138 { 142 {
143 switch (packet.Type)
144 {
145 case PacketType.ObjectUpdate:
146 ObjectUpdatePacket oup = (ObjectUpdatePacket)packet;
147
148 foreach (ObjectUpdatePacket.ObjectDataBlock oupod in
149 oup.ObjectData)
150 ReturnDataBlock<ObjectUpdatePacket.ObjectDataBlock>(oupod);
151 oup.ObjectData = null;
152 break;
153
154 case PacketType.ImprovedTerseObjectUpdate:
155 ImprovedTerseObjectUpdatePacket itoup =
156 (ImprovedTerseObjectUpdatePacket)packet;
157
158 foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock
159 itoupod in itoup.ObjectData)
160 ReturnDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(itoupod);
161 itoup.ObjectData = null;
162 break;
163 }
164
139 if (!packetPoolEnabled) 165 if (!packetPoolEnabled)
140 return; 166 return;
141 167
@@ -163,5 +189,45 @@ namespace OpenSim.Framework
163 return; 189 return;
164 } 190 }
165 } 191 }
192
193 public static T GetDataBlock<T>() where T: new()
194 {
195 lock(DataBlocks)
196 {
197 if (DataBlocks.ContainsKey(typeof(T)) && DataBlocks[typeof(T)].Count > 0)
198 {
199 T block = (T)DataBlocks[typeof(T)][0];
200 DataBlocks[typeof(T)].RemoveAt(0);
201 if (block == null)
202 return new T();
203 return block;
204 }
205 else
206 {
207 return new T();
208 }
209 }
210 }
211
212 public static void ReturnDataBlock<T>(T block) where T: new()
213 {
214 if (block == null)
215 return;
216
217 lock (DataBlocks)
218 {
219 if (!DataBlocks.ContainsKey(typeof(T)))
220 {
221 List<Object> l = new List<Object>();
222 l.Add(block);
223 DataBlocks.Add(typeof(T), l);
224 }
225 else
226 {
227 if (DataBlocks[typeof(T)].Count < 500)
228 DataBlocks[typeof(T)].Add(block);
229 }
230 }
231 }
166 } 232 }
167} 233}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 05ebcac..4acc6be 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -2893,10 +2893,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2893 if (rotation.X == rotation.Y && rotation.Y == rotation.Z && rotation.Z == rotation.W && rotation.W == 0) 2893 if (rotation.X == rotation.Y && rotation.Y == rotation.Z && rotation.Z == rotation.W && rotation.W == 0)
2894 rotation = Quaternion.Identity; 2894 rotation = Quaternion.Identity;
2895 2895
2896 ObjectUpdatePacket.ObjectDataBlock objectData = 2896 ObjectUpdatePacket.ObjectDataBlock objectData = CreatePrimUpdateBlock(primShape, flags);
2897 new ObjectUpdatePacket.ObjectDataBlock();
2898
2899 objectData = CreatePrimUpdateBlock(primShape, flags);
2900 2897
2901 objectData.ID = localID; 2898 objectData.ID = localID;
2902 objectData.FullID = objectID; 2899 objectData.FullID = objectID;
@@ -3655,7 +3652,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3655 { 3652 {
3656 byte[] bytes = new byte[60]; 3653 byte[] bytes = new byte[60];
3657 int i = 0; 3654 int i = 0;
3658 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 3655 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = PacketPool.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
3659 3656
3660 dat.TextureEntry = new byte[0]; // AvatarTemplate.TextureEntry; 3657 dat.TextureEntry = new byte[0]; // AvatarTemplate.TextureEntry;
3661 3658
@@ -3750,7 +3747,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3750 byte[] bytes = new byte[60]; 3747 byte[] bytes = new byte[60];
3751 3748
3752 int i = 0; 3749 int i = 0;
3753 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 3750 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = PacketPool.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
3754 dat.TextureEntry = new byte[0]; 3751 dat.TextureEntry = new byte[0];
3755 bytes[i++] = (byte)(ID % 256); 3752 bytes[i++] = (byte)(ID % 256);
3756 bytes[i++] = (byte)((ID >> 8) % 256); 3753 bytes[i++] = (byte)((ID >> 8) % 256);
@@ -3837,7 +3834,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3837 /// <returns></returns> 3834 /// <returns></returns>
3838 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags) 3835 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags)
3839 { 3836 {
3840 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); 3837 ObjectUpdatePacket.ObjectDataBlock objupdate = PacketPool.GetDataBlock<ObjectUpdatePacket.ObjectDataBlock>();
3841 SetDefaultPrimPacketValues(objupdate); 3838 SetDefaultPrimPacketValues(objupdate);
3842 objupdate.UpdateFlags = flags; 3839 objupdate.UpdateFlags = flags;
3843 SetPrimPacketShapeData(objupdate, primShape); 3840 SetPrimPacketShapeData(objupdate, primShape);
@@ -3908,7 +3905,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3908 /// <returns></returns> 3905 /// <returns></returns>
3909 public ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry) 3906 public ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry)
3910 { 3907 {
3911 ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); 3908 ObjectUpdatePacket.ObjectDataBlock objdata = PacketPool.GetDataBlock<ObjectUpdatePacket.ObjectDataBlock>();
3912 // new OpenMetaverse.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); 3909 // new OpenMetaverse.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
3913 3910
3914 SetDefaultAvatarPacketValues(ref objdata); 3911 SetDefaultAvatarPacketValues(ref objdata);
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
index 58777ab..2191ca7 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
@@ -586,7 +586,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
586 return; 586 return;
587 587
588 m_NeedAck.Remove(id); 588 m_NeedAck.Remove(id);
589 PacketPool.Instance.ReturnPacket(data.Packet); 589 // We can't return this packet, it will just have to be GC'd
590 // Reason for that is that the packet may still be in the
591 // send queue, and if it gets reused things get messy!
592 //
593 // PacketPool.Instance.ReturnPacket(data.Packet);
590 m_UnackedBytes -= data.Length; 594 m_UnackedBytes -= data.Length;
591 } 595 }
592 } 596 }
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
index d3e5b45..3b1bad0 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
@@ -129,7 +129,7 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList
129 129
130 private void OnMuteListRequest(IClientAPI client, uint crc) 130 private void OnMuteListRequest(IClientAPI client, uint crc)
131 { 131 {
132 m_log.DebugFormat("[MUTE LIST] Got mute list requestg for crc {0}", crc); 132 m_log.DebugFormat("[MUTE LIST] Got mute list request for crc {0}", crc);
133 string filename = "mutes"+client.AgentId.ToString(); 133 string filename = "mutes"+client.AgentId.ToString();
134 134
135 IXfer xfer = client.Scene.RequestModuleInterface<IXfer>(); 135 IXfer xfer = client.Scene.RequestModuleInterface<IXfer>();