From c20f7d6171a9df151c3ccde063336338da9ae322 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 25 May 2008 20:50:45 +0000 Subject: * A hacky Top Scripts display. It isn't accurate as far as ms accounting, however you can use it to help find out what scripts are causing your simulator to cry. * Access it from the Estate tools/Debug tab. --- .../Modules/World/Estate/EstateManagementModule.cs | 36 ++++++++++++++++------ OpenSim/Region/Environment/Scenes/EventManager.cs | 15 +++++++++ OpenSim/Region/Environment/Scenes/InnerScene.cs | 31 +++++++++++++++++++ .../Region/Environment/Scenes/SceneObjectGroup.cs | 5 +++ .../Region/Environment/Scenes/SceneObjectPart.cs | 32 +++++++++++++++++++ 5 files changed, 110 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs index d3aa4aa..ab5898d 100644 --- a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs @@ -313,12 +313,21 @@ namespace OpenSim.Region.Environment.Modules.World.Estate } private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient) { - Dictionary colliders = m_scene.PhysicsScene.GetTopColliders(); - - List collidera = new List(); - lock (colliders) + Dictionary SceneData = new Dictionary(); + + if (reportType == 1) + { + SceneData = m_scene.PhysicsScene.GetTopColliders(); + } + else if (reportType == 0) { - foreach (uint obj in colliders.Keys) + SceneData = m_scene.m_innerScene.GetTopScripts(); + } + + List SceneReport = new List(); + lock (SceneData) + { + foreach (uint obj in SceneData.Keys) { SceneObjectPart prt = m_scene.GetSceneObjectPart(obj); if (prt != null) @@ -332,21 +341,30 @@ namespace OpenSim.Region.Environment.Modules.World.Estate lsri.LocationX = sog.AbsolutePosition.X; lsri.LocationY = sog.AbsolutePosition.Y; lsri.LocationZ = sog.AbsolutePosition.Z; - lsri.Score = colliders[obj]; + lsri.Score = SceneData[obj]; lsri.TaskID = sog.UUID; lsri.TaskLocalID = sog.LocalId; lsri.TaskName = sog.GetPartName(obj); lsri.OwnerName = m_scene.CommsManager.UUIDNameRequestString(sog.OwnerID); - + if (filter.Length != 0) + { + if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter))) + { + } + else + { + continue; + } + } - collidera.Add(lsri); + SceneReport.Add(lsri); } } } } } - remoteClient.SendLandStatReply(reportType, requestFlags, (uint)collidera.Count,collidera.ToArray()); + remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray()); } diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs index a3f5d2f..1c345ba 100644 --- a/OpenSim/Region/Environment/Scenes/EventManager.cs +++ b/OpenSim/Region/Environment/Scenes/EventManager.cs @@ -174,6 +174,9 @@ namespace OpenSim.Region.Environment.Scenes public event AvatarKillData OnAvatarKilled; + public delegate void ScriptTimerEvent(uint localID, double timerinterval); + + public event ScriptTimerEvent OnScriptTimerEvent; public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); @@ -332,6 +335,7 @@ namespace OpenSim.Region.Environment.Scenes private RequestParcelPrimCountUpdate handlerRequestParcelPrimCountUpdate = null; private ParcelPrimCountTainted handlerParcelPrimCountTainted = null; private ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = null; + private ScriptTimerEvent handlerScriptTimerEvent = null; public void TriggerOnScriptChangedEvent(uint localID, uint change) { @@ -755,5 +759,16 @@ namespace OpenSim.Region.Environment.Scenes } } + // this lets us keep track of nasty script events like timer, etc. + public void TriggerTimerEvent(uint objLocalID, double Interval) + { + handlerScriptTimerEvent = OnScriptTimerEvent; + if (handlerScriptTimerEvent != null) + { + handlerScriptTimerEvent(objLocalID, Interval); + + } + + } } } diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 84de71f..d6e905b 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -846,6 +846,37 @@ namespace OpenSim.Region.Environment.Scenes return result; } + public Dictionary GetTopScripts() + { + Dictionary topScripts = new Dictionary(); + + List EntityList = GetEntities(); + int limit = 0; + foreach (EntityBase ent in EntityList) + { + if (ent is SceneObjectGroup) + { + SceneObjectGroup grp = (SceneObjectGroup)ent; + if ((grp.RootPart.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Scripted) != 0) + { + if (grp.scriptScore >= 0.01) + { + topScripts.Add(grp.LocalId, grp.scriptScore); + limit++; + if (limit >= 100) + { + break; + } + + } + grp.scriptScore = 0; + } + } + } + + return topScripts; + } + #endregion #region Other Methods diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 25b3d16..cd4be99 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -90,6 +90,7 @@ namespace OpenSim.Region.Environment.Scenes /// since the group's last persistent backup /// public bool HasGroupChanged = false; + public float scriptScore = 0f; @@ -959,6 +960,10 @@ namespace OpenSim.Region.Environment.Scenes public void AddScriptLPS(int count) { + if (scriptScore + count >= float.MaxValue - count) + scriptScore = 0; + + scriptScore += (float)count; InnerScene d = m_scene.m_innerScene; d.AddToScriptLPS(count); } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index b724bda..c6b3059 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -2752,6 +2752,14 @@ namespace OpenSim.Region.Environment.Scenes PhysActor.OnCollisionUpdate -= PhysicsCollision; } } + if ((GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Scripted) != 0) + { + m_parentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting; + } + else + { + m_parentGroup.Scene.EventManager.OnScriptTimerEvent -= handleTimerAccounting; + } LocalFlags=(LLObject.ObjectFlags)objectflagupdate; @@ -2812,6 +2820,30 @@ namespace OpenSim.Region.Environment.Scenes GetProperties(client); m_updateFlag = 2; } + private void handleTimerAccounting(uint localID, double interval) + { + if (localID == LocalId) + { + + float sec = (float)interval; + if (m_parentGroup != null) + { + if (sec == 0) + { + if (m_parentGroup.scriptScore + 0.001f >= float.MaxValue - 0.001) + m_parentGroup.scriptScore = 0; + + m_parentGroup.scriptScore += 0.001f; + return; + } + + if (m_parentGroup.scriptScore + (0.001f / sec) >= float.MaxValue - (0.001f / sec)) + m_parentGroup.scriptScore = 0; + m_parentGroup.scriptScore += (0.001f / sec); + } + + } + } } } -- cgit v1.1