change the clock source on udp outgoing, remove some dead code

melanie
UbitUmarov 2016-11-09 10:21:02 +00:00
parent 92984556e1
commit 94d2422230
3 changed files with 10 additions and 153 deletions

View File

@ -323,7 +323,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected int m_elapsedMSSinceLastStatReport = 0; protected int m_elapsedMSSinceLastStatReport = 0;
/// <summary>Environment.TickCount of the last time the outgoing packet handler executed</summary> /// <summary>Environment.TickCount of the last time the outgoing packet handler executed</summary>
protected int m_tickLastOutgoingPacketHandler; protected double m_tickLastOutgoingPacketHandler;
/// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped</summary> /// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped</summary>
protected int m_elapsedMSOutgoingPacketHandler; protected int m_elapsedMSOutgoingPacketHandler;
@ -356,20 +356,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
} }
protected ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>(); protected ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>();
/// <summary>
/// Event used to signal when queued packets are available for sending.
/// </summary>
/// <remarks>
/// This allows the outbound loop to only operate when there is data to send rather than continuously polling.
/// Some data is sent immediately and not queued. That data would not trigger this event.
/// WRONG use. May be usefull in future revision
/// </remarks>
// protected AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false);
protected Pool<IncomingPacket> m_incomingPacketPool; protected Pool<IncomingPacket> m_incomingPacketPool;
/// <summary> /// <summary>
@ -467,8 +455,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
int sceneThrottleBps = 0; int sceneThrottleBps = 0;
bool usePools = false; bool usePools = false;
IConfig config = configSource.Configs["ClientStack.LindenUDP"]; IConfig config = configSource.Configs["ClientStack.LindenUDP"];
if (config != null) if (config != null)
{ {
@ -927,10 +913,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
PacketPool.Instance.ReturnPacket(packet); PacketPool.Instance.ReturnPacket(packet);
/// WRONG use. May be usefull in future revision
// if (packetQueued)
// m_dataPresentEvent.Set();
} }
/// <summary> /// <summary>
@ -2079,14 +2061,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_sendPing = false; m_sendPing = false;
// Update elapsed time // Update elapsed time
int thisTick = Environment.TickCount & Int32.MaxValue; double thisTick = Util.GetTimeStampMS();
if (m_tickLastOutgoingPacketHandler > thisTick) int deltaMS = (int)(thisTick - m_tickLastOutgoingPacketHandler);
m_elapsedMSOutgoingPacketHandler += ((Int32.MaxValue - m_tickLastOutgoingPacketHandler) + thisTick);
else
m_elapsedMSOutgoingPacketHandler += (thisTick - m_tickLastOutgoingPacketHandler);
m_tickLastOutgoingPacketHandler = thisTick; m_tickLastOutgoingPacketHandler = thisTick;
// update some 1ms resolution chained timers
m_elapsedMSOutgoingPacketHandler += deltaMS;
// Check for pending outgoing resends every 100ms // Check for pending outgoing resends every 100ms
if (m_elapsedMSOutgoingPacketHandler >= 100) if (m_elapsedMSOutgoingPacketHandler >= 100)
{ {
@ -2109,15 +2091,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_sendPing = true; m_sendPing = true;
m_elapsed500MSOutgoingPacketHandler = 0; m_elapsed500MSOutgoingPacketHandler = 0;
} }
#endregion Update Timers #endregion Update Timers
// Use this for emergency monitoring -- bug hunting
//if (m_scene.EmergencyMonitoring)
// clientPacketHandler = MonitoredClientOutgoingPacketHandler;
//else
// clientPacketHandler = ClientOutgoingPacketHandler;
// Handle outgoing packets, resends, acknowledgements, and pings for each // Handle outgoing packets, resends, acknowledgements, and pings for each
// client. m_packetSent will be set to true if a packet is sent // client. m_packetSent will be set to true if a packet is sent
Scene.ForEachClient(clientPacketHandler); Scene.ForEachClient(clientPacketHandler);
@ -2129,7 +2104,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if(Scene.GetNumberOfClients() == 0) if(Scene.GetNumberOfClients() == 0)
{ {
Thread.Sleep(250); // be friendly to PIs, but how long ?? Thread.Sleep(100);
} }
else if (!m_packetSent) else if (!m_packetSent)
// Thread.Sleep((int)TickCountResolution); outch this is bad on linux // Thread.Sleep((int)TickCountResolution); outch this is bad on linux
@ -2204,99 +2179,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// </summary> /// </summary>
public long IncomingPacketsProcessed { get; protected set; } public long IncomingPacketsProcessed { get; protected set; }
protected void MonitoredClientOutgoingPacketHandler(IClientAPI client)
{
nticks++;
watch1.Start();
m_currentOutgoingClient = client;
try
{
if (client is LLClientView)
{
LLClientView llClient = (LLClientView)client;
LLUDPClient udpClient = llClient.UDPClient;
if (udpClient.IsConnected)
{
if (m_resendUnacked)
{
nticksUnack++;
watch2.Start();
HandleUnacked(llClient);
watch2.Stop();
avgResendUnackedTicks = (nticksUnack - 1)/(float)nticksUnack * avgResendUnackedTicks + (watch2.ElapsedTicks / (float)nticksUnack);
watch2.Reset();
}
if (m_sendAcks)
{
nticksAck++;
watch2.Start();
SendAcks(udpClient);
watch2.Stop();
avgSendAcksTicks = (nticksAck - 1) / (float)nticksAck * avgSendAcksTicks + (watch2.ElapsedTicks / (float)nticksAck);
watch2.Reset();
}
if (m_sendPing)
{
nticksPing++;
watch2.Start();
SendPing(udpClient);
watch2.Stop();
avgSendPingTicks = (nticksPing - 1) / (float)nticksPing * avgSendPingTicks + (watch2.ElapsedTicks / (float)nticksPing);
watch2.Reset();
}
watch2.Start();
// Dequeue any outgoing packets that are within the throttle limits
if (udpClient.DequeueOutgoing())
{
m_packetSent = true;
npacksSent++;
}
else
{
npackNotSent++;
}
watch2.Stop();
avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks);
watch2.Reset();
}
else
{
m_log.WarnFormat("[LLUDPSERVER]: Client is not connected");
}
}
}
catch (Exception ex)
{
m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler iteration for " + client.Name +
" threw an exception: " + ex.Message, ex);
}
watch1.Stop();
avgProcessingTicks = (nticks - 1) / (float)nticks * avgProcessingTicks + (watch1.ElapsedTicks / (float)nticks);
watch1.Reset();
// reuse this -- it's every ~100ms
if (Scene.EmergencyMonitoring && nticks % 100 == 0)
{
m_log.InfoFormat("[LLUDPSERVER]: avg processing ticks: {0} avg unacked: {1} avg acks: {2} avg ping: {3} avg dequeue: {4} (TickCountRes: {5} sent: {6} notsent: {7})",
avgProcessingTicks, avgResendUnackedTicks, avgSendAcksTicks, avgSendPingTicks, avgDequeueTicks, TickCountResolution, npacksSent, npackNotSent);
npackNotSent = npacksSent = 0;
}
}
#endregion #endregion
protected void ProcessInPacket(IncomingPacket incomingPacket) protected void ProcessInPacket(IncomingPacket incomingPacket)

View File

@ -92,8 +92,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Asset = throttleConfig.GetInt("asset_default", 10500); Asset = throttleConfig.GetInt("asset_default", 10500);
Total = Resend + Land + Wind + Cloud + Task + Texture + Asset; Total = Resend + Land + Wind + Cloud + Task + Texture + Asset;
// 3000000 bps default max // 5120000 bps default max
ClientMaxRate = throttleConfig.GetInt("client_throttle_max_bps", 375000); ClientMaxRate = throttleConfig.GetInt("client_throttle_max_bps", 640000);
if (ClientMaxRate > 1000000) if (ClientMaxRate > 1000000)
ClientMaxRate = 1000000; // no more than 8Mbps ClientMaxRate = 1000000; // no more than 8Mbps

View File

@ -125,13 +125,6 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
+ " With the 'full' option child agents are also shown.", + " With the 'full' option child agents are also shown.",
(mod, cmd) => MainConsole.Instance.Output(GetThrottlesReport(cmd))); (mod, cmd) => MainConsole.Instance.Output(GetThrottlesReport(cmd)));
scene.AddCommand(
"Comms", this, "emergency-monitoring",
"emergency-monitoring",
"Go on/off emergency monitoring mode",
"Go on/off emergency monitoring mode",
HandleEmergencyMonitoring);
scene.AddCommand( scene.AddCommand(
"Comms", this, "show client stats", "Comms", this, "show client stats",
"show client stats [first_name last_name]", "show client stats [first_name last_name]",
@ -197,24 +190,6 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
return report.ToString(); return report.ToString();
} }
protected void HandleEmergencyMonitoring(string module, string[] cmd)
{
bool mode = true;
if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on"))
{
mode = true;
MainConsole.Instance.Output("Emergency Monitoring ON");
}
else
{
mode = false;
MainConsole.Instance.Output("Emergency Monitoring OFF");
}
foreach (Scene s in m_scenes.Values)
s.EmergencyMonitoring = mode;
}
protected string GetColumnEntry(string entry, int maxLength, int columnPadding) protected string GetColumnEntry(string entry, int maxLength, int columnPadding)
{ {
return string.Format( return string.Format(