Merge pull request #7 from gamucf/moses.metricsPhase2

Moses.metrics phase2
fsassets
Michael Heilmann 2015-05-19 14:40:49 -04:00
commit 714c082ca8
7 changed files with 1012 additions and 751 deletions

52
OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs Normal file → Executable file
View File

@ -27,6 +27,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using OpenMetaverse; using OpenMetaverse;
@ -71,6 +72,11 @@ namespace OpenSim.Framework.Monitoring
private volatile float pendingUploads; private volatile float pendingUploads;
private volatile float activeScripts; private volatile float activeScripts;
private volatile float scriptLinesPerSecond; private volatile float scriptLinesPerSecond;
private volatile float m_frameDilation;
private volatile float m_usersLoggingIn;
private volatile float m_totalGeoPrims;
private volatile float m_totalMeshes;
private volatile float m_inUseThreads;
// /// <summary> // /// <summary>
// /// These statistics are being collected by push rather than pull. Pull would be simpler, but I had the // /// These statistics are being collected by push rather than pull. Pull would be simpler, but I had the
@ -249,6 +255,10 @@ namespace OpenSim.Framework.Monitoring
{ {
// FIXME: SimStats shouldn't allow an arbitrary stat packing order (which is inherited from the original // FIXME: SimStats shouldn't allow an arbitrary stat packing order (which is inherited from the original
// SimStatsPacket that was being used). // SimStatsPacket that was being used).
// For an unknown reason the original designers decided not to
// include the spare MS statistic inside of this class, this is
// located inside the StatsBlock at location 21, thus it is skipped
timeDilation = stats.StatsBlock[0].StatValue; timeDilation = stats.StatsBlock[0].StatValue;
simFps = stats.StatsBlock[1].StatValue; simFps = stats.StatsBlock[1].StatValue;
physicsFps = stats.StatsBlock[2].StatValue; physicsFps = stats.StatsBlock[2].StatValue;
@ -270,6 +280,11 @@ namespace OpenSim.Framework.Monitoring
pendingUploads = stats.StatsBlock[18].StatValue; pendingUploads = stats.StatsBlock[18].StatValue;
activeScripts = stats.StatsBlock[19].StatValue; activeScripts = stats.StatsBlock[19].StatValue;
scriptLinesPerSecond = stats.StatsBlock[20].StatValue; scriptLinesPerSecond = stats.StatsBlock[20].StatValue;
m_frameDilation = stats.StatsBlock[22].StatValue;
m_usersLoggingIn = stats.StatsBlock[23].StatValue;
m_totalGeoPrims = stats.StatsBlock[24].StatValue;
m_totalMeshes = stats.StatsBlock[25].StatValue;
m_inUseThreads = stats.StatsBlock[26].StatValue;
} }
/// <summary> /// <summary>
@ -407,6 +422,27 @@ Asset service request failures: {3}" + Environment.NewLine,
/// <returns></returns> /// <returns></returns>
public override OSDMap OReport(string uptime, string version) public override OSDMap OReport(string uptime, string version)
{ {
// Get the amount of physical memory, allocated with the instance of this program, in kilobytes;
// the working set is the set of memory pages currently visible to this program in physical RAM
// memory and includes both shared (e.g. system libraries) and private data
double memUsage = Process.GetCurrentProcess().WorkingSet64 / 1024.0;
// Get the number of threads from the system that are currently
// running
int numberThreadsRunning = 0;
foreach (ProcessThread currentThread in
Process.GetCurrentProcess().Threads)
{
// A known issue with the current process .Threads property is
// that it can return null threads, thus don't count those as
// running threads and prevent the program function from failing
if (currentThread != null &&
currentThread.ThreadState == ThreadState.Running)
{
numberThreadsRunning++;
}
}
OSDMap args = new OSDMap(30); OSDMap args = new OSDMap(30);
// args["AssetsInCache"] = OSD.FromString (String.Format ("{0:0.##}", AssetsInCache)); // args["AssetsInCache"] = OSD.FromString (String.Format ("{0:0.##}", AssetsInCache));
// args["TimeAfterCacheMiss"] = OSD.FromString (String.Format ("{0:0.##}", // args["TimeAfterCacheMiss"] = OSD.FromString (String.Format ("{0:0.##}",
@ -444,6 +480,22 @@ Asset service request failures: {3}" + Environment.NewLine,
args["Uptime"] = OSD.FromString (uptime); args["Uptime"] = OSD.FromString (uptime);
args["Version"] = OSD.FromString (version); args["Version"] = OSD.FromString (version);
args["FrameDilatn"] = OSD.FromString(String.Format("{0:0.##}", m_frameDilation));
args["Logging in Users"] = OSD.FromString(String.Format("{0:0.##}",
m_usersLoggingIn));
args["GeoPrims"] = OSD.FromString(String.Format("{0:0.##}",
m_totalGeoPrims));
args["Mesh Objects"] = OSD.FromString(String.Format("{0:0.##}",
m_totalMeshes));
args["XEngine Thread Count"] = OSD.FromString(String.Format("{0:0.##}",
m_inUseThreads));
args["Util Thread Count"] = OSD.FromString(String.Format("{0:0.##}",
Util.GetSmartThreadPoolInfo().InUseThreads));
args["System Thread Count"] = OSD.FromString(String.Format(
"{0:0.##}", numberThreadsRunning));
args["ProcMem"] = OSD.FromString(String.Format("{0:#,###,###.##}",
memUsage));
return args; return args;
} }
} }

View File

@ -1,29 +1,29 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright * * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the * * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -48,7 +48,7 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes.Scripting; using OpenSim.Region.Framework.Scenes.Scripting;
using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using Timer=System.Timers.Timer; using Timer = System.Timers.Timer;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags; using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
using GridRegion = OpenSim.Services.Interfaces.GridRegion; using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using PermissionMask = OpenSim.Framework.PermissionMask; using PermissionMask = OpenSim.Framework.PermissionMask;
@ -64,6 +64,8 @@ namespace OpenSim.Region.Framework.Scenes
public const int m_defaultNumberFramesStored = 10; public const int m_defaultNumberFramesStored = 10;
public const int m_defaultNumberFramesStored = 10;
public delegate void SynchronizeSceneHandler(Scene scene); public delegate void SynchronizeSceneHandler(Scene scene);
#region Fields #region Fields
@ -269,7 +271,8 @@ namespace OpenSim.Region.Framework.Scenes
public float DefaultDrawDistance public float DefaultDrawDistance
{ {
// get { return m_defaultDrawDistance; } // get { return m_defaultDrawDistance; }
get { get
{
if (RegionInfo != null) if (RegionInfo != null)
{ {
float largestDimension = Math.Max(RegionInfo.RegionSizeX, RegionInfo.RegionSizeY); float largestDimension = Math.Max(RegionInfo.RegionSizeX, RegionInfo.RegionSizeY);
@ -405,7 +408,7 @@ namespace OpenSim.Region.Framework.Scenes
private int m_update_events = 1; private int m_update_events = 1;
private int m_update_backup = 200; private int m_update_backup = 200;
private int m_update_terrain = 50; private int m_update_terrain = 50;
// private int m_update_land = 1; // private int m_update_land = 1;
private int m_update_coarse_locations = 50; private int m_update_coarse_locations = 50;
private int m_update_temp_cleaning = 180; private int m_update_temp_cleaning = 180;
@ -528,6 +531,13 @@ namespace OpenSim.Region.Framework.Scenes
get { return m_sceneGraph.PhysicsScene.TimeDilation; } get { return m_sceneGraph.PhysicsScene.TimeDilation; }
} }
public void setThreadCount(int inUseThreads)
{
// Just pass the thread count information on its way as the Scene
// does not require the value for anything at this time
StatsReporter.SetThreadCount(inUseThreads);
}
public SceneCommunicationService SceneGridService public SceneCommunicationService SceneGridService
{ {
get { return m_sceneGridService; } get { return m_sceneGridService; }
@ -795,12 +805,14 @@ namespace OpenSim.Region.Framework.Scenes
// can be closest/random/sequence // can be closest/random/sequence
public string SpawnPointRouting public string SpawnPointRouting
{ {
get; private set; get;
private set;
} }
// allow landmarks to pass // allow landmarks to pass
public bool TelehubAllowLandmarks public bool TelehubAllowLandmarks
{ {
get; private set; get;
private set;
} }
#endregion Properties #endregion Properties
@ -1039,15 +1051,15 @@ namespace OpenSim.Region.Framework.Scenes
if (startupConfig.Contains("MinFrameTime")) if (startupConfig.Contains("MinFrameTime"))
MinFrameTicks = (int)(startupConfig.GetFloat("MinFrameTime") * 1000); MinFrameTicks = (int)(startupConfig.GetFloat("MinFrameTime") * 1000);
m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); m_update_backup = startupConfig.GetInt("UpdateStorageEveryNFrames", m_update_backup);
m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); m_update_coarse_locations = startupConfig.GetInt("UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); m_update_entitymovement = startupConfig.GetInt("UpdateEntityMovementEveryNFrames", m_update_entitymovement);
m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); m_update_events = startupConfig.GetInt("UpdateEventsEveryNFrames", m_update_events);
m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); m_update_objects = startupConfig.GetInt("UpdateObjectsEveryNFrames", m_update_objects);
m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); m_update_physics = startupConfig.GetInt("UpdatePhysicsEveryNFrames", m_update_physics);
m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); m_update_presences = startupConfig.GetInt("UpdateAgentsEveryNFrames", m_update_presences);
m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); m_update_terrain = startupConfig.GetInt("UpdateTerrainEveryNFrames", m_update_terrain);
m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNSeconds", m_update_temp_cleaning); m_update_temp_cleaning = startupConfig.GetInt("UpdateTempCleaningEveryNSeconds", m_update_temp_cleaning);
} }
// FIXME: Ultimately this should be in a module. // FIXME: Ultimately this should be in a module.
@ -1109,6 +1121,14 @@ namespace OpenSim.Region.Framework.Scenes
#endregion Interest Management #endregion Interest Management
// The timer used by the Stopwatch class depends on the system hardware and operating system; inform
// if the timer is based on a high-resolution performance counter or based on the system timer;
// the performance counter will provide a more precise time than the system timer
if (Stopwatch.IsHighResolution)
m_log.InfoFormat("[SCENE]: Using high-resolution performance counter for statistics.");
else
m_log.InfoFormat("[SCENE]: Using system timer for statistics.");
// Acquire the statistics section of the OpenSim.ini file located // Acquire the statistics section of the OpenSim.ini file located
// in the bin directory // in the bin directory
IConfig statisticsConfig = m_config.Configs["Statistics"]; IConfig statisticsConfig = m_config.Configs["Statistics"];
@ -1136,7 +1156,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
public Scene(RegionInfo regInfo, PhysicsScene physicsScene) : base(regInfo) public Scene(RegionInfo regInfo, PhysicsScene physicsScene)
: base(regInfo)
{ {
m_sceneGraph = new SceneGraph(this); m_sceneGraph = new SceneGraph(this);
m_sceneGraph.PhysicsScene = physicsScene; m_sceneGraph.PhysicsScene = physicsScene;
@ -1442,7 +1463,7 @@ namespace OpenSim.Region.Framework.Scenes
m_isRunning = true; m_isRunning = true;
m_active = true; m_active = true;
// m_log.DebugFormat("[SCENE]: Starting Heartbeat timer for {0}", RegionInfo.RegionName); // m_log.DebugFormat("[SCENE]: Starting Heartbeat timer for {0}", RegionInfo.RegionName);
if (m_heartbeatThread != null) if (m_heartbeatThread != null)
{ {
m_heartbeatThread.Abort(); m_heartbeatThread.Abort();
@ -1524,7 +1545,7 @@ namespace OpenSim.Region.Framework.Scenes
// If the last frame did not complete on time, then immediately start the next update on the same thread // If the last frame did not complete on time, then immediately start the next update on the same thread
// and ignore further timed updates until we have a frame that had spare time. // and ignore further timed updates until we have a frame that had spare time.
while (!Update(1) && Active) {} while (!Update(1) && Active) { }
if (!Active || m_shuttingDown) if (!Active || m_shuttingDown)
{ {
@ -1560,7 +1581,7 @@ namespace OpenSim.Region.Framework.Scenes
runtc = Util.EnvironmentTickCount(); runtc = Util.EnvironmentTickCount();
++MaintenanceRun; ++MaintenanceRun;
// m_log.DebugFormat("[SCENE]: Maintenance run {0} in {1}", MaintenanceRun, Name); // m_log.DebugFormat("[SCENE]: Maintenance run {0} in {1}", MaintenanceRun, Name);
// Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client) // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
if (MaintenanceRun % (m_update_coarse_locations / 10) == 0) if (MaintenanceRun % (m_update_coarse_locations / 10) == 0)
@ -1575,7 +1596,7 @@ namespace OpenSim.Region.Framework.Scenes
if (SendPeriodicAppearanceUpdates && MaintenanceRun % 60 == 0) if (SendPeriodicAppearanceUpdates && MaintenanceRun % 60 == 0)
{ {
// m_log.DebugFormat("[SCENE]: Sending periodic appearance updates"); // m_log.DebugFormat("[SCENE]: Sending periodic appearance updates");
if (AvatarFactory != null) if (AvatarFactory != null)
{ {
@ -1586,7 +1607,7 @@ namespace OpenSim.Region.Framework.Scenes
// Delete temp-on-rez stuff // Delete temp-on-rez stuff
if (MaintenanceRun % m_update_temp_cleaning == 0 && !m_cleaningTemps) if (MaintenanceRun % m_update_temp_cleaning == 0 && !m_cleaningTemps)
{ {
// m_log.DebugFormat("[SCENE]: Running temp-on-rez cleaning in {0}", Name); // m_log.DebugFormat("[SCENE]: Running temp-on-rez cleaning in {0}", Name);
tmpMS = Util.EnvironmentTickCount(); tmpMS = Util.EnvironmentTickCount();
m_cleaningTemps = true; m_cleaningTemps = true;
@ -1632,7 +1653,7 @@ namespace OpenSim.Region.Framework.Scenes
// These variables will be used to save the precise frame time using the // These variables will be used to save the precise frame time using the
// Stopwatch class of Microsoft SDK; the times are recorded at the start // Stopwatch class of Microsoft SDK; the times are recorded at the start
// and end of a particular section of code, and then used to calculate // and end of a parcticular section of code, and then used to calculate
// the frame times, which are the sums of the sections for each given name // the frame times, which are the sums of the sections for each given name
double preciseTotalFrameTime = 0.0; double preciseTotalFrameTime = 0.0;
double preciseSimFrameTime = 0.0; double preciseSimFrameTime = 0.0;
@ -1649,7 +1670,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
++Frame; ++Frame;
// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
agentMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; agentMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0;
@ -1670,7 +1691,6 @@ namespace OpenSim.Region.Framework.Scenes
// at this point in time, the precise values all begin // at this point in time, the precise values all begin
// with the keyword precise // with the keyword precise
tmpMS = Util.EnvironmentTickCount(); tmpMS = Util.EnvironmentTickCount();
simFrameStopwatch.Start(); simFrameStopwatch.Start();
UpdateTerrain(); UpdateTerrain();
@ -1682,6 +1702,16 @@ namespace OpenSim.Region.Framework.Scenes
terrainMS = Util.EnvironmentTickCountSubtract(tmpMS); terrainMS = Util.EnvironmentTickCountSubtract(tmpMS);
} }
// At several points inside the code there was a need to
// create a more precise measurement of time elapsed. This
// led to the addition of variables that have a similar
// function and thus remain tightly connected to their
// original counterparts. However, the original code is
// not receiving comments from our group because we don't
// feel right modifying the code to that degree at this
// point in time, the precise values all begin with the
// keyword precise
tmpMS = Util.EnvironmentTickCount(); tmpMS = Util.EnvironmentTickCount();
// Begin the stopwatch to track the time to prepare physics // Begin the stopwatch to track the time to prepare physics
@ -1695,8 +1725,7 @@ namespace OpenSim.Region.Framework.Scenes
// enabled will report the time it took to check if physics // enabled will report the time it took to check if physics
// was enabled // was enabled
physicsFrameStopwatch.Stop(); physicsFrameStopwatch.Stop();
precisePhysicsFrameTime = precisePhysicsFrameTime = physicsFrameStopwatch.Elapsed.TotalMilliseconds;
physicsFrameStopwatch.Elapsed.TotalMilliseconds;
physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
// Apply any pending avatar force input to the avatar's velocity // Apply any pending avatar force input to the avatar's velocity
@ -1725,11 +1754,9 @@ namespace OpenSim.Region.Framework.Scenes
SynchronizeScene(this); SynchronizeScene(this);
} }
// Add the main physics update time to the prepare physics // Add the main physics update time to the prepare physics time
// time
physicsFrameStopwatch.Stop(); physicsFrameStopwatch.Stop();
precisePhysicsFrameTime += precisePhysicsFrameTime += physicsFrameStopwatch.Elapsed.TotalMilliseconds;
physicsFrameStopwatch.Elapsed.TotalMilliseconds;
physicsMS = Util.EnvironmentTickCountSubtract(tmpMS); physicsMS = Util.EnvironmentTickCountSubtract(tmpMS);
// Start the stopwatch for the remainder of the simulation // Start the stopwatch for the remainder of the simulation
@ -1887,6 +1914,9 @@ namespace OpenSim.Region.Framework.Scenes
RegionInfo.RegionName); RegionInfo.RegionName);
} }
// Finished updating scene frame, so stop the total frame's Stopwatch
totalFrameStopwatch.Stop();
return spareMS >= 0; return spareMS >= 0;
} }
@ -2004,7 +2034,7 @@ namespace OpenSim.Region.Framework.Scenes
IMessageTransferModule tr = RequestModuleInterface<IMessageTransferModule>(); IMessageTransferModule tr = RequestModuleInterface<IMessageTransferModule>();
if (tr != null) if (tr != null)
tr.SendInstantMessage(msg, delegate(bool success) {}); tr.SendInstantMessage(msg, delegate(bool success) { });
} }
m_returns.Clear(); m_returns.Clear();
} }
@ -2114,7 +2144,7 @@ namespace OpenSim.Region.Framework.Scenes
e.Message, e.StackTrace); e.Message, e.StackTrace);
// Non standard region size. If there's an old terrain in the database, it might read past the buffer // Non standard region size. If there's an old terrain in the database, it might read past the buffer
#pragma warning disable 0162 #pragma warning disable 0162
if ((int)Constants.RegionSize != 256) if ((int)Constants.RegionSize != 256)
{ {
Heightmap = new TerrainChannel(); Heightmap = new TerrainChannel();
@ -2146,11 +2176,11 @@ namespace OpenSim.Region.Framework.Scenes
GridRegion region = new GridRegion(RegionInfo); GridRegion region = new GridRegion(RegionInfo);
string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
// m_log.DebugFormat("[SCENE]: RegisterRegionWithGrid. name={0},id={1},loc=<{2},{3}>,size=<{4},{5}>", // m_log.DebugFormat("[SCENE]: RegisterRegionWithGrid. name={0},id={1},loc=<{2},{3}>,size=<{4},{5}>",
// m_regionName, // m_regionName,
// RegionInfo.RegionID, // RegionInfo.RegionID,
// RegionInfo.RegionLocX, RegionInfo.RegionLocY, // RegionInfo.RegionLocX, RegionInfo.RegionLocY,
// RegionInfo.RegionSizeX, RegionInfo.RegionSizeY); // RegionInfo.RegionSizeX, RegionInfo.RegionSizeY);
if (error != String.Empty) if (error != String.Empty)
throw new Exception(error); throw new Exception(error);
@ -2212,7 +2242,7 @@ namespace OpenSim.Region.Framework.Scenes
rootPart.TrimPermissions(); rootPart.TrimPermissions();
// Don't do this here - it will get done later on when sculpt data is loaded. // Don't do this here - it will get done later on when sculpt data is loaded.
// group.CheckSculptAndLoad(); // group.CheckSculptAndLoad();
} }
LoadingPrims = false; LoadingPrims = false;
@ -2230,7 +2260,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (PhysicsScene == null) if (PhysicsScene == null)
return null; return null;
return PhysicsScene.RaycastWorld(position, direction, length, Count,filter); return PhysicsScene.RaycastWorld(position, direction, length, Count, filter);
} }
/// <summary> /// <summary>
@ -2558,7 +2588,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="removeScripts">If true, then scripts are removed. If false, then they are only stopped.</para> /// <param name="removeScripts">If true, then scripts are removed. If false, then they are only stopped.</para>
public void DeleteSceneObject(SceneObjectGroup group, bool silent, bool removeScripts) public void DeleteSceneObject(SceneObjectGroup group, bool silent, bool removeScripts)
{ {
// m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); // m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID);
if (removeScripts) if (removeScripts)
group.RemoveScriptInstances(true); group.RemoveScriptInstances(true);
@ -2593,7 +2623,7 @@ namespace OpenSim.Region.Framework.Scenes
group.DeleteGroupFromScene(silent); group.DeleteGroupFromScene(silent);
// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
} }
/// <summary> /// <summary>
@ -2693,7 +2723,7 @@ namespace OpenSim.Region.Framework.Scenes
if (regionCombinerModule == null) if (regionCombinerModule == null)
{ {
// Regular region. Just check for region size // Regular region. Just check for region size
if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY ) if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY)
ret = true; ret = true;
} }
else else
@ -2770,10 +2800,10 @@ namespace OpenSim.Region.Framework.Scenes
{ {
SceneObjectGroup grp = sceneObject; SceneObjectGroup grp = sceneObject;
// m_log.DebugFormat( // m_log.DebugFormat(
// "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID); // "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID);
// m_log.DebugFormat( // m_log.DebugFormat(
// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); // "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
RootPrim.RemFlag(PrimFlags.TemporaryOnRez); RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
@ -2807,6 +2837,9 @@ namespace OpenSim.Region.Framework.Scenes
bool vialogin; bool vialogin;
bool reallyNew = true; bool reallyNew = true;
// Update the number of users attempting to login
StatsReporter.UpdateUsersLoggingIn(true);
// Validation occurs in LLUDPServer // Validation occurs in LLUDPServer
// //
// XXX: A race condition exists here where two simultaneous calls to AddNewAgent can interfere with // XXX: A race condition exists here where two simultaneous calls to AddNewAgent can interfere with
@ -2891,6 +2924,10 @@ namespace OpenSim.Region.Framework.Scenes
EventManager.TriggerOnClientLogin(client); EventManager.TriggerOnClientLogin(client);
} }
// User has logged into the scene so update the list of users logging
// in
StatsReporter.UpdateUsersLoggingIn(false);
m_LastLogin = Util.EnvironmentTickCount(); m_LastLogin = Util.EnvironmentTickCount();
return sp; return sp;
@ -3743,15 +3780,15 @@ namespace OpenSim.Region.Framework.Scenes
// vulnerable to an issue when a viewer quits a region without sending a proper logout but then // vulnerable to an issue when a viewer quits a region without sending a proper logout but then
// re-establishes the connection on a relogin. This could wrongly set the DoNotCloseAfterTeleport // re-establishes the connection on a relogin. This could wrongly set the DoNotCloseAfterTeleport
// flag when no teleport had taken place (and hence no close was going to come). // flag when no teleport had taken place (and hence no close was going to come).
// if (!acd.ChildrenCapSeeds.ContainsKey(RegionInfo.RegionHandle)) // if (!acd.ChildrenCapSeeds.ContainsKey(RegionInfo.RegionHandle))
// { // {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE]: Setting DoNotCloseAfterTeleport for child scene presence {0} in {1} because source will attempt close.", // "[SCENE]: Setting DoNotCloseAfterTeleport for child scene presence {0} in {1} because source will attempt close.",
// sp.Name, Name); // sp.Name, Name);
// //
// sp.DoNotCloseAfterTeleport = true; // sp.DoNotCloseAfterTeleport = true;
// } // }
// else if (EntityTransferModule.IsInTransit(sp.UUID)) // else if (EntityTransferModule.IsInTransit(sp.UUID))
sp.LifecycleState = ScenePresenceState.Running; sp.LifecycleState = ScenePresenceState.Running;
@ -3915,7 +3952,7 @@ namespace OpenSim.Region.Framework.Scenes
if (vialogin) if (vialogin)
{ {
// CleanDroppedAttachments(); // CleanDroppedAttachments();
// Make sure avatar position is in the region (why it wouldn't be is a mystery but do sanity checking) // Make sure avatar position is in the region (why it wouldn't be is a mystery but do sanity checking)
if (acd.startpos.X < 0) acd.startpos.X = 1f; if (acd.startpos.X < 0) acd.startpos.X = 1f;
@ -3923,9 +3960,9 @@ namespace OpenSim.Region.Framework.Scenes
if (acd.startpos.Y < 0) acd.startpos.Y = 1f; if (acd.startpos.Y < 0) acd.startpos.Y = 1f;
if (acd.startpos.Y >= RegionInfo.RegionSizeY) acd.startpos.Y = RegionInfo.RegionSizeY - 1f; if (acd.startpos.Y >= RegionInfo.RegionSizeY) acd.startpos.Y = RegionInfo.RegionSizeY - 1f;
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE]: Found telehub object {0} for new user connection {1} to {2}", // "[SCENE]: Found telehub object {0} for new user connection {1} to {2}",
// RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); // RegionInfo.RegionSettings.TelehubObject, acd.Name, Name);
// Honor Estate teleport routing via Telehubs excluding ViaHome and GodLike TeleportFlags // Honor Estate teleport routing via Telehubs excluding ViaHome and GodLike TeleportFlags
if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero && if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero &&
@ -4242,69 +4279,69 @@ namespace OpenSim.Region.Framework.Scenes
return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc);
} }
// /// <summary> // /// <summary>
// /// The Grid has requested that we log-off a user. Log them off. // /// The Grid has requested that we log-off a user. Log them off.
// /// </summary> // /// </summary>
// /// <param name="AvatarID">Unique ID of the avatar to log-off</param> // /// <param name="AvatarID">Unique ID of the avatar to log-off</param>
// /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param> // /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param>
// /// <param name="message">message to display to the user. Reason for being logged off</param> // /// <param name="message">message to display to the user. Reason for being logged off</param>
// public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) // public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
// { // {
// ScenePresence loggingOffUser = GetScenePresence(AvatarID); // ScenePresence loggingOffUser = GetScenePresence(AvatarID);
// if (loggingOffUser != null) // if (loggingOffUser != null)
// { // {
// UUID localRegionSecret = UUID.Zero; // UUID localRegionSecret = UUID.Zero;
// bool parsedsecret = UUID.TryParse(RegionInfo.regionSecret, out localRegionSecret); // bool parsedsecret = UUID.TryParse(RegionInfo.regionSecret, out localRegionSecret);
// //
// // Region Secret is used here in case a new sessionid overwrites an old one on the user server. // // Region Secret is used here in case a new sessionid overwrites an old one on the user server.
// // Will update the user server in a few revisions to use it. // // Will update the user server in a few revisions to use it.
// //
// if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) // if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret))
// { // {
// m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); // m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles);
// loggingOffUser.ControllingClient.Kick(message); // loggingOffUser.ControllingClient.Kick(message);
// // Give them a second to receive the message! // // Give them a second to receive the message!
// Thread.Sleep(1000); // Thread.Sleep(1000);
// loggingOffUser.ControllingClient.Close(); // loggingOffUser.ControllingClient.Close();
// } // }
// else // else
// { // {
// m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); // m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate");
// } // }
// } // }
// else // else
// { // {
// m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString()); // m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString());
// } // }
// } // }
// /// <summary> // /// <summary>
// /// Triggered when an agent crosses into this sim. Also happens on initial login. // /// Triggered when an agent crosses into this sim. Also happens on initial login.
// /// </summary> // /// </summary>
// /// <param name="agentID"></param> // /// <param name="agentID"></param>
// /// <param name="position"></param> // /// <param name="position"></param>
// /// <param name="isFlying"></param> // /// <param name="isFlying"></param>
// public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) // public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
// { // {
// ScenePresence presence = GetScenePresence(agentID); // ScenePresence presence = GetScenePresence(agentID);
// if (presence != null) // if (presence != null)
// { // {
// try // try
// { // {
// presence.MakeRootAgent(position, isFlying); // presence.MakeRootAgent(position, isFlying);
// } // }
// catch (Exception e) // catch (Exception e)
// { // {
// m_log.ErrorFormat("[SCENE]: Unable to do agent crossing, exception {0}{1}", e.Message, e.StackTrace); // m_log.ErrorFormat("[SCENE]: Unable to do agent crossing, exception {0}{1}", e.Message, e.StackTrace);
// } // }
// } // }
// else // else
// { // {
// m_log.ErrorFormat( // m_log.ErrorFormat(
// "[SCENE]: Could not find presence for agent {0} crossing into scene {1}", // "[SCENE]: Could not find presence for agent {0} crossing into scene {1}",
// agentID, RegionInfo.RegionName); // agentID, RegionInfo.RegionName);
// } // }
// } // }
/// <summary> /// <summary>
/// We've got an update about an agent that sees into this region, /// We've got an update about an agent that sees into this region,
@ -4382,17 +4419,17 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns>true if we handled it.</returns> /// <returns>true if we handled it.</returns>
public virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData) public virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE PRESENCE]: IncomingChildAgentDataUpdate POSITION for {0} in {1}, position {2}", // "[SCENE PRESENCE]: IncomingChildAgentDataUpdate POSITION for {0} in {1}, position {2}",
// cAgentData.AgentID, Name, cAgentData.Position); // cAgentData.AgentID, Name, cAgentData.Position);
ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID); ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID);
if (childAgentUpdate != null) if (childAgentUpdate != null)
{ {
// if (childAgentUpdate.ControllingClient.SessionId != cAgentData.SessionID) // if (childAgentUpdate.ControllingClient.SessionId != cAgentData.SessionID)
// // Only warn for now // // Only warn for now
// m_log.WarnFormat("[SCENE]: Attempt at updating position of agent {0} with invalid session id {1}. Neighbor running older version?", // m_log.WarnFormat("[SCENE]: Attempt at updating position of agent {0} with invalid session id {1}. Neighbor running older version?",
// childAgentUpdate.UUID, cAgentData.SessionID); // childAgentUpdate.UUID, cAgentData.SessionID);
// I can't imagine *yet* why we would get an update if the agent is a root agent.. // I can't imagine *yet* why we would get an update if the agent is a root agent..
// however to avoid a race condition crossing borders.. // however to avoid a race condition crossing borders..
@ -4752,7 +4789,7 @@ namespace OpenSim.Region.Framework.Scenes
#region Script Engine #region Script Engine
private bool ScriptDanger(SceneObjectPart part,Vector3 pos) private bool ScriptDanger(SceneObjectPart part, Vector3 pos)
{ {
ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
if (part != null) if (part != null)
@ -5110,15 +5147,15 @@ namespace OpenSim.Region.Framework.Scenes
#endregion #endregion
// Commented pending deletion since this method no longer appears to do anything at all // Commented pending deletion since this method no longer appears to do anything at all
// public bool NeedSceneCacheClear(UUID agentID) // public bool NeedSceneCacheClear(UUID agentID)
// { // {
// IInventoryTransferModule inv = RequestModuleInterface<IInventoryTransferModule>(); // IInventoryTransferModule inv = RequestModuleInterface<IInventoryTransferModule>();
// if (inv == null) // if (inv == null)
// return true; // return true;
// //
// return inv.NeedSceneCacheClear(agentID, this); // return inv.NeedSceneCacheClear(agentID, this);
// } // }
public void CleanTempObjects() public void CleanTempObjects()
{ {
@ -5160,7 +5197,7 @@ namespace OpenSim.Region.Framework.Scenes
// 3 = We have seen a new user enter within the past 4 minutes // 3 = We have seen a new user enter within the past 4 minutes
// which can be seen as positive confirmation of sim health // which can be seen as positive confirmation of sim health
// //
int health=1; // Start at 1, means we're up int health = 1; // Start at 1, means we're up
if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
health += 1; health += 1;
@ -5174,7 +5211,7 @@ namespace OpenSim.Region.Framework.Scenes
else else
return health; return health;
// CheckHeartbeat(); // CheckHeartbeat();
return health; return health;
} }
@ -5366,14 +5403,14 @@ namespace OpenSim.Region.Framework.Scenes
return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
} }
// private void CheckHeartbeat() // private void CheckHeartbeat()
// { // {
// if (m_firstHeartbeat) // if (m_firstHeartbeat)
// return; // return;
// //
// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000)
// StartTimer(); // StartTimer();
// } // }
public override ISceneObject DeserializeObject(string representation) public override ISceneObject DeserializeObject(string representation)
{ {
@ -5637,9 +5674,9 @@ namespace OpenSim.Region.Framework.Scenes
g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE]: For {0} found AxisAlignedBoundingBoxRaw {1}, {2}", // "[SCENE]: For {0} found AxisAlignedBoundingBoxRaw {1}, {2}",
// g.Name, new Vector3(ominX, ominY, ominZ), new Vector3(omaxX, omaxY, omaxZ)); // g.Name, new Vector3(ominX, ominY, ominZ), new Vector3(omaxX, omaxY, omaxZ));
ominX += vec.X; ominX += vec.X;
omaxX += vec.X; omaxX += vec.X;
@ -5778,7 +5815,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
catch (Exception e) catch (Exception e)
{ {
m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} " + e.StackTrace, e.Message);
reason = "Error authorizing agent: " + e.Message; reason = "Error authorizing agent: " + e.Message;
return false; return false;
} }
@ -5806,7 +5843,7 @@ namespace OpenSim.Region.Framework.Scenes
if (banned) if (banned)
{ {
if(Permissions.IsAdministrator(agentID) == false || Permissions.IsGridGod(agentID) == false) if (Permissions.IsAdministrator(agentID) == false || Permissions.IsGridGod(agentID) == false)
{ {
reason = "No suitable landing point found"; reason = "No suitable landing point found";
return false; return false;
@ -5866,15 +5903,15 @@ namespace OpenSim.Region.Framework.Scenes
if (presence.MovingToTarget) if (presence.MovingToTarget)
{ {
double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget); double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget);
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE]: Abs pos of {0} is {1}, target {2}, distance {3}", // "[SCENE]: Abs pos of {0} is {1}, target {2}, distance {3}",
// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget); // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget);
// Check the error term of the current position in relation to the target position // Check the error term of the current position in relation to the target position
if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT) if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT)
{ {
// We are close enough to the target // We are close enough to the target
// m_log.DebugFormat("[SCENEE]: Stopping autopilot of {0}", presence.Name); // m_log.DebugFormat("[SCENEE]: Stopping autopilot of {0}", presence.Name);
presence.Velocity = Vector3.Zero; presence.Velocity = Vector3.Zero;
presence.AbsolutePosition = presence.MoveToPositionTarget; presence.AbsolutePosition = presence.MoveToPositionTarget;
@ -5893,23 +5930,23 @@ namespace OpenSim.Region.Framework.Scenes
if (presence.LandAtTarget) if (presence.LandAtTarget)
presence.Flying = false; presence.Flying = false;
// Vector3 targetPos = presence.MoveToPositionTarget; // Vector3 targetPos = presence.MoveToPositionTarget;
// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; // float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
// if (targetPos.Z - terrainHeight < 0.2) // if (targetPos.Z - terrainHeight < 0.2)
// { // {
// presence.Flying = false; // presence.Flying = false;
// } // }
} }
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE]: AgentControlFlags {0}, MovementFlag {1} for {2}", // "[SCENE]: AgentControlFlags {0}, MovementFlag {1} for {2}",
// presence.AgentControlFlags, presence.MovementFlag, presence.Name); // presence.AgentControlFlags, presence.MovementFlag, presence.Name);
} }
else else
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE]: Updating npc {0} at {1} for next movement to {2}", // "[SCENE]: Updating npc {0} at {1} for next movement to {2}",
// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget);
Vector3 agent_control_v3 = new Vector3(); Vector3 agent_control_v3 = new Vector3();
presence.HandleMoveToTargetUpdate(1, ref agent_control_v3); presence.HandleMoveToTargetUpdate(1, ref agent_control_v3);

59
OpenSim/Region/Framework/Scenes/SceneGraph.cs Normal file → Executable file
View File

@ -67,7 +67,9 @@ namespace OpenSim.Region.Framework.Scenes
protected Scene m_parentScene; protected Scene m_parentScene;
protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>(); protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>();
protected int m_numRootAgents = 0; protected int m_numRootAgents = 0;
protected int m_numTotalPrim = 0;
protected int m_numPrim = 0; protected int m_numPrim = 0;
protected int m_numMesh = 0;
protected int m_numChildAgents = 0; protected int m_numChildAgents = 0;
protected int m_physicalPrim = 0; protected int m_physicalPrim = 0;
@ -368,7 +370,8 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart[] parts = sceneObject.Parts; SceneObjectPart[] parts = sceneObject.Parts;
// Clamp child prim sizes and add child prims to the m_numPrim count // Clamp the sizes (scales) of the child prims and add the child prims to the count of all primitives
// (meshes and geometric primitives) in the scene; add child prims to m_numTotalPrim count
if (m_parentScene.m_clampPrimSize) if (m_parentScene.m_clampPrimSize)
{ {
foreach (SceneObjectPart part in parts) foreach (SceneObjectPart part in parts)
@ -382,7 +385,19 @@ namespace OpenSim.Region.Framework.Scenes
part.Shape.Scale = scale; part.Shape.Scale = scale;
} }
} }
m_numPrim += parts.Length; m_numTotalPrim += parts.Length;
// Go through all parts (geometric primitives and meshes) of this Scene Object
foreach (SceneObjectPart part in parts)
{
// Keep track of the total number of meshes or geometric primitives now in the scene;
// determine which object this is based on its primitive type: sculpted (sculpt) prim refers to
// a mesh and all other prims (i.e. box, sphere, etc) are geometric primitives
if (part.GetPrimType() == PrimType.SCULPT)
m_numMesh++;
else
m_numPrim++;
}
sceneObject.AttachToScene(m_parentScene); sceneObject.AttachToScene(m_parentScene);
@ -437,7 +452,21 @@ namespace OpenSim.Region.Framework.Scenes
if (!resultOfObjectLinked) if (!resultOfObjectLinked)
{ {
m_numPrim -= grp.PrimCount; // Decrement the total number of primitives (meshes and geometric primitives)
// that are part of the Scene Object being removed
m_numTotalPrim -= grp.PrimCount;
// Go through all parts (primitives and meshes) of this Scene Object
foreach (SceneObjectPart part in grp.Parts)
{
// Keep track of the total number of meshes or geometric primitives left in the scene;
// determine which object this is based on its primitive type: sculpted (sculpt) prim refers to
// a mesh and all other prims (i.e. box, sphere, etc) are geometric primitives
if (part.GetPrimType() == PrimType.SCULPT)
m_numMesh--;
else
m_numPrim--;
}
if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics)
RemovePhysicalPrim(grp.PrimCount); RemovePhysicalPrim(grp.PrimCount);
@ -686,10 +715,20 @@ namespace OpenSim.Region.Framework.Scenes
} }
public int GetTotalObjectsCount() public int GetTotalObjectsCount()
{
return m_numTotalPrim;
}
public int GetTotalPrimObjectsCount()
{ {
return m_numPrim; return m_numPrim;
} }
public int GetTotalMeshObjectsCount()
{
return m_numMesh;
}
public int GetActiveObjectsCount() public int GetActiveObjectsCount()
{ {
return m_physicalPrim; return m_physicalPrim;
@ -1970,7 +2009,19 @@ namespace OpenSim.Region.Framework.Scenes
// think it's selected, so it will never send a deselect... // think it's selected, so it will never send a deselect...
copy.IsSelected = false; copy.IsSelected = false;
m_numPrim += copy.Parts.Length; m_numTotalPrim += copy.Parts.Length;
// Go through all parts (primitives and meshes) of this Scene Object
foreach (SceneObjectPart part in copy.Parts)
{
// Keep track of the total number of meshes or geometric primitives now in the scene;
// determine which object this is based on its primitive type: sculpted (sculpt) prim refers to
// a mesh and all other prims (i.e. box, sphere, etc) are geometric primitives
if (part.GetPrimType() == PrimType.SCULPT)
m_numMesh++;
else
m_numPrim++;
}
if (rot != Quaternion.Identity) if (rot != Quaternion.Identity)
{ {

View File

@ -61,6 +61,10 @@ namespace OpenSim.Region.Framework.Scenes
private YourStatsAreWrong handlerStatsIncorrect; private YourStatsAreWrong handlerStatsIncorrect;
// Determines the size of the array that is used to collect StatBlocks
// for sending to the SimStats and SimExtraStatsCollector
private const int m_statisticArraySize = 27;
/// <summary> /// <summary>
/// These are the IDs of stats sent in the StatsPacket to the viewer. /// These are the IDs of stats sent in the StatsPacket to the viewer.
/// </summary> /// </summary>
@ -104,7 +108,12 @@ namespace OpenSim.Region.Framework.Scenes
ScriptEps = 31, ScriptEps = 31,
SimSpareMs = 32, SimSpareMs = 32,
SimSleepMs = 33, SimSleepMs = 33,
SimIoPumpTime = 34 SimIoPumpTime = 34,
FrameDilation = 35,
UsersLoggingIn = 36,
TotalGeoPrim = 37,
TotalMesh = 38,
ThreadCount = 39
} }
/// <summary> /// <summary>
@ -175,7 +184,7 @@ namespace OpenSim.Region.Framework.Scenes
// saved last reported value so there is something available for llGetRegionFPS // saved last reported value so there is something available for llGetRegionFPS
private float lastReportedSimFPS; private float lastReportedSimFPS;
private float[] lastReportedSimStats = new float[22]; private float[] lastReportedSimStats = new float[m_statisticArraySize];
private float m_pfps; private float m_pfps;
/// <summary> /// <summary>
@ -202,6 +211,8 @@ namespace OpenSim.Region.Framework.Scenes
private int m_rootAgents; private int m_rootAgents;
private int m_childAgents; private int m_childAgents;
private int m_numPrim; private int m_numPrim;
private int m_numGeoPrim;
private int m_numMesh;
private int m_inPacketsPerSecond; private int m_inPacketsPerSecond;
private int m_outPacketsPerSecond; private int m_outPacketsPerSecond;
private int m_activePrim; private int m_activePrim;
@ -234,6 +245,13 @@ namespace OpenSim.Region.Framework.Scenes
// update for physics // update for physics
private int m_numberPhysicsFrames; private int m_numberPhysicsFrames;
// The current number of users attempting to login to the region
private int m_usersLoggingIn;
// The last reported value of threads from the SmartThreadPool inside of
// XEngine
private int m_inUseThreads;
private Scene m_scene; private Scene m_scene;
private RegionInfo ReportingRegion; private RegionInfo ReportingRegion;
@ -246,11 +264,13 @@ namespace OpenSim.Region.Framework.Scenes
{ {
// Initialize the different frame time arrays to the correct sizes // Initialize the different frame time arrays to the correct sizes
m_totalFrameTimeMilliseconds = new double[m_numberFramesStored]; m_totalFrameTimeMilliseconds = new double[m_numberFramesStored];
m_simulationFrameTimeMilliseconds = new m_simulationFrameTimeMilliseconds = new double[m_numberFramesStored];
double[m_numberFramesStored];
m_physicsFrameTimeMilliseconds = new double[m_numberFramesStored]; m_physicsFrameTimeMilliseconds = new double[m_numberFramesStored];
m_networkFrameTimeMilliseconds = new double[m_numberFramesStored]; m_networkFrameTimeMilliseconds = new double[m_numberFramesStored];
// Initialize the current number of users logging into the region
m_usersLoggingIn = 0;
m_scene = scene; m_scene = scene;
m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps; m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps;
m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000); m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
@ -284,13 +304,14 @@ namespace OpenSim.Region.Framework.Scenes
StatsManager.RegisterStat(SlowFramesStat); StatsManager.RegisterStat(SlowFramesStat);
} }
public SimStatsReporter(Scene scene, int numberOfFrames) : this (scene) public SimStatsReporter(Scene scene, int numberOfFrames) : this (scene)
{ {
// Store the number of frames from the OpenSim.ini configuration // Store the number of frames from the OpenSim.ini configuration file
// file
m_numberFramesStored = numberOfFrames; m_numberFramesStored = numberOfFrames;
} }
public void Close() public void Close()
{ {
m_report.Elapsed -= TriggerStatsHeartbeat; m_report.Elapsed -= TriggerStatsHeartbeat;
@ -328,11 +349,17 @@ namespace OpenSim.Region.Framework.Scenes
double simulationSumFrameTime; double simulationSumFrameTime;
double physicsSumFrameTime; double physicsSumFrameTime;
double networkSumFrameTime; double networkSumFrameTime;
float frameDilation;
int currentFrame;
if (!m_scene.Active) if (!m_scene.Active)
return; return;
SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; // Create arrays to hold the statistics for this current scene,
// these will be passed to the SimExtraStatsCollector, they are also
// sent to the SimStats class
SimStatsPacket.StatBlock[] sb = new
SimStatsPacket.StatBlock[m_statisticArraySize];
SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
// Know what's not thread safe in Mono... modifying timers. // Know what's not thread safe in Mono... modifying timers.
@ -381,6 +408,8 @@ namespace OpenSim.Region.Framework.Scenes
m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount(); m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount();
m_numGeoPrim = m_scene.SceneGraph.GetTotalPrimObjectsCount();
m_numMesh = m_scene.SceneGraph.GetTotalMeshObjectsCount();
m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount();
m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();
@ -406,7 +435,7 @@ namespace OpenSim.Region.Framework.Scenes
if (framesUpdated == 0) if (framesUpdated == 0)
framesUpdated = 1; framesUpdated = 1;
for (int i = 0; i < 22; i++) for (int i = 0; i < m_statisticArraySize; i++)
{ {
sb[i] = new SimStatsPacket.StatBlock(); sb[i] = new SimStatsPacket.StatBlock();
} }
@ -431,6 +460,19 @@ namespace OpenSim.Region.Framework.Scenes
networkSumFrameTime += m_networkFrameTimeMilliseconds[i]; networkSumFrameTime += m_networkFrameTimeMilliseconds[i];
} }
// Get the index that represents the current frame based on the next one known; go back
// to the last index if next one is stated to restart at 0
if (m_nextLocation == 0)
currentFrame = m_numberFramesStored - 1;
else
currentFrame = m_nextLocation - 1;
// Calculate the frame dilation; which is currently based on the ratio between the sum of the
// physics and simulation rate, and the set minimum time to run a scene's frame
frameDilation = (float)(m_simulationFrameTimeMilliseconds[currentFrame] +
m_physicsFrameTimeMilliseconds[currentFrame]) / m_scene.MinFrameTicks;
// ORIGINAL code commented out until we have time to add our own
sb[0].StatID = (uint) Stats.TimeDilation; sb[0].StatID = (uint) Stats.TimeDilation;
sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
@ -459,18 +501,15 @@ namespace OpenSim.Region.Framework.Scenes
// statistics to the statistics window // statistics to the statistics window
sb[8].StatID = (uint)Stats.FrameMS; sb[8].StatID = (uint)Stats.FrameMS;
//sb[8].StatValue = m_frameMS / framesUpdated; //sb[8].StatValue = m_frameMS / framesUpdated;
sb[8].StatValue = (float) totalSumFrameTime / sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored;
m_numberFramesStored;
sb[9].StatID = (uint)Stats.NetMS; sb[9].StatID = (uint)Stats.NetMS;
//sb[9].StatValue = m_netMS / framesUpdated; //sb[9].StatValue = m_netMS / framesUpdated;
sb[9].StatValue = (float) networkSumFrameTime / sb[9].StatValue = (float) networkSumFrameTime / m_numberFramesStored;
m_numberFramesStored;
sb[10].StatID = (uint)Stats.PhysicsMS; sb[10].StatID = (uint)Stats.PhysicsMS;
//sb[10].StatValue = m_physicsMS / framesUpdated; //sb[10].StatValue = m_physicsMS / framesUpdated;
sb[10].StatValue = (float) physicsSumFrameTime / sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored;
m_numberFramesStored;
sb[11].StatID = (uint)Stats.ImageMS ; sb[11].StatID = (uint)Stats.ImageMS ;
sb[11].StatValue = m_imageMS / framesUpdated; sb[11].StatValue = m_imageMS / framesUpdated;
@ -507,7 +546,28 @@ namespace OpenSim.Region.Framework.Scenes
sb[21].StatID = (uint)Stats.SimSpareMs; sb[21].StatID = (uint)Stats.SimSpareMs;
sb[21].StatValue = m_spareMS / framesUpdated; sb[21].StatValue = m_spareMS / framesUpdated;
for (int i = 0; i < 22; i++) // Current ratio between the sum of physics and sim rate, and the
// minimum time to run a scene's frame
sb[22].StatID = (uint)Stats.FrameDilation;
sb[22].StatValue = frameDilation;
// Current number of users currently attemptint to login to region
sb[23].StatID = (uint)Stats.UsersLoggingIn;
sb[23].StatValue = m_usersLoggingIn;
// Total number of geometric primitives in the scene
sb[24].StatID = (uint)Stats.TotalGeoPrim;
sb[24].StatValue = m_numGeoPrim;
// Total number of mesh objects in the scene
sb[25].StatID = (uint)Stats.TotalMesh;
sb[25].StatValue = m_numMesh;
// Current number of threads that XEngine is using
sb[26].StatID = (uint)Stats.ThreadCount;
sb[26].StatValue = m_inUseThreads;
for (int i = 0; i < m_statisticArraySize; i++)
{ {
lastReportedSimStats[i] = sb[i].StatValue; lastReportedSimStats[i] = sb[i].StatValue;
} }
@ -734,6 +794,31 @@ namespace OpenSim.Region.Framework.Scenes
AddunAckedBytes(unAckedBytes); AddunAckedBytes(unAckedBytes);
} }
public void UpdateUsersLoggingIn(bool isLoggingIn)
{
// Determine whether the user has started logging in or has completed
// logging into the region
if (isLoggingIn)
{
// The user is starting to login to the region so increment the
// number of users attempting to login to the region
m_usersLoggingIn++;
}
else
{
// The user has finished logging into the region so decrement the
// number of users logging into the region
m_usersLoggingIn--;
}
}
public void SetThreadCount(int inUseThreads)
{
// Save the new number of threads to our member variable to send to
// the extra stats collector
m_inUseThreads = inUseThreads;
}
#endregion #endregion
public Dictionary<string, float> GetExtraSimStats() public Dictionary<string, float> GetExtraSimStats()

36
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs Normal file → Executable file
View File

@ -1872,6 +1872,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
IScriptInstance instance = GetInstance(itemID); IScriptInstance instance = GetInstance(itemID);
if (instance != null) if (instance != null)
instance.ApiResetScript(); instance.ApiResetScript();
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
} }
public void ResetScript(UUID itemID) public void ResetScript(UUID itemID)
@ -1879,6 +1885,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
IScriptInstance instance = GetInstance(itemID); IScriptInstance instance = GetInstance(itemID);
if (instance != null) if (instance != null)
instance.ResetScript(m_WaitForEventCompletionOnScriptStop); instance.ResetScript(m_WaitForEventCompletionOnScriptStop);
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
} }
public void StartScript(UUID itemID) public void StartScript(UUID itemID)
@ -1888,6 +1900,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
instance.Start(); instance.Start();
else else
m_runFlags.AddOrUpdate(itemID, true, 240); m_runFlags.AddOrUpdate(itemID, true, 240);
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
} }
public void StopScript(UUID itemID) public void StopScript(UUID itemID)
@ -1903,6 +1921,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// m_log.DebugFormat("[XENGINE]: Could not find script with ID {0} to stop in {1}", itemID, World.Name); // m_log.DebugFormat("[XENGINE]: Could not find script with ID {0} to stop in {1}", itemID, World.Name);
m_runFlags.AddOrUpdate(itemID, false, 240); m_runFlags.AddOrUpdate(itemID, false, 240);
} }
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
} }
public DetectParams GetDetectParams(UUID itemID, int idx) public DetectParams GetDetectParams(UUID itemID, int idx)
@ -2393,6 +2417,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
instance.Suspend(); instance.Suspend();
// else // else
// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID); // m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID);
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
} }
public void ResumeScript(UUID itemID) public void ResumeScript(UUID itemID)
@ -2404,6 +2434,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
instance.Resume(); instance.Resume();
// else // else
// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID); // m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID);
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
} }
public bool HasScript(UUID itemID, out bool running) public bool HasScript(UUID itemID, out bool running)

0
bin/LukeSkywalker.IPNetwork.dll Normal file → Executable file
View File

2
bin/OpenSimDefaults.ini Normal file → Executable file
View File

@ -296,7 +296,7 @@
; Simulator Stats URI ; Simulator Stats URI
; Enable JSON simulator data by setting a URI name (case sensitive) ; Enable JSON simulator data by setting a URI name (case sensitive)
; Returns regular sim stats (SimFPS, ...) ; Returns regular sim stats (SimFPS, ...)
; Stats_URI = "jsonSimStats" Stats_URI = "jsonSimStats"
; Simulator StatsManager URI ; Simulator StatsManager URI
; Enable fetch of StatsManager registered stats. Fetch is query which can optionally ; Enable fetch of StatsManager registered stats. Fetch is query which can optionally