Cause better packing of ObjectProperties

mysql-performance
Melanie 2009-12-05 23:25:30 +00:00
parent 8e089b6d8d
commit f8cc409034
1 changed files with 78 additions and 26 deletions

View File

@ -352,6 +352,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private IHyperAssetService m_hyperAssets; private IHyperAssetService m_hyperAssets;
private const bool m_checkPackets = true; private const bool m_checkPackets = true;
private Timer m_propertiesPacketTimer;
private List<ObjectPropertiesPacket.ObjectDataBlock> m_propertiesBlocks = new List<ObjectPropertiesPacket.ObjectDataBlock>();
#endregion Class Members #endregion Class Members
#region Properties #region Properties
@ -433,6 +436,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_udpClient.OnQueueEmpty += HandleQueueEmpty; m_udpClient.OnQueueEmpty += HandleQueueEmpty;
m_udpClient.OnPacketStats += PopulateStats; m_udpClient.OnPacketStats += PopulateStats;
m_propertiesPacketTimer = new Timer(100);
m_propertiesPacketTimer.Elapsed += ProcessObjectPropertiesPacket;
RegisterLocalPacketHandlers(); RegisterLocalPacketHandlers();
} }
@ -3579,42 +3585,88 @@ namespace OpenSim.Region.ClientStack.LindenUDP
string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask,
uint BaseMask, byte saleType, int salePrice) uint BaseMask, byte saleType, int salePrice)
{ {
ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties); //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
// TODO: don't create new blocks if recycling an old packet // TODO: don't create new blocks if recycling an old packet
proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; ObjectPropertiesPacket.ObjectDataBlock block =
proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); new ObjectPropertiesPacket.ObjectDataBlock();
proper.ObjectData[0].ItemID = ItemID;
proper.ObjectData[0].CreationDate = CreationDate;
proper.ObjectData[0].CreatorID = CreatorUUID;
proper.ObjectData[0].FolderID = FolderUUID;
proper.ObjectData[0].FromTaskID = FromTaskUUID;
proper.ObjectData[0].GroupID = GroupUUID;
proper.ObjectData[0].InventorySerial = InventorySerial;
proper.ObjectData[0].LastOwnerID = LastOwnerUUID; block.ItemID = ItemID;
block.CreationDate = CreationDate;
block.CreatorID = CreatorUUID;
block.FolderID = FolderUUID;
block.FromTaskID = FromTaskUUID;
block.GroupID = GroupUUID;
block.InventorySerial = InventorySerial;
block.LastOwnerID = LastOwnerUUID;
// proper.ObjectData[0].LastOwnerID = UUID.Zero; // proper.ObjectData[0].LastOwnerID = UUID.Zero;
proper.ObjectData[0].ObjectID = ObjectUUID; block.ObjectID = ObjectUUID;
if (OwnerUUID == GroupUUID) if (OwnerUUID == GroupUUID)
proper.ObjectData[0].OwnerID = UUID.Zero; block.OwnerID = UUID.Zero;
else else
proper.ObjectData[0].OwnerID = OwnerUUID; block.OwnerID = OwnerUUID;
proper.ObjectData[0].TouchName = Util.StringToBytes256(TouchTitle); block.TouchName = Util.StringToBytes256(TouchTitle);
proper.ObjectData[0].TextureID = TextureID; block.TextureID = TextureID;
proper.ObjectData[0].SitName = Util.StringToBytes256(SitTitle); block.SitName = Util.StringToBytes256(SitTitle);
proper.ObjectData[0].Name = Util.StringToBytes256(ItemName); block.Name = Util.StringToBytes256(ItemName);
proper.ObjectData[0].Description = Util.StringToBytes256(ItemDescription); block.Description = Util.StringToBytes256(ItemDescription);
proper.ObjectData[0].OwnerMask = OwnerMask; block.OwnerMask = OwnerMask;
proper.ObjectData[0].NextOwnerMask = NextOwnerMask; block.NextOwnerMask = NextOwnerMask;
proper.ObjectData[0].GroupMask = GroupMask; block.GroupMask = GroupMask;
proper.ObjectData[0].EveryoneMask = EveryoneMask; block.EveryoneMask = EveryoneMask;
proper.ObjectData[0].BaseMask = BaseMask; block.BaseMask = BaseMask;
// proper.ObjectData[0].AggregatePerms = 53; // proper.ObjectData[0].AggregatePerms = 53;
// proper.ObjectData[0].AggregatePermTextures = 0; // proper.ObjectData[0].AggregatePermTextures = 0;
// proper.ObjectData[0].AggregatePermTexturesOwner = 0; // proper.ObjectData[0].AggregatePermTexturesOwner = 0;
proper.ObjectData[0].SaleType = saleType; block.SaleType = saleType;
proper.ObjectData[0].SalePrice = salePrice; block.SalePrice = salePrice;
lock (m_propertiesPacketTimer)
{
m_propertiesBlocks.Add(block);
int length = 0;
foreach (ObjectPropertiesPacket.ObjectDataBlock b in m_propertiesBlocks)
{
length += b.Length;
}
if (length > 1100) // FIXME: use real MTU
{
ProcessObjectPropertiesPacket(null, null);
m_propertiesPacketTimer.Stop();
return;
}
m_propertiesPacketTimer.Stop();
m_propertiesPacketTimer.Start();
}
//proper.Header.Zerocoded = true;
//OutPacket(proper, ThrottleOutPacketType.Task);
}
private void ProcessObjectPropertiesPacket(Object sender, ElapsedEventArgs e)
{
ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
lock (m_propertiesPacketTimer)
{
m_propertiesPacketTimer.Stop();
proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count];
int index = 0;
foreach (ObjectPropertiesPacket.ObjectDataBlock b in m_propertiesBlocks)
{
proper.ObjectData[index++] = b;
}
m_propertiesBlocks.Clear();
}
proper.Header.Zerocoded = true; proper.Header.Zerocoded = true;
OutPacket(proper, ThrottleOutPacketType.Task); OutPacket(proper, ThrottleOutPacketType.Task);
} }