From 752a1534f8cea6ad086b4e47ab96b8939664e55d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 13 Nov 2015 01:12:37 +0000 Subject: [PATCH 1/3] add the option Normalized55FPS. This is transition code ported from avinationmerge branch. (configration file changes will be commited later) --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 +++ .../Framework/Scenes/SimStatsReporter.cs | 40 ++++++++++--------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index dce2247dc5..cca8963aa9 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -381,6 +381,10 @@ namespace OpenSim.Region.Framework.Scenes } private int m_minFrameTicks; + // Normalize the frame related stats to nominal 55fps for viewer and scripts option + // see SimStatsReporter.cs + public bool Normalized55FPS { get; private set; } + /// /// The minimum length of time in seconds that will be taken for a scene frame. /// @@ -856,6 +860,7 @@ namespace OpenSim.Region.Framework.Scenes { m_config = config; MinFrameTicks = 89; + Normalized55FPS = true; MinMaintenanceTicks = 1000; SeeIntoRegion = true; @@ -1083,6 +1088,7 @@ namespace OpenSim.Region.Framework.Scenes if (startupConfig.Contains("MinFrameTime")) MinFrameTicks = (int)(startupConfig.GetFloat("MinFrameTime") * 1000); + Normalized55FPS = startupConfig.GetBoolean( "Normalized55FPS", Normalized55FPS); m_update_backup = startupConfig.GetInt("UpdateStorageEveryNFrames", m_update_backup); m_update_coarse_locations = startupConfig.GetInt("UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 2174e5157a..3effee7ab2 100755 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -176,11 +176,16 @@ namespace OpenSim.Region.Framework.Scenes /// Parameter to adjust reported scene fps /// /// - /// Our scene loop runs slower than other server implementations, apparantly because we work somewhat differently. - /// However, we will still report an FPS that's closer to what people are used to seeing. A lower FPS might - /// affect clients and monitoring scripts/software. + /// The close we have to a frame rate as expected by viewers, users and scripts + /// is heartbeat rate. + /// heartbeat rate default value is very diferent from the expected one + /// and can be changed from region to region acording to its specific simulation needs + /// since this creates incompatibility with expected values, + /// this scale factor can be used to normalize values to a Virtual FPS. + /// original decision was to use a value of 55fps for all opensim + /// corresponding, with default heartbeat rate, to a value of 5. /// - private float m_reportedFpsCorrectionFactor = 5; + private float m_statisticsFPSfactor = 5.0f; // saved last reported value so there is something available for llGetRegionFPS private float lastReportedSimFPS; @@ -278,10 +283,15 @@ namespace OpenSim.Region.Framework.Scenes m_usersLoggingIn = 0; m_scene = scene; - m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps; + m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000); ReportingRegion = scene.RegionInfo; + if(scene.Normalized55FPS) + m_statisticsFPSfactor = 55.0f * m_scene.MinFrameTicks / 1000.0f; + else + m_statisticsFPSfactor = 1.0f; + m_objectCapacity = scene.RegionInfo.ObjectCapacity; m_report.AutoReset = true; m_report.Interval = m_statsUpdatesEveryMS; @@ -381,13 +391,7 @@ namespace OpenSim.Region.Framework.Scenes #region various statistic googly moogly - // ORIGINAL code commented out until we have time to add our own - // statistics to the statistics window, this will be done as a - // new section given the title of our current project - // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently - // locked at a maximum of 11. Maybe at some point this can change so that we're not lying. - //int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); - int reportedFPS = m_fps; + int reportedFPS = (int)(m_fps * m_statisticsFPSfactor); // save the reported value so there is something available for llGetRegionFPS lastReportedSimFPS = reportedFPS / m_statsUpdateFactor; @@ -395,7 +399,7 @@ namespace OpenSim.Region.Framework.Scenes // ORIGINAL code commented out until we have time to add our own // statistics to the statistics window //float physfps = ((m_pfps / 1000)); - float physfps = m_numberPhysicsFrames; + float physfps = m_numberPhysicsFrames * m_statisticsFPSfactor; //if (physfps > 600) //physfps = physfps - (physfps - 600); @@ -429,7 +433,7 @@ namespace OpenSim.Region.Framework.Scenes uint thisFrame = m_scene.Frame; uint numFrames = thisFrame - m_lastUpdateFrame; - float framesUpdated = (float)numFrames * m_reportedFpsCorrectionFactor; + float framesUpdated = (float)numFrames * m_statisticsFPSfactor; m_lastUpdateFrame = thisFrame; // Avoid div-by-zero if somehow we've not updated any frames. @@ -502,22 +506,22 @@ namespace OpenSim.Region.Framework.Scenes // statistics to the statistics window sb[8].StatID = (uint)Stats.FrameMS; //sb[8].StatValue = m_frameMS / framesUpdated; - sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored; + sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored / m_statisticsFPSfactor; sb[9].StatID = (uint)Stats.NetMS; //sb[9].StatValue = m_netMS / framesUpdated; - sb[9].StatValue = (float) networkSumFrameTime / m_numberFramesStored; + sb[9].StatValue = (float) networkSumFrameTime / m_numberFramesStored / m_statisticsFPSfactor; sb[10].StatID = (uint)Stats.PhysicsMS; //sb[10].StatValue = m_physicsMS / framesUpdated; - sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored; + sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored / m_statisticsFPSfactor; sb[11].StatID = (uint)Stats.ImageMS ; sb[11].StatValue = m_imageMS / framesUpdated; sb[12].StatID = (uint)Stats.OtherMS; //sb[12].StatValue = m_otherMS / framesUpdated; - sb[12].StatValue = (float) simulationSumFrameTime / m_numberFramesStored; + sb[12].StatValue = (float) simulationSumFrameTime / m_numberFramesStored / m_statisticsFPSfactor; sb[13].StatID = (uint)Stats.InPacketsPerSecond; sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); From 75befda6df8f0000122e440ad437338287c5d27c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 13 Nov 2015 02:12:13 +0000 Subject: [PATCH 2/3] Add some values to the SimulatorFeatures cap's OpenSimExtras section relative to FPS statistics. This is transition code ported from avinationmerge. --- .../RegionModulesControllerPlugin.cs | 2 + OpenSim/Region/Framework/Scenes/Scene.cs | 41 ++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs index 17edb67d18..8f38a2978b 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs +++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs @@ -509,6 +509,8 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController { module.RegionLoaded(scene); } + + scene.AllModulesLoaded(); } public void RemoveRegionFromModules (Scene scene) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index cca8963aa9..2fe6e22c1f 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -39,6 +39,7 @@ using Nini.Config; using OpenMetaverse; using OpenMetaverse.Packets; using OpenMetaverse.Imaging; +using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Framework.Monitoring; using OpenSim.Services.Interfaces; @@ -381,6 +382,9 @@ namespace OpenSim.Region.Framework.Scenes } private int m_minFrameTicks; + public int FrameTimeWarnPercent { get; private set; } + public int FrameTimeCritPercent { get; private set; } + // Normalize the frame related stats to nominal 55fps for viewer and scripts option // see SimStatsReporter.cs public bool Normalized55FPS { get; private set; } @@ -860,6 +864,8 @@ namespace OpenSim.Region.Framework.Scenes { m_config = config; MinFrameTicks = 89; + FrameTimeWarnPercent = 60; + FrameTimeCritPercent = 40; Normalized55FPS = true; MinMaintenanceTicks = 1000; SeeIntoRegion = true; @@ -1088,6 +1094,8 @@ namespace OpenSim.Region.Framework.Scenes if (startupConfig.Contains("MinFrameTime")) MinFrameTicks = (int)(startupConfig.GetFloat("MinFrameTime") * 1000); + FrameTimeWarnPercent = startupConfig.GetInt( "FrameTimeWarnPercent", FrameTimeWarnPercent); + FrameTimeCritPercent = startupConfig.GetInt( "FrameTimeCritPercent", FrameTimeCritPercent); Normalized55FPS = startupConfig.GetBoolean( "Normalized55FPS", Normalized55FPS); m_update_backup = startupConfig.GetInt("UpdateStorageEveryNFrames", m_update_backup); @@ -1256,13 +1264,44 @@ namespace OpenSim.Region.Framework.Scenes get { return m_sceneGraph; } } - protected virtual void RegisterDefaultSceneEvents() + /// + /// Called by the module loader when all modules are loaded, after each module's + /// RegionLoaded hook is called. This is the earliest time where RequestModuleInterface + /// may be used. + /// + public void AllModulesLoaded() { IDialogModule dm = RequestModuleInterface(); if (dm != null) m_eventManager.OnPermissionError += dm.SendAlertToUser; + ISimulatorFeaturesModule fm = RequestModuleInterface(); + if (fm != null) + { + OSD openSimExtras; + OSDMap openSimExtrasMap; + + if (!fm.TryGetFeature("OpenSimExtras", out openSimExtras)) + openSimExtras = new OSDMap(); + + float FrameTime = MinFrameTicks / 1000.0f; + float statisticsFPSfactor = 1.0f; + if(Normalized55FPS) + statisticsFPSfactor = 55.0f * FrameTime; + + openSimExtrasMap = (OSDMap)openSimExtras; + openSimExtrasMap["SimulatorFPS"] = OSD.FromReal(1.0f / FrameTime); + openSimExtrasMap["SimulatorFPSFactor"] = OSD.FromReal(statisticsFPSfactor); + openSimExtrasMap["SimulatorFPSWarnPercent"] = OSD.FromInteger(FrameTimeWarnPercent); + openSimExtrasMap["SimulatorFPSCritPercent"] = OSD.FromInteger(FrameTimeCritPercent); + + fm.AddFeature("OpenSimExtras", openSimExtrasMap); + } + } + + protected virtual void RegisterDefaultSceneEvents() + { m_eventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; } From a2a71f0951033d88ab62d63a8655b41aaec1496c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 13 Nov 2015 02:18:12 +0000 Subject: [PATCH 3/3] configuration options relative to last tow commits --- bin/OpenSimDefaults.ini | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 636069de03..9002650be5 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -166,12 +166,30 @@ ; into a restart. InworldRestartShutsDown = false + ; Use of normalized 55FPS statistics + ; Opensim does not have a frame rate control like other simulators + ; Most parameters that control timing can be configurable region by region + ; To achive closer compatibility with values expected by viewers, scripts and users + ; some parameters are converted to a equivalent per frame value. + ; Adicionaly they are scaled to values they whould have on a system running at a nominal 55 frames per second rate + ; The scale factor it 55 * FrameTime, corresponding to 5 with default configuration + ; You can choose to not apply this scale factor setting Normalized55FPS to false. + ; Normalized55FPS = true + ; The minimum proportion of a second that any particular frame can take to execute. ; Only change this if you really know what you're doing, and be prepared to change UpdatePhysicsEveryNFrames ; (and other Frames params) to match! For instance, halving MinFrameTime to 0.0445 require ; UpdatePhysicsEveryNFrames = 2 unless you don't mind your avatar walking like Benny Hill. MinFrameTime = 0.089 + ; The values below represent the percentage of the target frame time that, + ; when underrun, should trigger yellow or red in the lag meter. + ; Less than 60% of FPS is amber by default, less then 40% is red. + ; These values are advisory. Viewers may choose to not use them but it is + ; encouraged that they do. + ; FrameTimeWarnPercent = 60; + ; FrameTimeCritPercent = 40; + ; Send scheduled updates to objects in the scene ; This must be a whole number UpdateObjectsEveryNFrames = 1;