aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP
diff options
context:
space:
mode:
authorUbitUmarov2016-08-07 17:07:09 +0100
committerUbitUmarov2016-08-07 21:13:29 +0100
commitc255c23981a3023e3587a71872bbaeb6fcd62093 (patch)
tree569226a286d82d185a4205f5b5c20fb1befb053a /OpenSim/Region/ClientStack/Linden/UDP
parentseveral changes related to culling option (diff)
downloadopensim-SC-c255c23981a3023e3587a71872bbaeb6fcd62093.zip
opensim-SC-c255c23981a3023e3587a71872bbaeb6fcd62093.tar.gz
opensim-SC-c255c23981a3023e3587a71872bbaeb6fcd62093.tar.bz2
opensim-SC-c255c23981a3023e3587a71872bbaeb6fcd62093.tar.xz
move updates from updates queues into udp queues acording to their payload estimated size and udp sending capability on a time slice, instead always moving a arbitrary number of updates.
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs81
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs5
2 files changed, 46 insertions, 40 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index b823abe..6beb9b4 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -3982,7 +3982,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3982 ResendPrimUpdate(update); 3982 ResendPrimUpdate(update);
3983 } 3983 }
3984 3984
3985 private void ProcessEntityUpdates(int maxUpdates) 3985 private void ProcessEntityUpdates(int maxUpdatesBytes)
3986 { 3986 {
3987 OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>(); 3987 OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
3988 OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>(); 3988 OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
@@ -3996,16 +3996,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3996 3996
3997 3997
3998 // Check to see if this is a flush 3998 // Check to see if this is a flush
3999 if (maxUpdates <= 0) 3999 if (maxUpdatesBytes <= 0)
4000 { 4000 {
4001 maxUpdates = Int32.MaxValue; 4001 maxUpdatesBytes = Int32.MaxValue;
4002 } 4002 }
4003 4003
4004 int updatesThisCall = 0;
4005
4006 // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
4007 // condition where a kill can be processed before an out-of-date update for the same object.
4008// float avgTimeDilation = 0.0f;
4009 EntityUpdate update; 4004 EntityUpdate update;
4010 Int32 timeinqueue; // this is just debugging code & can be dropped later 4005 Int32 timeinqueue; // this is just debugging code & can be dropped later
4011 4006
@@ -4018,25 +4013,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4018 ScenePresence mysp = (ScenePresence)SceneAgent; 4013 ScenePresence mysp = (ScenePresence)SceneAgent;
4019 if(mysp != null && !mysp.IsDeleted) 4014 if(mysp != null && !mysp.IsDeleted)
4020 { 4015 {
4021 cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance +16f; 4016 cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f;
4022// mycamera = mysp.CameraPosition; 4017// mycamera = mysp.CameraPosition;
4023 mypos = mysp.AbsolutePosition; 4018 mypos = mysp.AbsolutePosition;
4024 } 4019 }
4025 else 4020 else
4026 doCulling = false; 4021 doCulling = false;
4027 4022
4028 while (updatesThisCall < maxUpdates) 4023 while (maxUpdatesBytes > 0)
4029 { 4024 {
4030 lock (m_entityUpdates.SyncRoot) 4025 lock (m_entityUpdates.SyncRoot)
4031 if (!m_entityUpdates.TryDequeue(out update, out timeinqueue)) 4026 if (!m_entityUpdates.TryDequeue(out update, out timeinqueue))
4032 break; 4027 break;
4033 4028
4034// avgTimeDilation += update.TimeDilation;
4035 PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags; 4029 PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
4036 4030
4037 if(updateFlags.HasFlag(PrimUpdateFlags.Kill)) 4031 if(updateFlags.HasFlag(PrimUpdateFlags.Kill))
4038 { 4032 {
4039 m_killRecord.Add(update.Entity.LocalId); 4033 m_killRecord.Add(update.Entity.LocalId);
4034 maxUpdatesBytes -= 30;
4040 continue; 4035 continue;
4041 } 4036 }
4042 4037
@@ -4158,8 +4153,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4158 continue; 4153 continue;
4159 } 4154 }
4160 4155
4161 ++updatesThisCall;
4162
4163 #region UpdateFlags to packet type conversion 4156 #region UpdateFlags to packet type conversion
4164 4157
4165 bool canUseCompressed = true; 4158 bool canUseCompressed = true;
@@ -4212,30 +4205,49 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4212 4205
4213 // TODO: Remove this once we can build compressed updates 4206 // TODO: Remove this once we can build compressed updates
4214 canUseCompressed = false; 4207 canUseCompressed = false;
4215 4208
4216 if (!canUseImproved && !canUseCompressed) 4209 if (!canUseImproved && !canUseCompressed)
4217 { 4210 {
4218 if (update.Entity is ScenePresence) 4211 if (update.Entity is ScenePresence)
4219 { 4212 {
4220 objectUpdateBlocks.Value.Add(CreateAvatarUpdateBlock((ScenePresence)update.Entity)); 4213 ObjectUpdatePacket.ObjectDataBlock ablock =
4214 CreateAvatarUpdateBlock((ScenePresence)update.Entity);
4215 objectUpdateBlocks.Value.Add(ablock);
4216 maxUpdatesBytes -= ablock.Length;
4221 } 4217 }
4222 else 4218 else
4223 { 4219 {
4224 objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId)); 4220 ObjectUpdatePacket.ObjectDataBlock ablock =
4221 CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId);
4222 objectUpdateBlocks.Value.Add(ablock);
4223 maxUpdatesBytes -= ablock.Length;
4225 } 4224 }
4226 } 4225 }
4227 else if (!canUseImproved) 4226 else if (!canUseImproved)
4228 { 4227 {
4229 compressedUpdateBlocks.Value.Add(CreateCompressedUpdateBlock((SceneObjectPart)update.Entity, updateFlags)); 4228 ObjectUpdateCompressedPacket.ObjectDataBlock ablock =
4229 CreateCompressedUpdateBlock((SceneObjectPart)update.Entity, updateFlags);
4230 compressedUpdateBlocks.Value.Add(ablock);
4231 maxUpdatesBytes -= ablock.Length;
4230 } 4232 }
4231 else 4233 else
4232 { 4234 {
4233 if (update.Entity is ScenePresence) 4235 if (update.Entity is ScenePresence)
4236 {
4234 // ALL presence updates go into a special list 4237 // ALL presence updates go into a special list
4235 terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures))); 4238 ImprovedTerseObjectUpdatePacket.ObjectDataBlock ablock =
4239 CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
4240 terseAgentUpdateBlocks.Value.Add(ablock);
4241 maxUpdatesBytes -= ablock.Length;
4242 }
4236 else 4243 else
4244 {
4237 // Everything else goes here 4245 // Everything else goes here
4238 terseUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures))); 4246 ImprovedTerseObjectUpdatePacket.ObjectDataBlock ablock =
4247 CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
4248 terseUpdateBlocks.Value.Add(ablock);
4249 maxUpdatesBytes -= ablock.Length;
4250 }
4239 } 4251 }
4240 4252
4241 #endregion Block Construction 4253 #endregion Block Construction
@@ -4504,8 +4516,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4504 // of updates converted to packets. Since we don't want packets 4516 // of updates converted to packets. Since we don't want packets
4505 // to sit in the queue with old data, only convert enough updates 4517 // to sit in the queue with old data, only convert enough updates
4506 // to packets that can be sent in 200ms. 4518 // to packets that can be sent in 200ms.
4507 private Int32 m_LastQueueFill = 0; 4519// private Int32 m_LastQueueFill = 0;
4508 private Int32 m_maxUpdates = 0; 4520// private Int32 m_maxUpdates = 0;
4509 4521
4510 void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories) 4522 void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
4511 { 4523 {
@@ -4516,7 +4528,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4516 { 4528 {
4517// if (!m_udpServer.IsRunningOutbound) 4529// if (!m_udpServer.IsRunningOutbound)
4518// return; 4530// return;
4519 4531/*
4520 if (m_maxUpdates == 0 || m_LastQueueFill == 0) 4532 if (m_maxUpdates == 0 || m_LastQueueFill == 0)
4521 { 4533 {
4522 m_maxUpdates = m_udpServer.PrimUpdatesPerCallback; 4534 m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
@@ -4530,17 +4542,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4530 } 4542 }
4531 m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500); 4543 m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500);
4532 m_LastQueueFill = Util.EnvironmentTickCount(); 4544 m_LastQueueFill = Util.EnvironmentTickCount();
4533 4545*/
4546 int maxUpdateBytes = m_udpClient.GetCatBytesCanSend(ThrottleOutPacketType.Task, 30);
4547
4534 if (m_entityUpdates.Count > 0) 4548 if (m_entityUpdates.Count > 0)
4535 ProcessEntityUpdates(m_maxUpdates); 4549 ProcessEntityUpdates(maxUpdateBytes);
4536 4550
4537 if (m_entityProps.Count > 0) 4551 if (m_entityProps.Count > 0)
4538 ProcessEntityPropertyRequests(m_maxUpdates); 4552 ProcessEntityPropertyRequests(maxUpdateBytes);
4539 } 4553 }
4540 4554
4541 if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0) 4555 if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
4542 ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit); 4556 ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
4543 } 4557 }
4544 4558
4545 internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories) 4559 internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories)
4546 { 4560 {
@@ -4723,7 +4737,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4723 m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true)); 4737 m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
4724 } 4738 }
4725 4739
4726 private void ProcessEntityPropertyRequests(int maxUpdates) 4740 private void ProcessEntityPropertyRequests(int maxUpdateBytes)
4727 { 4741 {
4728 OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks = 4742 OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks =
4729 new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>(); 4743 new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>();
@@ -4740,8 +4754,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4740 EntityUpdate iupdate; 4754 EntityUpdate iupdate;
4741 Int32 timeinqueue; // this is just debugging code & can be dropped later 4755 Int32 timeinqueue; // this is just debugging code & can be dropped later
4742 4756
4743 int updatesThisCall = 0; 4757 while (maxUpdateBytes > 0)
4744 while (updatesThisCall < m_maxUpdates)
4745 { 4758 {
4746 lock (m_entityProps.SyncRoot) 4759 lock (m_entityProps.SyncRoot)
4747 if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue)) 4760 if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
@@ -4756,6 +4769,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4756 ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags); 4769 ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
4757 objectFamilyBlocks.Value.Add(objPropDB); 4770 objectFamilyBlocks.Value.Add(objPropDB);
4758 familyUpdates.Value.Add(update); 4771 familyUpdates.Value.Add(update);
4772 maxUpdateBytes -= objPropDB.Length;
4759 } 4773 }
4760 } 4774 }
4761 4775
@@ -4767,16 +4781,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4767 ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop); 4781 ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
4768 objectPropertiesBlocks.Value.Add(objPropDB); 4782 objectPropertiesBlocks.Value.Add(objPropDB);
4769 propertyUpdates.Value.Add(update); 4783 propertyUpdates.Value.Add(update);
4784 maxUpdateBytes -= objPropDB.Length;
4770 } 4785 }
4771 } 4786 }
4772
4773 updatesThisCall++;
4774 } 4787 }
4775 4788
4776
4777 // Int32 ppcnt = 0;
4778 // Int32 pbcnt = 0;
4779
4780 if (objectPropertiesBlocks.IsValueCreated) 4789 if (objectPropertiesBlocks.IsValueCreated)
4781 { 4790 {
4782 List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value; 4791 List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value;
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
index 36e0a0e..4e68a9b 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
@@ -771,8 +771,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
771 RTO = Math.Min(RTO * 2, m_maxRTO); 771 RTO = Math.Min(RTO * 2, m_maxRTO);
772 } 772 }
773 773
774 774 const int MIN_CALLBACK_MS = 20;
775 const int MIN_CALLBACK_MS = 10;
776 775
777 /// <summary> 776 /// <summary>
778 /// Does an early check to see if this queue empty callback is already 777 /// Does an early check to see if this queue empty callback is already
@@ -807,9 +806,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
807 } 806 }
808 } 807 }
809 else 808 else
810 {
811 m_isQueueEmptyRunning = false; 809 m_isQueueEmptyRunning = false;
812 }
813 } 810 }
814 } 811 }
815 812