This change moves texture send processing out of the main
  packet processing loop and moves it to a timer based
  processing cycle.

  Texture packets are sent to the client consistently over
  time. The timer is discontinued whenever there are no
  textures to transmit.

  The behavior of the texture sending mechanism is controlled
  by three variables in the LLCLient section of the config
  file:

   [1] TextureRequestRate (mS) determines how many times per second
       texture send processing will occur. The default is 100mS.
   [2] TextureSendLimit determines how many different textures
       will be considered on each cycle. Textures are selected
       by priority. The old mechanism specified a value of 10 for
       this parameter and this is the default
   [3] TextureDataLimit determines how many packets will be sent for
       each of the selected textures. The old mechanism specified a
       value of 5, so this is the default.

  So the net effect is that TextureSendLimit*TextureDataLimit
  packets will be sent every TextureRequestRate mS.

  Once we have gotten a reasonable feeling for how these parameters
  affect overall processing, it would be nice to autonmically manage
  these values using information about the current status of the
  region and network.

  Note that this also resolves the pathologcal problem that
  previously existed which was that a seated avatar generated very
  few in-bound packets (theoretically) and would therefore be the
  least able to retrieve the images being displayed by a
  projector script.
This commit is contained in:
Dr Scofield
2009-06-25 07:42:06 +00:00
parent 652bcf91d5
commit afd5f76648
4 changed files with 185 additions and 75 deletions

View File

@@ -26,6 +26,7 @@
*/
using System;
using System.Threading;
using System.Collections.Generic;
using OpenMetaverse;
using OpenMetaverse.Imaging;
@@ -96,46 +97,42 @@ namespace OpenSim.Region.ClientStack.LindenUDP
J2KImage imgrequest = m_imagestore[newRequest.RequestedAssetID];
// This is the inbound request sequence number. We can ignore
// "old" ones.
if (newRequest.requestSequence > imgrequest.m_lastSequence)
{
imgrequest.m_lastSequence = newRequest.requestSequence;
//First of all, is this being killed?
//if (newRequest.Priority == 0.0f && newRequest.DiscardLevel == -1)
//{
//Do nothing (leaving the if for future use)
//}
//else
//{
//Check the priority
double priority = imgrequest.m_requestedPriority;
if (priority != newRequest.Priority)
{
//Remove the old priority
m_priorities.Remove(imgrequest.m_designatedPriorityKey);
//Assign a new unique priority
imgrequest.m_requestedPriority = newRequest.Priority;
imgrequest.m_designatedPriorityKey = AssignPriority(newRequest.RequestedAssetID, newRequest.Priority);
}
//Check the priority
double priority = imgrequest.m_requestedPriority;
if (priority != newRequest.Priority)
{
//Remove the old priority
m_priorities.Remove(imgrequest.m_designatedPriorityKey);
//Assign a new unique priority
imgrequest.m_requestedPriority = newRequest.Priority;
imgrequest.m_designatedPriorityKey = AssignPriority(newRequest.RequestedAssetID, newRequest.Priority);
}
//Update the requested discard level
imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel;
//Update the requested discard level
imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel;
//Update the requested packet number
imgrequest.m_requestedPacketNumber = newRequest.PacketNumber;
//Update the requested packet number
imgrequest.m_requestedPacketNumber = newRequest.PacketNumber;
//Check if this will create an outstanding texture request
bool activated = imgrequest.m_completedSendAtCurrentDiscardLevel;
//Run an update
//Check if this will create an outstanding texture request
bool activated = imgrequest.m_completedSendAtCurrentDiscardLevel;
//Run an update
imgrequest.RunUpdate();
if (activated && !imgrequest.m_completedSendAtCurrentDiscardLevel && imgrequest.m_decoded)
{
m_outstandingtextures++;
}
imgrequest.RunUpdate();
//}
if (activated && !imgrequest.m_completedSendAtCurrentDiscardLevel && imgrequest.m_decoded)
{
Interlocked.Increment(ref m_outstandingtextures);
}
}
}
else
@@ -198,10 +195,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
public void ProcessImageQueue(int count)
public bool ProcessImageQueue(int count, int maxpack)
{
// this can happen during Close()
if (m_client == null) return;
if (m_client == null)
return false;
//Count is the number of textures we want to process in one go.
//As part of this class re-write, that number will probably rise
@@ -214,7 +213,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (m_lastloopprocessed == 0)
{
if (m_client.PacketHandler == null || m_client.PacketHandler.PacketQueue == null || m_client.PacketHandler.PacketQueue.TextureThrottle == null)
return;
return false;
//This is decent for a semi fast machine, but we'll calculate it more accurately based on time below
threshold = m_client.PacketHandler.PacketQueue.TextureThrottle.Current / 6300;
m_lastloopprocessed = DateTime.Now.Ticks;
@@ -239,10 +238,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
if (m_client.PacketHandler == null)
return;
return false;
if (m_client.PacketHandler.PacketQueue == null)
return;
return false;
//First of all make sure our packet queue isn't above our threshold
@@ -252,24 +251,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
bool justreset = false;
for (int x = m_priorities.Count - 1; x > -1; x--)
{
J2KImage imagereq = m_imagestore[m_priorities.Values[x]];
if (imagereq.m_decoded == true && !imagereq.m_completedSendAtCurrentDiscardLevel)
{
numCollected++;
//SendPackets will send up to ten packets per cycle
if (imagereq.SendPackets(m_client))
if (imagereq.SendPackets(m_client, maxpack))
{
//Send complete
if (!imagereq.m_completedSendAtCurrentDiscardLevel)
{
imagereq.m_completedSendAtCurrentDiscardLevel = true;
m_outstandingtextures--;
Interlocked.Decrement(ref m_outstandingtextures);
//Re-assign priority to bottom
//Remove the old priority
m_priorities.Remove(imagereq.m_designatedPriorityKey);
@@ -310,13 +306,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
justreset = true; //prevents us from getting stuck in a loop
}
}
}
return m_outstandingtextures != 0;
}
//Faux destructor