From 1dbbf6edb6c913697ac3248ef5b74c943a7a9c23 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 18 Oct 2009 03:15:36 -0700 Subject: * Process the avatar terse update priority queue as soon as an update for our own avatar is ready to send * Reduce the scope of the locks when processing the update queues * Reuse the ImprovedTerseObjectUpdate.RegionData block --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 79 +++++++++++----------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index b93e905..83a7184 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3402,34 +3402,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateAvatarImprovedBlock(data.localID, data.position, data.velocity, rotation); - + lock (m_avatarTerseUpdates.SyncRoot) m_avatarTerseUpdates.Enqueue(data.priority, terseBlock, data.localID); + + // If we received an update about our own avatar, process the avatar update priority queue immediately + if (data.agentid == m_agentId) + ProcessAvatarTerseUpdates(); } private void ProcessAvatarTerseUpdates() { - lock (m_avatarTerseUpdates.SyncRoot) - { - ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate); + ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate); + terse.Header.Reliable = false; + terse.Header.Zerocoded = true; - terse.RegionData = new ImprovedTerseObjectUpdatePacket.RegionDataBlock(); - - terse.RegionData.RegionHandle = Scene.RegionInfo.RegionHandle; - terse.RegionData.TimeDilation = - (ushort)(Scene.TimeDilation * ushort.MaxValue); + //terse.RegionData = new ImprovedTerseObjectUpdatePacket.RegionDataBlock(); + terse.RegionData.RegionHandle = Scene.RegionInfo.RegionHandle; + terse.RegionData.TimeDilation = (ushort)(Scene.TimeDilation * ushort.MaxValue); + lock (m_avatarTerseUpdates.SyncRoot) + { int count = Math.Min(m_avatarTerseUpdates.Count, m_avatarTerseUpdatesPerPacket); + if (count == 0) + return; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[count]; for (int i = 0; i < count; i++) terse.ObjectData[i] = m_avatarTerseUpdates.Dequeue(); - - terse.Header.Reliable = false; - terse.Header.Zerocoded = true; - - OutPacket(terse, ThrottleOutPacketType.Task); } + + OutPacket(terse, ThrottleOutPacketType.Task); } public void SendCoarseLocationUpdate(List users, List CoarseLocations) @@ -3642,26 +3645,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP void ProcessPrimFullUpdates() { - lock (m_primFullUpdates.SyncRoot) - { - ObjectUpdatePacket outPacket = - (ObjectUpdatePacket)PacketPool.Instance.GetPacket( - PacketType.ObjectUpdate); + ObjectUpdatePacket outPacket = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate); + outPacket.Header.Zerocoded = true; - outPacket.RegionData.RegionHandle = - Scene.RegionInfo.RegionHandle; - outPacket.RegionData.TimeDilation = - (ushort)(Scene.TimeDilation * ushort.MaxValue); + //outPacket.RegionData = new ObjectUpdatePacket.RegionDataBlock(); + outPacket.RegionData.RegionHandle = Scene.RegionInfo.RegionHandle; + outPacket.RegionData.TimeDilation = (ushort)(Scene.TimeDilation * ushort.MaxValue); + lock (m_primFullUpdates.SyncRoot) + { int count = Math.Min(m_primFullUpdates.Count, m_primFullUpdatesPerPacket); + if (count == 0) + return; outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[count]; for (int i = 0; i < count; i++) outPacket.ObjectData[i] = m_primFullUpdates.Dequeue(); - - outPacket.Header.Zerocoded = true; - OutPacket(outPacket, ThrottleOutPacketType.State); } + + OutPacket(outPacket, ThrottleOutPacketType.State); } /// @@ -3695,28 +3697,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP void ProcessPrimTerseUpdates() { - lock (m_primTerseUpdates.SyncRoot) - { - ImprovedTerseObjectUpdatePacket outPacket = - (ImprovedTerseObjectUpdatePacket) - PacketPool.Instance.GetPacket( - PacketType.ImprovedTerseObjectUpdate); + ImprovedTerseObjectUpdatePacket outPacket = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate); + outPacket.Header.Reliable = false; + outPacket.Header.Zerocoded = true; - outPacket.RegionData.RegionHandle = - Scene.RegionInfo.RegionHandle; - outPacket.RegionData.TimeDilation = - (ushort)(Scene.TimeDilation * ushort.MaxValue); + outPacket.RegionData.RegionHandle = Scene.RegionInfo.RegionHandle; + outPacket.RegionData.TimeDilation = (ushort)(Scene.TimeDilation * ushort.MaxValue); + lock (m_primTerseUpdates.SyncRoot) + { int count = Math.Min(m_primTerseUpdates.Count, m_primTerseUpdatesPerPacket); + if (count == 0) + return; outPacket.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[count]; for (int i = 0; i < count; i++) outPacket.ObjectData[i] = m_primTerseUpdates.Dequeue(); - - outPacket.Header.Reliable = false; - outPacket.Header.Zerocoded = true; - OutPacket(outPacket, ThrottleOutPacketType.State); } + + OutPacket(outPacket, ThrottleOutPacketType.State); } public void ReprioritizeUpdates(StateUpdateTypes type, UpdatePriorityHandler handler) -- cgit v1.1