diff options
author | Justin Clark-Casey (justincc) | 2013-07-19 00:51:13 +0100 |
---|---|---|
committer | Diva Canto | 2013-07-21 08:58:55 -0700 |
commit | 61eda1f441092eb12936472de2dc73898e40aa16 (patch) | |
tree | 946091464ce67628e7ec3a3e3ca49349085ae19e /OpenSim/Region/ClientStack/Linden | |
parent | Add measure of number of inbound AgentUpdates that were seen as significant t... (diff) | |
download | opensim-SC-61eda1f441092eb12936472de2dc73898e40aa16.zip opensim-SC-61eda1f441092eb12936472de2dc73898e40aa16.tar.gz opensim-SC-61eda1f441092eb12936472de2dc73898e40aa16.tar.bz2 opensim-SC-61eda1f441092eb12936472de2dc73898e40aa16.tar.xz |
Make the check as to whether any particular inbound AgentUpdate packet is significant much earlier in UDP processing (i.e. before we pointlessly place such packets on internal queues, etc.)
Appears to have some impact on cpu but needs testing.
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 170 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 17 |
2 files changed, 129 insertions, 58 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 3145275..7e5511f 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -357,7 +357,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
357 | /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods | 357 | /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods |
358 | /// cannot retain a reference to it outside of that method. | 358 | /// cannot retain a reference to it outside of that method. |
359 | /// </remarks> | 359 | /// </remarks> |
360 | private AgentUpdateArgs m_lastAgentUpdateArgs; | 360 | private AgentUpdateArgs m_lastAgentUpdateArgs = new AgentUpdateArgs(); |
361 | |||
362 | private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs(); | ||
361 | 363 | ||
362 | protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); | 364 | protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); |
363 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers | 365 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers |
@@ -5569,80 +5571,136 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5569 | 5571 | ||
5570 | #region Scene/Avatar | 5572 | #region Scene/Avatar |
5571 | 5573 | ||
5574 | /// <summary> | ||
5575 | /// This checks the update significance against the last update made. | ||
5576 | /// </summary> | ||
5577 | /// <remarks>Can only be called by one thread at a time, and not at the same time as </remarks> | ||
5578 | /// | ||
5579 | /// <returns>/returns> | ||
5580 | /// <param name='x'></param> | ||
5581 | public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) | ||
5582 | { | ||
5583 | bool update = false; | ||
5584 | |||
5585 | if (m_lastAgentUpdateArgs != null) | ||
5586 | { | ||
5587 | // These should be ordered from most-likely to | ||
5588 | // least likely to change. I've made an initial | ||
5589 | // guess at that. | ||
5590 | update = | ||
5591 | ( | ||
5592 | (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || | ||
5593 | (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || | ||
5594 | (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || | ||
5595 | (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || | ||
5596 | (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || | ||
5597 | (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || | ||
5598 | (x.Far != m_lastAgentUpdateArgs.Far) || | ||
5599 | (x.Flags != m_lastAgentUpdateArgs.Flags) || | ||
5600 | (x.State != m_lastAgentUpdateArgs.State) || | ||
5601 | (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || | ||
5602 | (x.SessionID != m_lastAgentUpdateArgs.SessionID) || | ||
5603 | (x.AgentID != m_lastAgentUpdateArgs.AgentID) | ||
5604 | ); | ||
5605 | } | ||
5606 | else | ||
5607 | { | ||
5608 | m_lastAgentUpdateArgs = new AgentUpdateArgs(); | ||
5609 | update = true; | ||
5610 | } | ||
5611 | |||
5612 | if (update) | ||
5613 | { | ||
5614 | // m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); | ||
5615 | TotalSignificantAgentUpdates++; | ||
5616 | |||
5617 | m_lastAgentUpdateArgs.AgentID = x.AgentID; | ||
5618 | m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation; | ||
5619 | m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; | ||
5620 | m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter; | ||
5621 | m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; | ||
5622 | m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; | ||
5623 | m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags; | ||
5624 | m_lastAgentUpdateArgs.Far = x.Far; | ||
5625 | m_lastAgentUpdateArgs.Flags = x.Flags; | ||
5626 | m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation; | ||
5627 | m_lastAgentUpdateArgs.SessionID = x.SessionID; | ||
5628 | m_lastAgentUpdateArgs.State = x.State; | ||
5629 | } | ||
5630 | |||
5631 | return update; | ||
5632 | } | ||
5633 | |||
5572 | private bool HandleAgentUpdate(IClientAPI sener, Packet packet) | 5634 | private bool HandleAgentUpdate(IClientAPI sener, Packet packet) |
5573 | { | 5635 | { |
5574 | if (OnAgentUpdate != null) | 5636 | if (OnAgentUpdate != null) |
5575 | { | 5637 | { |
5576 | AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; | 5638 | AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; |
5577 | 5639 | ||
5578 | #region Packet Session and User Check | 5640 | // Now done earlier |
5579 | if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId) | 5641 | // #region Packet Session and User Check |
5580 | { | 5642 | // if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId) |
5581 | PacketPool.Instance.ReturnPacket(packet); | 5643 | // { |
5582 | return false; | 5644 | // PacketPool.Instance.ReturnPacket(packet); |
5583 | } | 5645 | // return false; |
5584 | #endregion | 5646 | // } |
5585 | 5647 | // #endregion | |
5586 | bool update = false; | 5648 | // |
5649 | // bool update = false; | ||
5587 | AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; | 5650 | AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; |
5588 | 5651 | // | |
5589 | if (m_lastAgentUpdateArgs != null) | 5652 | // if (m_lastAgentUpdateArgs != null) |
5590 | { | 5653 | // { |
5591 | // These should be ordered from most-likely to | 5654 | // // These should be ordered from most-likely to |
5592 | // least likely to change. I've made an initial | 5655 | // // least likely to change. I've made an initial |
5593 | // guess at that. | 5656 | // // guess at that. |
5594 | update = | 5657 | // update = |
5595 | ( | 5658 | // ( |
5596 | (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || | 5659 | // (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || |
5597 | (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || | 5660 | // (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || |
5598 | (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || | 5661 | // (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || |
5599 | (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || | 5662 | // (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || |
5600 | (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || | 5663 | // (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || |
5601 | (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || | 5664 | // (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || |
5602 | (x.Far != m_lastAgentUpdateArgs.Far) || | 5665 | // (x.Far != m_lastAgentUpdateArgs.Far) || |
5603 | (x.Flags != m_lastAgentUpdateArgs.Flags) || | 5666 | // (x.Flags != m_lastAgentUpdateArgs.Flags) || |
5604 | (x.State != m_lastAgentUpdateArgs.State) || | 5667 | // (x.State != m_lastAgentUpdateArgs.State) || |
5605 | (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || | 5668 | // (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || |
5606 | (x.SessionID != m_lastAgentUpdateArgs.SessionID) || | 5669 | // (x.SessionID != m_lastAgentUpdateArgs.SessionID) || |
5607 | (x.AgentID != m_lastAgentUpdateArgs.AgentID) | 5670 | // (x.AgentID != m_lastAgentUpdateArgs.AgentID) |
5608 | ); | 5671 | // ); |
5609 | } | 5672 | // } |
5610 | else | 5673 | // |
5611 | { | 5674 | // if (update) |
5612 | m_lastAgentUpdateArgs = new AgentUpdateArgs(); | 5675 | // { |
5613 | update = true; | 5676 | //// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); |
5614 | } | ||
5615 | |||
5616 | if (update) | ||
5617 | { | ||
5618 | // m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); | ||
5619 | TotalSignificantAgentUpdates++; | 5677 | TotalSignificantAgentUpdates++; |
5620 | 5678 | ||
5621 | m_lastAgentUpdateArgs.AgentID = x.AgentID; | 5679 | m_thisAgentUpdateArgs.AgentID = x.AgentID; |
5622 | m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation; | 5680 | m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation; |
5623 | m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; | 5681 | m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; |
5624 | m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter; | 5682 | m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter; |
5625 | m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; | 5683 | m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; |
5626 | m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; | 5684 | m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; |
5627 | m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags; | 5685 | m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags; |
5628 | m_lastAgentUpdateArgs.Far = x.Far; | 5686 | m_thisAgentUpdateArgs.Far = x.Far; |
5629 | m_lastAgentUpdateArgs.Flags = x.Flags; | 5687 | m_thisAgentUpdateArgs.Flags = x.Flags; |
5630 | m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation; | 5688 | m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; |
5631 | m_lastAgentUpdateArgs.SessionID = x.SessionID; | 5689 | m_thisAgentUpdateArgs.SessionID = x.SessionID; |
5632 | m_lastAgentUpdateArgs.State = x.State; | 5690 | m_thisAgentUpdateArgs.State = x.State; |
5633 | 5691 | ||
5634 | UpdateAgent handlerAgentUpdate = OnAgentUpdate; | 5692 | UpdateAgent handlerAgentUpdate = OnAgentUpdate; |
5635 | UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; | 5693 | UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; |
5636 | 5694 | ||
5637 | if (handlerPreAgentUpdate != null) | 5695 | if (handlerPreAgentUpdate != null) |
5638 | OnPreAgentUpdate(this, m_lastAgentUpdateArgs); | 5696 | OnPreAgentUpdate(this, m_thisAgentUpdateArgs); |
5639 | 5697 | ||
5640 | if (handlerAgentUpdate != null) | 5698 | if (handlerAgentUpdate != null) |
5641 | OnAgentUpdate(this, m_lastAgentUpdateArgs); | 5699 | OnAgentUpdate(this, m_thisAgentUpdateArgs); |
5642 | 5700 | ||
5643 | handlerAgentUpdate = null; | 5701 | handlerAgentUpdate = null; |
5644 | handlerPreAgentUpdate = null; | 5702 | handlerPreAgentUpdate = null; |
5645 | } | 5703 | // } |
5646 | } | 5704 | } |
5647 | 5705 | ||
5648 | PacketPool.Instance.ReturnPacket(packet); | 5706 | PacketPool.Instance.ReturnPacket(packet); |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 78d4165..766c2fe 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -1307,8 +1307,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1307 | LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length); | 1307 | LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length); |
1308 | #endregion BinaryStats | 1308 | #endregion BinaryStats |
1309 | 1309 | ||
1310 | if (m_discardAgentUpdates && packet.Type == PacketType.AgentUpdate) | 1310 | if (packet.Type == PacketType.AgentUpdate) |
1311 | return; | 1311 | { |
1312 | if (m_discardAgentUpdates) | ||
1313 | return; | ||
1314 | |||
1315 | AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; | ||
1316 | |||
1317 | if (agentUpdate.AgentData.SessionID != client.SessionId | ||
1318 | || agentUpdate.AgentData.AgentID != client.AgentId | ||
1319 | || !((LLClientView)client).CheckAgentUpdateSignificance(agentUpdate.AgentData)) | ||
1320 | { | ||
1321 | PacketPool.Instance.ReturnPacket(packet); | ||
1322 | return; | ||
1323 | } | ||
1324 | } | ||
1312 | 1325 | ||
1313 | #region Ping Check Handling | 1326 | #region Ping Check Handling |
1314 | 1327 | ||