try Hacking in an AutoResetEvent to control the outgoing UDP loop instead of a continuous loop with sleeps.

Does appear to have a cpu impact but may need further tweaking
cpu-performance
Justin Clark-Casey (justincc) 2013-07-18 01:17:46 +01:00
parent 0af3b5ed9a
commit 1ba5a05cf7
2 changed files with 28 additions and 2 deletions

View File

@ -3776,6 +3776,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
ResendPrimUpdate(update); ResendPrimUpdate(update);
} }
// OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
// OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
// OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
// OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
//
// OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
// OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
// OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
// OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
private void ProcessEntityUpdates(int maxUpdates) private void ProcessEntityUpdates(int maxUpdates)
{ {
OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>(); OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
@ -3788,6 +3799,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>(); OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>(); OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
// objectUpdateBlocks.Value.Clear();
// compressedUpdateBlocks.Value.Clear();
// terseUpdateBlocks.Value.Clear();
// terseAgentUpdateBlocks.Value.Clear();
// objectUpdates.Value.Clear();
// compressedUpdates.Value.Clear();
// terseUpdates.Value.Clear();
// terseAgentUpdates.Value.Clear();
// Check to see if this is a flush // Check to see if this is a flush
if (maxUpdates <= 0) if (maxUpdates <= 0)
{ {

View File

@ -806,8 +806,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
PacketPool.Instance.ReturnPacket(packet); PacketPool.Instance.ReturnPacket(packet);
m_dataPresentEvent.Set();
} }
private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false);
/// <summary> /// <summary>
/// Start the process of sending a packet to the client. /// Start the process of sending a packet to the client.
/// </summary> /// </summary>
@ -1658,6 +1662,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Action generic every round // Action generic every round
Action<IClientAPI> clientPacketHandler = ClientOutgoingPacketHandler; Action<IClientAPI> clientPacketHandler = ClientOutgoingPacketHandler;
// while (true)
while (base.IsRunningOutbound) while (base.IsRunningOutbound)
{ {
try try
@ -1718,8 +1723,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// If nothing was sent, sleep for the minimum amount of time before a // If nothing was sent, sleep for the minimum amount of time before a
// token bucket could get more tokens // token bucket could get more tokens
if (!m_packetSent) //if (!m_packetSent)
Thread.Sleep((int)TickCountResolution); // Thread.Sleep((int)TickCountResolution);
m_dataPresentEvent.WaitOne(100);
Watchdog.UpdateThread(); Watchdog.UpdateThread();
} }