diff options
author | Teravus Ovares | 2008-05-25 20:50:45 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-25 20:50:45 +0000 |
commit | c20f7d6171a9df151c3ccde063336338da9ae322 (patch) | |
tree | a6093b52da4093e3b692771a421ce4a55052d24b /OpenSim/Region | |
parent | Thank you very much, Melanie for a patch that: (diff) | |
download | opensim-SC-c20f7d6171a9df151c3ccde063336338da9ae322.zip opensim-SC-c20f7d6171a9df151c3ccde063336338da9ae322.tar.gz opensim-SC-c20f7d6171a9df151c3ccde063336338da9ae322.tar.bz2 opensim-SC-c20f7d6171a9df151c3ccde063336338da9ae322.tar.xz |
* 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.
Diffstat (limited to 'OpenSim/Region')
9 files changed, 123 insertions, 13 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 484518a..11fb5be 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -5652,6 +5652,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5652 | handlerLandStatRequest(0, 1, 0, "", this); | 5652 | handlerLandStatRequest(0, 1, 0, "", this); |
5653 | } | 5653 | } |
5654 | break; | 5654 | break; |
5655 | case "scripts": | ||
5656 | handlerLandStatRequest = OnLandStatRequest; | ||
5657 | if (handlerLandStatRequest != null) | ||
5658 | { | ||
5659 | handlerLandStatRequest(0, 0, 0, "", this); | ||
5660 | } | ||
5661 | break; | ||
5655 | default: | 5662 | default: |
5656 | m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket.ToString()); | 5663 | m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket.ToString()); |
5657 | break; | 5664 | break; |
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 | |||
313 | } | 313 | } |
314 | private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient) | 314 | private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient) |
315 | { | 315 | { |
316 | Dictionary<uint, float> colliders = m_scene.PhysicsScene.GetTopColliders(); | 316 | Dictionary<uint, float> SceneData = new Dictionary<uint,float>(); |
317 | 317 | ||
318 | List<LandStatReportItem> collidera = new List<LandStatReportItem>(); | 318 | if (reportType == 1) |
319 | lock (colliders) | 319 | { |
320 | SceneData = m_scene.PhysicsScene.GetTopColliders(); | ||
321 | } | ||
322 | else if (reportType == 0) | ||
320 | { | 323 | { |
321 | foreach (uint obj in colliders.Keys) | 324 | SceneData = m_scene.m_innerScene.GetTopScripts(); |
325 | } | ||
326 | |||
327 | List<LandStatReportItem> SceneReport = new List<LandStatReportItem>(); | ||
328 | lock (SceneData) | ||
329 | { | ||
330 | foreach (uint obj in SceneData.Keys) | ||
322 | { | 331 | { |
323 | SceneObjectPart prt = m_scene.GetSceneObjectPart(obj); | 332 | SceneObjectPart prt = m_scene.GetSceneObjectPart(obj); |
324 | if (prt != null) | 333 | if (prt != null) |
@@ -332,21 +341,30 @@ namespace OpenSim.Region.Environment.Modules.World.Estate | |||
332 | lsri.LocationX = sog.AbsolutePosition.X; | 341 | lsri.LocationX = sog.AbsolutePosition.X; |
333 | lsri.LocationY = sog.AbsolutePosition.Y; | 342 | lsri.LocationY = sog.AbsolutePosition.Y; |
334 | lsri.LocationZ = sog.AbsolutePosition.Z; | 343 | lsri.LocationZ = sog.AbsolutePosition.Z; |
335 | lsri.Score = colliders[obj]; | 344 | lsri.Score = SceneData[obj]; |
336 | lsri.TaskID = sog.UUID; | 345 | lsri.TaskID = sog.UUID; |
337 | lsri.TaskLocalID = sog.LocalId; | 346 | lsri.TaskLocalID = sog.LocalId; |
338 | lsri.TaskName = sog.GetPartName(obj); | 347 | lsri.TaskName = sog.GetPartName(obj); |
339 | lsri.OwnerName = m_scene.CommsManager.UUIDNameRequestString(sog.OwnerID); | 348 | lsri.OwnerName = m_scene.CommsManager.UUIDNameRequestString(sog.OwnerID); |
340 | 349 | if (filter.Length != 0) | |
350 | { | ||
351 | if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter))) | ||
352 | { | ||
353 | } | ||
354 | else | ||
355 | { | ||
356 | continue; | ||
357 | } | ||
358 | } | ||
341 | 359 | ||
342 | collidera.Add(lsri); | 360 | SceneReport.Add(lsri); |
343 | } | 361 | } |
344 | } | 362 | } |
345 | } | 363 | } |
346 | 364 | ||
347 | } | 365 | } |
348 | } | 366 | } |
349 | remoteClient.SendLandStatReply(reportType, requestFlags, (uint)collidera.Count,collidera.ToArray()); | 367 | remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray()); |
350 | 368 | ||
351 | } | 369 | } |
352 | 370 | ||
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 | |||
174 | 174 | ||
175 | public event AvatarKillData OnAvatarKilled; | 175 | public event AvatarKillData OnAvatarKilled; |
176 | 176 | ||
177 | public delegate void ScriptTimerEvent(uint localID, double timerinterval); | ||
178 | |||
179 | public event ScriptTimerEvent OnScriptTimerEvent; | ||
177 | 180 | ||
178 | 181 | ||
179 | public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); | 182 | public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); |
@@ -332,6 +335,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
332 | private RequestParcelPrimCountUpdate handlerRequestParcelPrimCountUpdate = null; | 335 | private RequestParcelPrimCountUpdate handlerRequestParcelPrimCountUpdate = null; |
333 | private ParcelPrimCountTainted handlerParcelPrimCountTainted = null; | 336 | private ParcelPrimCountTainted handlerParcelPrimCountTainted = null; |
334 | private ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = null; | 337 | private ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = null; |
338 | private ScriptTimerEvent handlerScriptTimerEvent = null; | ||
335 | 339 | ||
336 | public void TriggerOnScriptChangedEvent(uint localID, uint change) | 340 | public void TriggerOnScriptChangedEvent(uint localID, uint change) |
337 | { | 341 | { |
@@ -755,5 +759,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
755 | 759 | ||
756 | } | 760 | } |
757 | } | 761 | } |
762 | // this lets us keep track of nasty script events like timer, etc. | ||
763 | public void TriggerTimerEvent(uint objLocalID, double Interval) | ||
764 | { | ||
765 | handlerScriptTimerEvent = OnScriptTimerEvent; | ||
766 | if (handlerScriptTimerEvent != null) | ||
767 | { | ||
768 | handlerScriptTimerEvent(objLocalID, Interval); | ||
769 | |||
770 | } | ||
771 | |||
772 | } | ||
758 | } | 773 | } |
759 | } | 774 | } |
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 | |||
846 | return result; | 846 | return result; |
847 | } | 847 | } |
848 | 848 | ||
849 | public Dictionary<uint, float> GetTopScripts() | ||
850 | { | ||
851 | Dictionary<uint, float> topScripts = new Dictionary<uint, float>(); | ||
852 | |||
853 | List<EntityBase> EntityList = GetEntities(); | ||
854 | int limit = 0; | ||
855 | foreach (EntityBase ent in EntityList) | ||
856 | { | ||
857 | if (ent is SceneObjectGroup) | ||
858 | { | ||
859 | SceneObjectGroup grp = (SceneObjectGroup)ent; | ||
860 | if ((grp.RootPart.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Scripted) != 0) | ||
861 | { | ||
862 | if (grp.scriptScore >= 0.01) | ||
863 | { | ||
864 | topScripts.Add(grp.LocalId, grp.scriptScore); | ||
865 | limit++; | ||
866 | if (limit >= 100) | ||
867 | { | ||
868 | break; | ||
869 | } | ||
870 | |||
871 | } | ||
872 | grp.scriptScore = 0; | ||
873 | } | ||
874 | } | ||
875 | } | ||
876 | |||
877 | return topScripts; | ||
878 | } | ||
879 | |||
849 | #endregion | 880 | #endregion |
850 | 881 | ||
851 | #region Other Methods | 882 | #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 | |||
90 | /// since the group's last persistent backup | 90 | /// since the group's last persistent backup |
91 | /// </summary> | 91 | /// </summary> |
92 | public bool HasGroupChanged = false; | 92 | public bool HasGroupChanged = false; |
93 | public float scriptScore = 0f; | ||
93 | 94 | ||
94 | 95 | ||
95 | 96 | ||
@@ -959,6 +960,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
959 | 960 | ||
960 | public void AddScriptLPS(int count) | 961 | public void AddScriptLPS(int count) |
961 | { | 962 | { |
963 | if (scriptScore + count >= float.MaxValue - count) | ||
964 | scriptScore = 0; | ||
965 | |||
966 | scriptScore += (float)count; | ||
962 | InnerScene d = m_scene.m_innerScene; | 967 | InnerScene d = m_scene.m_innerScene; |
963 | d.AddToScriptLPS(count); | 968 | d.AddToScriptLPS(count); |
964 | } | 969 | } |
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 | |||
2752 | PhysActor.OnCollisionUpdate -= PhysicsCollision; | 2752 | PhysActor.OnCollisionUpdate -= PhysicsCollision; |
2753 | } | 2753 | } |
2754 | } | 2754 | } |
2755 | if ((GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Scripted) != 0) | ||
2756 | { | ||
2757 | m_parentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting; | ||
2758 | } | ||
2759 | else | ||
2760 | { | ||
2761 | m_parentGroup.Scene.EventManager.OnScriptTimerEvent -= handleTimerAccounting; | ||
2762 | } | ||
2755 | 2763 | ||
2756 | LocalFlags=(LLObject.ObjectFlags)objectflagupdate; | 2764 | LocalFlags=(LLObject.ObjectFlags)objectflagupdate; |
2757 | 2765 | ||
@@ -2812,6 +2820,30 @@ namespace OpenSim.Region.Environment.Scenes | |||
2812 | GetProperties(client); | 2820 | GetProperties(client); |
2813 | m_updateFlag = 2; | 2821 | m_updateFlag = 2; |
2814 | } | 2822 | } |
2823 | private void handleTimerAccounting(uint localID, double interval) | ||
2824 | { | ||
2825 | if (localID == LocalId) | ||
2826 | { | ||
2827 | |||
2828 | float sec = (float)interval; | ||
2829 | if (m_parentGroup != null) | ||
2830 | { | ||
2831 | if (sec == 0) | ||
2832 | { | ||
2833 | if (m_parentGroup.scriptScore + 0.001f >= float.MaxValue - 0.001) | ||
2834 | m_parentGroup.scriptScore = 0; | ||
2835 | |||
2836 | m_parentGroup.scriptScore += 0.001f; | ||
2837 | return; | ||
2838 | } | ||
2839 | |||
2840 | if (m_parentGroup.scriptScore + (0.001f / sec) >= float.MaxValue - (0.001f / sec)) | ||
2841 | m_parentGroup.scriptScore = 0; | ||
2842 | m_parentGroup.scriptScore += (0.001f / sec); | ||
2843 | } | ||
2844 | |||
2845 | } | ||
2846 | } | ||
2815 | 2847 | ||
2816 | } | 2848 | } |
2817 | } | 2849 | } |
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 3fa65f5..fbfb400 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -474,7 +474,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
474 | 474 | ||
475 | public void llSensor(string name, string id, int type, double range, double arc) | 475 | public void llSensor(string name, string id, int type, double range, double arc) |
476 | { | 476 | { |
477 | m_host.AddScriptLPS(1); | 477 | m_host.AddScriptLPS(300); |
478 | LLUUID keyID = LLUUID.Zero; | 478 | LLUUID keyID = LLUUID.Zero; |
479 | LLUUID.TryParse(id, out keyID); | 479 | LLUUID.TryParse(id, out keyID); |
480 | 480 | ||
@@ -1818,7 +1818,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
1818 | 1818 | ||
1819 | public void llSleep(double sec) | 1819 | public void llSleep(double sec) |
1820 | { | 1820 | { |
1821 | m_host.AddScriptLPS(1); | 1821 | m_host.AddScriptLPS((int)(sec * 100)); |
1822 | Thread.Sleep((int)(sec * 1000)); | 1822 | Thread.Sleep((int)(sec * 1000)); |
1823 | } | 1823 | } |
1824 | 1824 | ||
@@ -2582,7 +2582,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
2582 | 2582 | ||
2583 | public void llResetScript() | 2583 | public void llResetScript() |
2584 | { | 2584 | { |
2585 | m_host.AddScriptLPS(1); | 2585 | m_host.AddScriptLPS(800); |
2586 | m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID); | 2586 | m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID); |
2587 | } | 2587 | } |
2588 | 2588 | ||
@@ -4279,7 +4279,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
4279 | ScriptManager sm; | 4279 | ScriptManager sm; |
4280 | IScript script = null; | 4280 | IScript script = null; |
4281 | 4281 | ||
4282 | m_host.AddScriptLPS(1); | 4282 | m_host.AddScriptLPS(8000); |
4283 | 4283 | ||
4284 | // These functions are supposed to be robust, | 4284 | // These functions are supposed to be robust, |
4285 | // so get the state one step at a time. | 4285 | // so get the state one step at a time. |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs index 13c9d25..82bd3ac 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs | |||
@@ -316,6 +316,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugin | |||
316 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "sensor", EventQueueManager.llDetectNull, | 316 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "sensor", EventQueueManager.llDetectNull, |
317 | new object[] { new LSL_Types.LSLInteger(SensedObjects.Length) }); | 317 | new object[] { new LSL_Types.LSLInteger(SensedObjects.Length) }); |
318 | } | 318 | } |
319 | m_CmdManager.m_ScriptEngine.World.EventManager.TriggerTimerEvent(ts.localID, ts.interval); | ||
319 | } | 320 | } |
320 | } | 321 | } |
321 | } | 322 | } |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs index 6f88e11..f6de3c6 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs | |||
@@ -126,6 +126,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugin | |||
126 | // Add it to queue | 126 | // Add it to queue |
127 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", EventQueueManager.llDetectNull, | 127 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", EventQueueManager.llDetectNull, |
128 | null); | 128 | null); |
129 | m_CmdManager.m_ScriptEngine.World.EventManager.TriggerTimerEvent(ts.localID, ((double)ts.interval / 10000000)); | ||
129 | // set next interval | 130 | // set next interval |
130 | 131 | ||
131 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | 132 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |