From 756d1f917f9475d82702d75992ce54b6c5cd1cf5 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 7 Mar 2012 00:31:18 +0000 Subject: [PATCH] Stop individually deleting objects at the end of each ObjectTortureTest. We can now do this since the entire scene and all objects within it are now successfully gc'd at the end of these tests. This greatly improves the time taken to run each test (by reducing teardown time, not the time to actually do the test work that we're interested in). Slightly simplifies config read in Scene constructor to help facilitate this. --- OpenSim/Region/Framework/Scenes/Scene.cs | 49 +++++++++----------- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 2 +- OpenSim/Tests/Torture/NPCTortureTests.cs | 4 ++ OpenSim/Tests/Torture/ObjectTortureTests.cs | 8 +--- OpenSim/Tests/Torture/ScriptTortureTests.cs | 8 ++++ 5 files changed, 36 insertions(+), 35 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c571a54ea9..fdff8a9ef5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -670,10 +670,10 @@ namespace OpenSim.Region.Framework.Scenes #region Region Config - try + // Region config overrides global config + // + if (m_config.Configs["Startup"] != null) { - // Region config overrides global config - // IConfig startupConfig = m_config.Configs["Startup"]; m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); @@ -765,46 +765,39 @@ namespace OpenSim.Region.Framework.Scenes SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); } - catch - { - m_log.Warn("[SCENE]: Failed to load StartupConfig"); - } #endregion Region Config #region Interest Management - if (m_config != null) + IConfig interestConfig = m_config.Configs["InterestManagement"]; + if (interestConfig != null) { - IConfig interestConfig = m_config.Configs["InterestManagement"]; - if (interestConfig != null) + string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower(); + + try { - string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower(); - - try - { - m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true); - } - catch (Exception) - { - m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time"); - m_priorityScheme = UpdatePrioritizationSchemes.Time; - } - - m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true); - m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0); - m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0); - m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0); + m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true); } + catch (Exception) + { + m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time"); + m_priorityScheme = UpdatePrioritizationSchemes.Time; + } + + m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true); + m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0); + m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0); + m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0); } - m_log.InfoFormat("[SCENE]: Using the {0} prioritization scheme", m_priorityScheme); + m_log.DebugFormat("[SCENE]: Using the {0} prioritization scheme", m_priorityScheme); #endregion Interest Management StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; - StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; + StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; } /// diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index d9f8a148e9..7a6b1cf8d5 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -136,7 +136,7 @@ namespace OpenSim.Tests.Common StartAuthenticationService(testScene); LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene); StartGridService(testScene); - LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); + LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); inventoryService.PostInitialise(); diff --git a/OpenSim/Tests/Torture/NPCTortureTests.cs b/OpenSim/Tests/Torture/NPCTortureTests.cs index 8078d9dfab..65732dbc1f 100644 --- a/OpenSim/Tests/Torture/NPCTortureTests.cs +++ b/OpenSim/Tests/Torture/NPCTortureTests.cs @@ -75,6 +75,10 @@ namespace OpenSim.Tests.Torture [TestFixtureTearDown] public void TearDown() { + scene.Close(); + GC.Collect(); + GC.WaitForPendingFinalizers(); + // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple // threads. Possibly, later tests should be rewritten not to worry about such things. Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; diff --git a/OpenSim/Tests/Torture/ObjectTortureTests.cs b/OpenSim/Tests/Torture/ObjectTortureTests.cs index 0a127b1285..e3f951fb8a 100644 --- a/OpenSim/Tests/Torture/ObjectTortureTests.cs +++ b/OpenSim/Tests/Torture/ObjectTortureTests.cs @@ -156,11 +156,6 @@ namespace OpenSim.Tests.Torture // objects will be clean up by the garbage collector before the next stress test is run. scene.Update(1); - // Currently, we need to do this in order to garbage collect the scene objects ready for the next test run. - // However, what we really need to do is find out why the entire scene is not garbage collected in - // teardown. - scene.DeleteAllSceneObjects(); - Console.WriteLine( "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)", Math.Round(elapsed.TotalMilliseconds), @@ -170,7 +165,8 @@ namespace OpenSim.Tests.Torture objectsToAdd, primsInEachObject); - scene = null; + scene.Close(); +// scene = null; } } } \ No newline at end of file diff --git a/OpenSim/Tests/Torture/ScriptTortureTests.cs b/OpenSim/Tests/Torture/ScriptTortureTests.cs index d94bbde680..87932cb7f8 100644 --- a/OpenSim/Tests/Torture/ScriptTortureTests.cs +++ b/OpenSim/Tests/Torture/ScriptTortureTests.cs @@ -91,6 +91,14 @@ namespace OpenSim.Tests.Torture m_scene.StartScripts(); } + [TearDown] + public void TearDown() + { + m_scene.Close(); + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + [Test] public void TestCompileAndStart100Scripts() {