Beispiel #1
0
 public SimStats(uint regionX, uint regionY, uint regionFlags, uint objectCapacity, SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock, UUID pRUUID)
 {
     regionUUID       = pRUUID;
     m_regionX        = regionX;
     m_regionY        = regionY;
     m_regionFlags    = regionFlags;
     m_objectCapacity = objectCapacity;
     m_regionBlock    = regionBlock;
     m_statsBlock     = statsBlock;
 }
            private void buildInitialRegionBlock()
            {
                rb = new SimStatsPacket.RegionBlock();
                uint regionFlags = 0;

                try {
                    if (m_estateModule == null)
                    {
                        m_estateModule = m_currentScene.RequestModuleInterface <IEstateModule> ();
                    }
                    regionFlags = m_estateModule != null ? (uint)m_estateModule.GetRegionFlags() : 0;
                } catch (Exception) {
                    // leave region flags at 0
                }
                rb.ObjectCapacity = (uint)m_currentScene.RegionInfo.ObjectCapacity;
                rb.RegionFlags    = regionFlags;
                rb.RegionX        = (uint)m_currentScene.RegionInfo.RegionLocX / Constants.RegionSize;
                rb.RegionY        = (uint)m_currentScene.RegionInfo.RegionLocY / Constants.RegionSize;
            }
Beispiel #3
0
        private void statsHeartBeat(object sender, EventArgs e)
        {
            double totalSumFrameTime;
            double simulationSumFrameTime;
            double physicsSumFrameTime;
            double networkSumFrameTime;
            float frameDilation;
            int currentFrame;

            if (!m_scene.Active)
                return;

            // 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();
            
            // Know what's not thread safe in Mono... modifying timers.
            // m_log.Debug("Firing Stats Heart Beat");
            lock (m_report)
            {
                uint regionFlags = 0;
                
                try
                {
                    if (estateModule == null)
                        estateModule = m_scene.RequestModuleInterface<IEstateModule>();
                    regionFlags = estateModule != null ? estateModule.GetRegionFlags() : (uint) 0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

#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;

                // save the reported value so there is something available for llGetRegionFPS 
                lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;

               // 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;

                //if (physfps > 600)
                //physfps = physfps - (physfps - 600);

                if (physfps < 0)
                    physfps = 0;

#endregion

                m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
                m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
                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_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();

                // FIXME: Checking for stat sanity is a complex approach.  What we really need to do is fix the code
                // so that stat numbers are always consistent.
                CheckStatSanity();
                
                //Our time dilation is 0.91 when we're running a full speed,
                // therefore to make sure we get an appropriate range,
                // we have to factor in our error.   (0.10f * statsUpdateFactor)
                // multiplies the fix for the error times the amount of times it'll occur a second
                // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
                // Then we divide the whole amount by the amount of seconds pass in between stats updates.

                // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
                // values to X-per-second values.

                uint thisFrame = m_scene.Frame;
                uint numFrames = thisFrame - m_lastUpdateFrame;
                float framesUpdated = (float)numFrames * m_reportedFpsCorrectionFactor;
                m_lastUpdateFrame = thisFrame;

                // Avoid div-by-zero if somehow we've not updated any frames.
                if (framesUpdated == 0)
                    framesUpdated = 1;

                for (int i = 0; i < m_statisticArraySize; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }

                // Resetting the sums of the frame times to prevent any errors
                // in calculating the moving average for frame time
                totalSumFrameTime = 0;
                simulationSumFrameTime = 0;
                physicsSumFrameTime = 0;
                networkSumFrameTime = 0;

                // Loop through all the frames that were stored for the current
                // heartbeat to process the moving average of frame times
                for (int i = 0; i < m_numberFramesStored; i++)
                {
                    // Sum up each frame time in order to calculate the moving
                    // average of frame time
                    totalSumFrameTime += m_totalFrameTimeMilliseconds[i];
                    simulationSumFrameTime +=
                        m_simulationFrameTimeMilliseconds[i];
                    physicsSumFrameTime += m_physicsFrameTimeMilliseconds[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].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10)  / statsUpdateFactor));

                sb[1].StatID = (uint) Stats.SimFPS;
                sb[1].StatValue = reportedFPS / m_statsUpdateFactor;

                sb[2].StatID = (uint) Stats.PhysicsFPS;
                sb[2].StatValue = physfps / m_statsUpdateFactor;

                sb[3].StatID = (uint) Stats.AgentUpdates;
                sb[3].StatValue = (m_agentUpdates / m_statsUpdateFactor);

                sb[4].StatID = (uint) Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID = (uint) Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID = (uint) Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID = (uint) Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

               // ORIGINAL code commented out until we have time to add our own
               // 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[9].StatID = (uint)Stats.NetMS;
                //sb[9].StatValue = m_netMS / framesUpdated;
                sb[9].StatValue = (float) networkSumFrameTime / m_numberFramesStored;

                sb[10].StatID = (uint)Stats.PhysicsMS;
                //sb[10].StatValue = m_physicsMS / framesUpdated;
                sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored;

                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[13].StatID = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);

                sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (m_outPacketsPerSecond / m_statsUpdateFactor);

                sb[15].StatID = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID = (uint)Stats.AgentMS;
                sb[16].StatValue = m_agentMS / framesUpdated;

                sb[17].StatID = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
                sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;

                sb[21].StatID = (uint)Stats.SimSpareMs;
                sb[21].StatValue = m_spareMS / framesUpdated;

                // 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;

                sb[27].StatID = (uint)Stats.ScriptMS;
                sb[27].StatValue = (numFrames <= 0) ? 0 : ((float)m_scriptMS / numFrames);

                for (int i = 0; i < m_statisticArraySize; i++)
                {
                    lastReportedSimStats[i] = sb[i].StatValue;
                }
              
                SimStats simStats 
                    = new SimStats(
                        ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
                        rb, sb, m_scene.RegionInfo.originRegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }

                // Extra statistics that aren't currently sent to clients
                lock (m_lastReportedExtraSimStats)
                {
                    m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor;
                    m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value;

                    Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
    
                    if (physicsStats != null)
                    {
                        foreach (KeyValuePair<string, float> tuple in physicsStats)
                        {
                            // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
                            // Need to change things so that stats source can indicate whether they are per second or
                            // per frame.
                            if (tuple.Key.EndsWith("MS"))
                                m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated;
                            else
                                m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
                        }
                    }
                }

                ResetValues();
            }
        }
Beispiel #4
0
            /// <summary>
            /// This is called by a timer and makes a SimStats class of the current stats that we have in this simulator.
            ///  It then sends the packet to the client and triggers the events to tell followers about the updated stats
            ///   and updates the LastSet* values for monitors.
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void statsHeartBeat(object sender, EventArgs e)
            {
                SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();

                // Know what's not thread safe in Mono... modifying timers.
                lock (m_report)
                {
                    uint regionFlags = 0;

                    try
                    {
                        if (m_estateModule == null)
                            m_estateModule = m_currentScene.RequestModuleInterface<IEstateModule>();
                        regionFlags = m_estateModule != null ? m_estateModule.GetRegionFlags() : (uint)0;
                    }
                    catch (Exception)
                    {
                        // leave region flags at 0
                    }

                    rb.ObjectCapacity = (uint)m_currentScene.RegionInfo.ObjectCapacity;
                    rb.RegionFlags = regionFlags;
                    rb.RegionX = (uint)m_currentScene.RegionInfo.RegionLocX / Constants.RegionSize;
                    rb.RegionY = (uint)m_currentScene.RegionInfo.RegionLocY / Constants.RegionSize;

                    ISimFrameMonitor simFrameMonitor = (ISimFrameMonitor)GetMonitor("SimFrameStats");
                    ITimeDilationMonitor timeDilationMonitor = (ITimeDilationMonitor)GetMonitor("Time Dilation");
                    ITotalFrameTimeMonitor totalFrameMonitor = (ITotalFrameTimeMonitor)GetMonitor("Total Frame Time");
                    ITimeMonitor sleepFrameMonitor = (ITimeMonitor)GetMonitor("Sleep Frame Time");
                    ITimeMonitor otherFrameMonitor = (ITimeMonitor)GetMonitor("Other Frame Time");
                    IPhysicsFrameMonitor physicsFrameMonitor = (IPhysicsFrameMonitor)GetMonitor("Total Physics Frame Time");
                    ITimeMonitor physicsSyncFrameMonitor = (ITimeMonitor)GetMonitor("Physics Sync Frame Time");
                    ITimeMonitor physicsTimeFrameMonitor = (ITimeMonitor)GetMonitor("Physics Update Frame Time");
                    IAgentUpdateMonitor agentUpdateFrameMonitor = (IAgentUpdateMonitor)GetMonitor("Agent Update Count");
                    INetworkMonitor networkMonitor = (INetworkMonitor)GetMonitor("Network Monitor");
                    IMonitor imagesMonitor = GetMonitor("Images Frame Time");
                    ITimeMonitor scriptMonitor = (ITimeMonitor)GetMonitor("Script Frame Time");
                    IScriptCountMonitor totalScriptMonitor = (IScriptCountMonitor)GetMonitor("Total Script Count");
                    
                    #region various statistic googly moogly

                    float simfps = simFrameMonitor.SimFPS / statsUpdateFactor;
                    // save the reported value so there is something available for llGetRegionFPS 
                    simFrameMonitor.LastReportedSimFPS = simfps;

                    float physfps = (float)physicsFrameMonitor.PhysicsFPS / statsUpdateFactor;
                    physicsFrameMonitor.LastReportedPhysicsFPS = physfps;
                    //Update the time dilation with the newest physicsFPS
                    timeDilationMonitor.SetPhysicsFPS(physfps);

                    #endregion

                    #region Add the stats packets

                    //Some info on this packet http://wiki.secondlife.com/wiki/Statistics_Bar_Guide

                    sb[0].StatID = (uint)Stats.TimeDilation;
                    sb[0].StatValue = (float)timeDilationMonitor.GetValue();

                    sb[1].StatID = (uint)Stats.FPS;
                    sb[1].StatValue = simfps;

                    float realsimfps = simfps * 2;

                    sb[2].StatID = (uint)Stats.PhysFPS;
                    sb[2].StatValue = physfps;

                    sb[3].StatID = (uint)Stats.AgentUpdates;
                    sb[3].StatValue = (agentUpdateFrameMonitor.AgentUpdates / realsimfps);

                    sb[4].StatID = (uint)Stats.FrameMS;
                    float TotalFrames = (float)(totalFrameMonitor.GetValue() / realsimfps);
                    sb[4].StatValue = TotalFrames;

                    sb[5].StatID = (uint)Stats.NetMS;
                    sb[5].StatValue = 0;//TODO: Implement this

                    sb[6].StatID = (uint)Stats.SimOtherMS;
                    sb[6].StatValue = (float)(otherFrameMonitor.GetValue() / realsimfps);

                    sb[7].StatID = (uint)Stats.SimPhysicsMS;
                    float PhysicsMS = (float)(physicsTimeFrameMonitor.GetValue() / realsimfps);
                    sb[7].StatValue = PhysicsMS;

                    sb[8].StatID = (uint)Stats.AgentMS;
                    sb[8].StatValue = (agentUpdateFrameMonitor.AgentFrameTime / realsimfps);

                    sb[9].StatID = (uint)Stats.ImagesMS;
                    sb[9].StatValue = (float)(imagesMonitor.GetValue() / realsimfps);

                    sb[10].StatID = (uint)Stats.ScriptMS;
                    float ScriptMS = (float)(scriptMonitor.GetValue() / realsimfps);
                    sb[10].StatValue = ScriptMS;

                    sb[11].StatID = (uint)Stats.TotalObjects;
                    sb[12].StatID = (uint)Stats.ActiveObjects;
                    sb[13].StatID = (uint)Stats.NumAgentMain;
                    sb[14].StatID = (uint)Stats.NumAgentChild;

                    IEntityCountModule entityCountModule = m_currentScene.RequestModuleInterface<IEntityCountModule>();
                    if (entityCountModule != null)
                    {
                        sb[11].StatValue = entityCountModule.Objects;

                        sb[12].StatValue = entityCountModule.ActiveObjects;

                        sb[13].StatValue = entityCountModule.RootAgents;

                        sb[14].StatValue = entityCountModule.ChildAgents;
                    }

                    sb[15].StatID = (uint)Stats.NumScriptActive;
                    sb[15].StatValue = totalScriptMonitor.ActiveScripts;

                    sb[16].StatID = (uint)Stats.LSLIPS;
                    sb[16].StatValue = 0; //This isn't used anymore, and has been superseeded by LSLEPS

                    sb[17].StatID = (uint)Stats.InPPS;
                    sb[17].StatValue = (float)(networkMonitor.InPacketsPerSecond / statsUpdateFactor);

                    sb[18].StatID = (uint)Stats.OutPPS;
                    sb[18].StatValue = (float)(networkMonitor.OutPacketsPerSecond / statsUpdateFactor);

                    sb[19].StatID = (uint)Stats.PendingDownloads;
                    sb[19].StatValue = (float)(networkMonitor.PendingDownloads);

                    sb[20].StatID = (uint)Stats.PendingUploads;
                    sb[20].StatValue = (float)(networkMonitor.PendingUploads);

                    //21 and 22 are forced to the GC memory as they WILL make memory usage go up rapidly otherwise!
                    sb[21].StatID = (uint)Stats.VirtualSizeKB;
                    sb[21].StatValue = GC.GetTotalMemory(false) / 1024;// System.Diagnostics.Process.GetCurrentProcess().WorkingSet64 / (1024);

                    sb[22].StatID = (uint)Stats.ResidentSizeKB;
                    sb[22].StatValue = GC.GetTotalMemory(false) / 1024;//(float)System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64 / (1024);
                    
                    sb[23].StatID = (uint)Stats.PendingLocalUploads;
                    sb[23].StatValue = (float)(networkMonitor.PendingUploads / statsUpdateFactor);
                    
                    sb[24].StatID = (uint)Stats.TotalUnackedBytes;
                    sb[24].StatValue = (float)(networkMonitor.UnackedBytes);

                    sb[25].StatID = (uint)Stats.PhysicsPinnedTasks;
                    sb[25].StatValue = 0;

                    sb[26].StatID = (uint)Stats.PhysicsLODTasks;
                    sb[26].StatValue = 0;

                    sb[27].StatID = (uint)Stats.SimPhysicsStepMS;
                    sb[27].StatValue = m_currentScene.PhysicsScene.StepTime;
                    
                    sb[28].StatID = (uint)Stats.SimPhysicsShape;
                    sb[28].StatValue = 0;

                    sb[29].StatID = (uint)Stats.SimPhysicsOtherMS;
                    sb[29].StatValue = (float)(physicsSyncFrameMonitor.GetValue() / realsimfps);

                    sb[30].StatID = (uint)Stats.SimPhysicsMemory;
                    sb[30].StatValue = 0;

                    sb[31].StatID = (uint)Stats.ScriptEPS;
                    sb[31].StatValue = totalScriptMonitor.ScriptEPS / statsUpdateFactor;
                    
                    sb[32].StatID = (uint)Stats.SimSpareTime;
                    //Spare time is the total time minus the stats that are in the same category in the client
                    // It is the sleep time, physics step, update physics shape, physics other, and pumpI0.
                    // Note: take out agent Update and script time for now, as they are not a part of the heartbeat right now and will mess this calc up
                    float SpareTime = (float)(TotalFrames - (/*NetMS + */ PhysicsMS + 
                        otherFrameMonitor.GetValue() + /*(agentUpdateFrameMonitor.AgentFrameTime / statsUpdateFactor) +*/
                        (imagesMonitor.GetValue() / statsUpdateFactor) /* + ScriptMS*/));
                    
                    sb[32].StatValue = SpareTime;

                    sb[33].StatID = (uint)Stats.SimSleepTime;
                    sb[33].StatValue = (float)(sleepFrameMonitor.GetValue() / realsimfps);

                    //Info about this stat: http://blogs.secondlife.com/message/66098
                    sb[34].StatID = (uint)Stats.IOPumpTime;
                    sb[34].StatValue = 0;//TODO: implement this

                    #endregion

                    for (int i = 0; i < sb.Length; i++)
                    {
                        if (float.IsInfinity(sb[i].StatValue) ||
                            float.IsNaN(sb[i].StatValue))
                            sb[i].StatValue = 0;
                        lastReportedSimStats[i] = sb[i].StatValue;
                    }

                    SimStats simStats
                        = new SimStats(rb, sb, m_currentScene.RegionInfo.RegionID);

                    //Fire the event and tell followers about the new stats
                    m_module.SendStatsResults(simStats);

                    //Tell all the scene presences about the new stats
                    foreach (IScenePresence agent in m_currentScene.GetScenePresences ())
                    {
                        if (!agent.IsChildAgent)
                            agent.ControllingClient.SendSimStats(simStats);
                    }
                    //Now fix any values that require reseting
                    ResetValues();
                }
            }
Beispiel #5
0
        private void statsHeartBeat(object sender, EventArgs e)
        {
            SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22];
            SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
            
            // Know what's not thread safe in Mono... modifying timers.
            // m_log.Debug("Firing Stats Heart Beat");
            lock (m_report)
            {
                uint regionFlags = 0;
                
                try
                {
                    if (estateModule == null)
                        estateModule = m_scene.RequestModuleInterface<IEstateModule>();
                    regionFlags = estateModule != null ? estateModule.GetRegionFlags() : (uint) 0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

#region various statistic googly moogly

                // 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);

                // save the reported value so there is something available for llGetRegionFPS 
                lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;

                float physfps = ((m_pfps / 1000));

                //if (physfps > 600)
                //physfps = physfps - (physfps - 600);

                if (physfps < 0)
                    physfps = 0;

#endregion

                m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
                m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
                m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount();
                m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount();
                m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();

                // FIXME: Checking for stat sanity is a complex approach.  What we really need to do is fix the code
                // so that stat numbers are always consistent.
                CheckStatSanity();
                
                //Our time dilation is 0.91 when we're running a full speed,
                // therefore to make sure we get an appropriate range,
                // we have to factor in our error.   (0.10f * statsUpdateFactor)
                // multiplies the fix for the error times the amount of times it'll occur a second
                // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
                // Then we divide the whole amount by the amount of seconds pass in between stats updates.

                // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
                // values to X-per-second values.

                uint thisFrame = m_scene.Frame;
                float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor;
                m_lastUpdateFrame = thisFrame;

                // Avoid div-by-zero if somehow we've not updated any frames.
                if (framesUpdated == 0)
                    framesUpdated = 1;

                for (int i = 0; i < 22; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }
                
                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[1].StatID = (uint) Stats.SimFPS;
                sb[1].StatValue = reportedFPS / m_statsUpdateFactor;

                sb[2].StatID = (uint) Stats.PhysicsFPS;
                sb[2].StatValue = physfps / m_statsUpdateFactor;

                sb[3].StatID = (uint) Stats.AgentUpdates;
                sb[3].StatValue = (m_agentUpdates / m_statsUpdateFactor);

                sb[4].StatID = (uint) Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID = (uint) Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID = (uint) Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID = (uint) Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                sb[8].StatID = (uint)Stats.FrameMS;
                sb[8].StatValue = m_frameMS / framesUpdated;

                sb[9].StatID = (uint)Stats.NetMS;
                sb[9].StatValue = m_netMS / framesUpdated;

                sb[10].StatID = (uint)Stats.PhysicsMS;
                sb[10].StatValue = m_physicsMS / framesUpdated;

                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[13].StatID = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);

                sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (m_outPacketsPerSecond / m_statsUpdateFactor);

                sb[15].StatID = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID = (uint)Stats.AgentMS;
                sb[16].StatValue = m_agentMS / framesUpdated;

                sb[17].StatID = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
                sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;

                sb[21].StatID = (uint)Stats.SimSpareMs;
                sb[21].StatValue = m_spareMS / framesUpdated;

                for (int i = 0; i < 22; i++)
                {
                    lastReportedSimStats[i] = sb[i].StatValue;
                }
              
                SimStats simStats 
                    = new SimStats(
                        ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
                        rb, sb, m_scene.RegionInfo.originRegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }

                // Extra statistics that aren't currently sent to clients
                lock (m_lastReportedExtraSimStats)
                {
                    m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor;
                    m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value;

                    Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
    
                    if (physicsStats != null)
                    {
                        foreach (KeyValuePair<string, float> tuple in physicsStats)
                        {
                            // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
                            // Need to change things so that stats source can indicate whether they are per second or
                            // per frame.
                            if (tuple.Key.EndsWith("MS"))
                                m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated;
                            else
                                m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
                        }
                    }
                }

                ResetValues();
            }
        }
Beispiel #6
0
        private void statsHeartBeat(object sender, EventArgs e)
        {
            SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
            SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();

            // Know what's not thread safe in Mono... modifying timers.
            // m_log.Debug("Firing Stats Heart Beat");
            lock (m_report)
            {
                uint regionFlags = 0;

                try
                {
                    if (estateModule == null)
                    {
                        estateModule = m_scene.RequestModuleInterface <IEstateModule>();
                    }
                    regionFlags = estateModule != null?estateModule.GetRegionFlags() : (uint)0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

                #region various statistic googly moogly

                // 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);

                // save the reported value so there is something available for llGetRegionFPS
                lastReportedSimFPS = reportedFPS / statsUpdateFactor;

                float physfps = ((m_pfps / 1000));

                //if (physfps > 600)
                //physfps = physfps - (physfps - 600);

                if (physfps < 0)
                {
                    physfps = 0;
                }

                #endregion

                //Our time dilation is 0.91 when we're running a full speed,
                // therefore to make sure we get an appropriate range,
                // we have to factor in our error.   (0.10f * statsUpdateFactor)
                // multiplies the fix for the error times the amount of times it'll occur a second
                // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
                // Then we divide the whole amount by the amount of seconds pass in between stats updates.

                // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
                // values to X-per-second values.

                for (int i = 0; i < 21; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }

                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[1].StatID    = (uint)Stats.SimFPS;
                sb[1].StatValue = reportedFPS / statsUpdateFactor;

                sb[2].StatID    = (uint)Stats.PhysicsFPS;
                sb[2].StatValue = physfps / statsUpdateFactor;

                sb[3].StatID    = (uint)Stats.AgentUpdates;
                sb[3].StatValue = (m_agentUpdates / statsUpdateFactor);

                sb[4].StatID    = (uint)Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID    = (uint)Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID    = (uint)Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID    = (uint)Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                sb[8].StatID    = (uint)Stats.FrameMS;
                sb[8].StatValue = m_frameMS / statsUpdateFactor;

                sb[9].StatID    = (uint)Stats.NetMS;
                sb[9].StatValue = m_netMS / statsUpdateFactor;

                sb[10].StatID    = (uint)Stats.PhysicsMS;
                sb[10].StatValue = m_physicsMS / statsUpdateFactor;

                sb[11].StatID    = (uint)Stats.ImageMS;
                sb[11].StatValue = m_imageMS / statsUpdateFactor;

                sb[12].StatID    = (uint)Stats.OtherMS;
                sb[12].StatValue = m_otherMS / statsUpdateFactor;

                sb[13].StatID    = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor);

                sb[14].StatID    = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);

                sb[15].StatID    = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID    = (uint)Stats.AgentMS;
                sb[16].StatValue = m_agentMS / statsUpdateFactor;

                sb[17].StatID    = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID    = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID    = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID    = (uint)Stats.ScriptLinesPerSecond;
                sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;

                for (int i = 0; i < 21; i++)
                {
                    lastReportedSimStats[i] = sb[i].StatValue;
                }

                SimStats simStats
                    = new SimStats(
                          ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
                          rb, sb, m_scene.RegionInfo.originRegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }

                // Extra statistics that aren't currently sent to clients
                LastReportedObjectUpdates = m_objectUpdates / statsUpdateFactor;

                resetvalues();
            }
        }
Beispiel #7
0
            protected void buildInitialRegionBlock()
            {
                rb = new SimStatsPacket.RegionBlock();
                uint regionFlags = 0;

                try
                {
                    if (m_estateModule == null)
                        m_estateModule = m_currentScene.RequestModuleInterface<IEstateModule>();
                    regionFlags = m_estateModule != null ? (uint)m_estateModule.GetRegionFlags() : 0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }
                rb.ObjectCapacity = (uint) m_currentScene.RegionInfo.ObjectCapacity;
                rb.RegionFlags = regionFlags;
                rb.RegionX = (uint) m_currentScene.RegionInfo.RegionLocX/Constants.RegionSize;
                rb.RegionY = (uint) m_currentScene.RegionInfo.RegionLocY/Constants.RegionSize;
            }
        private void statsHeartBeat(object sender, EventArgs e)
        {
            if (statsRunning)
            {
                return;
            }

            try
            {
                statsRunning = true;

                SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
                SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();

                uint regionFlags = 0;

                try
                {
                    if (estateModule == null)
                    {
                        estateModule = m_scene.RequestModuleInterface <IEstateModule>();
                    }
                    regionFlags = estateModule != null?estateModule.GetRegionFlags() : (uint)0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

                float simfps = (int)m_fps;
                // save the reported value so there is something available for llGetRegionFPS
                lastReportedSimFPS = (float)simfps / statsUpdateFactor;

                float physfps = m_pfps;

                if (physfps < 0)
                {
                    physfps = 0;
                }

                //Our time dilation is 0.91 when we're running a full speed,
                // therefore to make sure we get an appropriate range,
                // we have to factor in our error.   (0.10f * statsUpdateFactor)
                // multiplies the fix for the error times the amount of times it'll occur a second
                // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
                // Then we divide the whole amount by the amount of seconds pass in between stats updates.

                for (int i = 0; i < 21; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }

                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[1].StatID    = (uint)Stats.SimFPS;
                sb[1].StatValue = simfps / statsUpdateFactor;

                sb[2].StatID    = (uint)Stats.PhysicsFPS;
                sb[2].StatValue = physfps;

                sb[3].StatID    = (uint)Stats.AgentUpdates;
                sb[3].StatValue = (m_agentUpdates / statsUpdateFactor);

                sb[4].StatID    = (uint)Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID    = (uint)Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID    = (uint)Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID    = (uint)Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                sb[8].StatID    = (uint)Stats.FrameMS;
                sb[8].StatValue = m_frameMS / statsUpdateFactor;

                sb[9].StatID    = (uint)Stats.NetMS;
                sb[9].StatValue = m_netMS / statsUpdateFactor;

                sb[10].StatID    = (uint)Stats.PhysicsMS;
                sb[10].StatValue = m_physicsMS / statsUpdateFactor;

                sb[11].StatID    = (uint)Stats.ImageMS;
                sb[11].StatValue = m_imageMS / statsUpdateFactor;

                sb[12].StatID    = (uint)Stats.OtherMS;
                sb[12].StatValue = m_otherMS / statsUpdateFactor;

                sb[13].StatID    = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (m_inPacketsPerSecond);

                sb[14].StatID    = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);

                sb[15].StatID    = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID    = (uint)Stats.AgentMS;
                sb[16].StatValue = m_agentMS / statsUpdateFactor;

                sb[17].StatID    = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID    = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID    = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID    = (uint)Stats.ScriptLinesPerSecond;
                sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;

                SimStats simStats
                    = new SimStats(
                          ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)objectCapacity, rb, sb, m_scene.RegionInfo.originRegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }
                resetvalues();
            }
            finally
            {
                statsRunning = false;
            }
        }
 public SimStats(SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock, UUID pRUUID)
 {
     regionUUID = pRUUID;
     m_regionBlock = regionBlock;
     m_statsBlock = statsBlock;
 }
Beispiel #10
0
        private void statsHeartBeat(object sender, EventArgs e)
        {
            double totalSumFrameTime;
            double simulationSumFrameTime;
            double physicsSumFrameTime;
            double networkSumFrameTime;
            double networkSumQueueSize;
            float  frameDilation;
            int    currentFrame;

            if (!m_scene.Active)
            {
                return;
            }

            // 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();

            // Know what's not thread safe in Mono... modifying timers.
            // m_log.Debug("Firing Stats Heart Beat");
            lock (m_report)
            {
                uint regionFlags = 0;

                try
                {
                    if (estateModule == null)
                    {
                        estateModule = m_scene.RequestModuleInterface <IEstateModule>();
                    }
                    regionFlags = estateModule != null?estateModule.GetRegionFlags() : (uint)0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

                #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;

                // save the reported value so there is something available for llGetRegionFPS
                lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;

                // 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;

                //if (physfps > 600)
                //physfps = physfps - (physfps - 600);

                if (physfps < 0)
                {
                    physfps = 0;
                }

                #endregion

                m_rootAgents    = m_scene.SceneGraph.GetRootAgentCount();
                m_childAgents   = m_scene.SceneGraph.GetChildAgentCount();
                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_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();

                // FIXME: Checking for stat sanity is a complex approach.  What we really need to do is fix the code
                // so that stat numbers are always consistent.
                CheckStatSanity();

                //Our time dilation is 0.91 when we're running a full speed,
                // therefore to make sure we get an appropriate range,
                // we have to factor in our error.   (0.10f * statsUpdateFactor)
                // multiplies the fix for the error times the amount of times it'll occur a second
                // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
                // Then we divide the whole amount by the amount of seconds pass in between stats updates.

                // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
                // values to X-per-second values.

                uint  thisFrame     = m_scene.Frame;
                float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor;
                m_lastUpdateFrame = thisFrame;

                // Avoid div-by-zero if somehow we've not updated any frames.
                if (framesUpdated == 0)
                {
                    framesUpdated = 1;
                }

                for (int i = 0; i < m_statisticArraySize; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }

                // Resetting the sums of the frame times to prevent any errors
                // in calculating the moving average for frame time
                totalSumFrameTime      = 0;
                simulationSumFrameTime = 0;
                physicsSumFrameTime    = 0;
                networkSumFrameTime    = 0;
                networkSumQueueSize    = 0;

                // Loop through all the frames that were stored for the current
                // heartbeat to process the moving average of frame times
                for (int i = 0; i < m_numberFramesStored; i++)
                {
                    // Sum up each frame time in order to calculate the moving
                    // average of frame time
                    totalSumFrameTime      += m_totalFrameTimeMilliseconds[i];
                    simulationSumFrameTime +=
                        m_simulationFrameTimeMilliseconds[i];
                    physicsSumFrameTime += m_physicsFrameTimeMilliseconds[i];
                    networkSumFrameTime += m_networkFrameTimeMilliseconds[i];
                    networkSumQueueSize += m_networkQueueSize[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].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation;  //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10)  / statsUpdateFactor));

                sb[1].StatID    = (uint)Stats.SimFPS;
                sb[1].StatValue = reportedFPS / m_statsUpdateFactor;

                sb[2].StatID    = (uint)Stats.PhysicsFPS;
                sb[2].StatValue = physfps / m_statsUpdateFactor;

                sb[3].StatID    = (uint)Stats.AgentUpdates;
                sb[3].StatValue = (m_agentUpdates / m_statsUpdateFactor);

                sb[4].StatID    = (uint)Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID    = (uint)Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID    = (uint)Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID    = (uint)Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                // ORIGINAL code commented out until we have time to add our own
                // 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[9].StatID = (uint)Stats.NetMS;
                //sb[9].StatValue = m_netMS / framesUpdated;
                sb[9].StatValue = (float)networkSumFrameTime / m_numberFramesStored;

                sb[10].StatID = (uint)Stats.PhysicsMS;
                //sb[10].StatValue = m_physicsMS / framesUpdated;
                sb[10].StatValue = (float)physicsSumFrameTime / m_numberFramesStored;

                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[13].StatID    = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (float)m_inPacketsPerSecond;

                sb[14].StatID    = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (float)m_outPacketsPerSecond;

                sb[15].StatID    = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID    = (uint)Stats.AgentMS;
                sb[16].StatValue = m_agentMS / framesUpdated;

                sb[17].StatID    = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID    = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID    = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID    = (uint)Stats.ScriptLinesPerSecond;
                sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;

                sb[21].StatID    = (uint)Stats.SimSpareMs;
                sb[21].StatValue = m_spareMS / framesUpdated;

                // 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.Count;

                // 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;

                // Tracks the number of bytes that are received by the server's
                // UDP network handler
                sb[27].StatID    = (uint)Stats.UDPInRate;
                sb[27].StatValue = (float)m_inByteRate;

                // Tracks the number of bytes that are sent by the server's UDP
                // network handler
                sb[28].StatID    = (uint)Stats.UDPOutRate;
                sb[28].StatValue = (float)m_outByteRate;

                // Tracks the number of packets that were received by the
                // server's UDP network handler, that were unable to be processed
                sb[29].StatID    = (uint)Stats.UDPErrorRate;
                sb[29].StatValue = (float)m_errorPacketRate;

                // Track the queue size of the network as a moving average
                sb[30].StatID    = (uint)Stats.NetworkQueueSize;
                sb[30].StatValue = (float)networkSumQueueSize /
                                   m_numberFramesStored;

                // Current average ping between the server and a subset of its conneced users
                sb[31].StatID    = (uint)Stats.ClientPingAvg;
                sb[31].StatValue = (float)m_clientPing;

                for (int i = 0; i < m_statisticArraySize; i++)
                {
                    lastReportedSimStats[i] = sb[i].StatValue;
                }

                SimStats simStats
                    = new SimStats(
                          ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
                          rb, sb, m_scene.RegionInfo.originRegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }

                // Extra statistics that aren't currently sent to clients
                lock (m_lastReportedExtraSimStats)
                {
                    m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor;
                    m_lastReportedExtraSimStats[SlowFramesStat.ShortName]         = (float)SlowFramesStat.Value;

                    Dictionary <string, float> physicsStats = m_scene.PhysicsScene.GetStats();

                    if (physicsStats != null)
                    {
                        foreach (KeyValuePair <string, float> tuple in physicsStats)
                        {
                            // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
                            // Need to change things so that stats source can indicate whether they are per second or
                            // per frame.
                            if (tuple.Key.EndsWith("MS"))
                            {
                                m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated;
                            }
                            else
                            {
                                m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
                            }
                        }
                    }
                }

                ResetValues();
            }
        }
Beispiel #11
0
        private void statsHeartBeat(object sender, EventArgs e)
        {
            if (!m_scene.Active)
            {
                return;
            }

            SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22];
            SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();

            // Know what's not thread safe in Mono... modifying timers.
            // m_log.Debug("Firing Stats Heart Beat");
            lock (m_report)
            {
                uint regionFlags = 0;

                try
                {
                    if (estateModule == null)
                    {
                        estateModule = m_scene.RequestModuleInterface <IEstateModule>();
                    }
                    regionFlags = estateModule != null?estateModule.GetRegionFlags() : (uint)0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

                #region various statistic googly moogly

                // 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);

                // save the reported value so there is something available for llGetRegionFPS
                lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;

                float physfps = ((m_pfps / 1000));

                //if (physfps > 600)
                //physfps = physfps - (physfps - 600);

                if (physfps < 0)
                {
                    physfps = 0;
                }

                #endregion various statistic googly moogly

                m_rootAgents    = m_scene.SceneGraph.GetRootAgentCount();
                m_childAgents   = m_scene.SceneGraph.GetChildAgentCount();
                m_numPrim       = m_scene.SceneGraph.GetTotalObjectsCount();
                m_activePrim    = m_scene.SceneGraph.GetActiveObjectsCount();
                m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();

                // FIXME: Checking for stat sanity is a complex approach.  What we really need to do is fix the code
                // so that stat numbers are always consistent.
                CheckStatSanity();

                //Our time dilation is 0.91 when we're running a full speed,
                // therefore to make sure we get an appropriate range,
                // we have to factor in our error.   (0.10f * statsUpdateFactor)
                // multiplies the fix for the error times the amount of times it'll occur a second
                // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
                // Then we divide the whole amount by the amount of seconds pass in between stats updates.

                // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
                // values to X-per-second values.

                uint  thisFrame     = m_scene.Frame;
                float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor;
                m_lastUpdateFrame = thisFrame;

                // Avoid div-by-zero if somehow we've not updated any frames.
                if (framesUpdated == 0)
                {
                    framesUpdated = 1;
                }

                for (int i = 0; i < 22; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }

                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[1].StatID    = (uint)Stats.SimFPS;
                sb[1].StatValue = reportedFPS / m_statsUpdateFactor;

                sb[2].StatID    = (uint)Stats.PhysicsFPS;
                sb[2].StatValue = physfps / m_statsUpdateFactor;

                sb[3].StatID    = (uint)Stats.AgentUpdates;
                sb[3].StatValue = (m_agentUpdates / m_statsUpdateFactor);

                sb[4].StatID    = (uint)Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID    = (uint)Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID    = (uint)Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID    = (uint)Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                sb[8].StatID    = (uint)Stats.FrameMS;
                sb[8].StatValue = m_frameMS / framesUpdated;

                sb[9].StatID    = (uint)Stats.NetMS;
                sb[9].StatValue = m_netMS / framesUpdated;

                sb[10].StatID    = (uint)Stats.PhysicsMS;
                sb[10].StatValue = m_physicsMS / framesUpdated;

                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[13].StatID    = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);

                sb[14].StatID    = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (m_outPacketsPerSecond / m_statsUpdateFactor);

                sb[15].StatID    = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID    = (uint)Stats.AgentMS;
                sb[16].StatValue = m_agentMS / framesUpdated;

                sb[17].StatID    = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID    = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID    = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID    = (uint)Stats.ScriptLinesPerSecond;
                sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;

                sb[21].StatID    = (uint)Stats.SimSpareMs;
                sb[21].StatValue = m_spareMS / framesUpdated;

                for (int i = 0; i < 22; i++)
                {
                    lastReportedSimStats[i] = sb[i].StatValue;
                }

                SimStats simStats
                    = new SimStats(
                          ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
                          rb, sb, m_scene.RegionInfo.originRegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }

                // Extra statistics that aren't currently sent to clients
                lock (m_lastReportedExtraSimStats)
                {
                    m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor;
                    m_lastReportedExtraSimStats[SlowFramesStat.ShortName]         = (float)SlowFramesStat.Value;

                    Dictionary <string, float> physicsStats = m_scene.PhysicsScene.GetStats();

                    if (physicsStats != null)
                    {
                        foreach (KeyValuePair <string, float> tuple in physicsStats)
                        {
                            // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
                            // Need to change things so that stats source can indicate whether they are per second or
                            // per frame.
                            if (tuple.Key.EndsWith("MS"))
                            {
                                m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated;
                            }
                            else
                            {
                                m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
                            }
                        }
                    }
                }

                ResetValues();
            }
        }
Beispiel #12
0
 public SimStats(SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock, UUID pRUUID)
 {
     regionUUID    = pRUUID;
     m_regionBlock = regionBlock;
     m_statsBlock  = statsBlock;
 }
Beispiel #13
0
        private void statsHeartBeat(object sender, EventArgs e)
        {
              if (!m_scene.Active)
                return;
            
            // dont do it if if still been done

            if(Monitor.TryEnter(m_statsLock))
            {
                // m_log.Debug("Firing Stats Heart Beat");

                SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[m_statisticViewerArraySize];
                SimStatsPacket.StatBlock[] sbex = new SimStatsPacket.StatBlock[m_statisticExtraArraySize];
                SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
                uint regionFlags = 0;

                try
                {
                    if (estateModule == null)
                        estateModule = m_scene.RequestModuleInterface<IEstateModule>();
                    regionFlags = estateModule != null ? estateModule.GetRegionFlags() : (uint) 0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

#region various statistic googly moogly
                double timeTmp = m_lastUpdateTS;
                m_lastUpdateTS = Util.GetTimeStampMS();
                float updateElapsed = (float)((m_lastUpdateTS - timeTmp)/1000.0);

                // factor to consider updates integration time
                float updateTimeFactor = 1.0f / updateElapsed;

               
                // scene frame stats 
                float reportedFPS;
                float physfps;
                float timeDilation;
                float agentMS;
                float physicsMS;
                float otherMS;
                float sleeptime;
                float scriptTimeMS;
                float totalFrameTime;

                float invFrameElapsed;

                // get a copy under lock and reset
                lock(m_statsFrameLock)
                {
                    timeDilation   = m_timeDilation;
                    reportedFPS    = m_fps;
                    physfps        = m_pfps;
                    agentMS        = m_agentMS;
                    physicsMS      = m_physicsMS;
                    otherMS        = m_otherMS;
                    sleeptime      = m_sleeptimeMS;
                    scriptTimeMS   = m_scriptTimeMS;
                    totalFrameTime = m_frameMS;
                    // still not inv 
                    invFrameElapsed = (float)((m_FrameStatsTS - m_prevFrameStatsTS) / 1000.0);

                    ResetFrameStats();
                }

                if (invFrameElapsed / updateElapsed < 0.8)
                   // scene is in trouble, its account of time is most likely wrong
                   // can even be in stall
                   invFrameElapsed = updateTimeFactor;
                else
                    invFrameElapsed = 1.0f / invFrameElapsed;

                float perframefactor;
                if (reportedFPS <= 0)
                {
                   reportedFPS = 0.0f;
                   physfps = 0.0f;
                   perframefactor = 1.0f;
                   timeDilation = 0.0f;
                }
                else
                {
                   timeDilation /= reportedFPS;
                   reportedFPS *=  m_statisticsFPSfactor;
                   perframefactor = 1.0f / (float)reportedFPS;
                   reportedFPS *= invFrameElapsed;
                   physfps *= invFrameElapsed  * m_statisticsFPSfactor;
                }

                // some engines track frame time with error related to the simulation step size
                if(physfps > reportedFPS) 
                    physfps = reportedFPS;

                // save the reported value so there is something available for llGetRegionFPS 
                lastReportedSimFPS = reportedFPS;

                // scale frame stats

                totalFrameTime *= perframefactor;
                sleeptime      *= perframefactor;
                otherMS        *= perframefactor;
                physicsMS      *= perframefactor;
                agentMS        *= perframefactor;
                scriptTimeMS   *= perframefactor;

                // estimate spare time
                float sparetime;
                sparetime      = m_targetFrameTime - (physicsMS + agentMS + otherMS);

                if (sparetime < 0)
                    sparetime = 0;
                 else if (sparetime > totalFrameTime)
                        sparetime = totalFrameTime;

#endregion

                m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
                m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
                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_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();
                m_scriptLinesPerSecond = m_scene.SceneGraph.GetScriptLPS();

                 // FIXME: Checking for stat sanity is a complex approach.  What we really need to do is fix the code
                // so that stat numbers are always consistent.
                CheckStatSanity(); 
 
                for (int i = 0; i < m_statisticViewerArraySize; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }
              
                sb[0].StatID = (uint) Stats.TimeDilation;
                sb[0].StatValue = (Single.IsNaN(timeDilation)) ? 0.0f : (float)Math.Round(timeDilation,3);

                sb[1].StatID = (uint) Stats.SimFPS;
                sb[1].StatValue = (float)Math.Round(reportedFPS,1);;

                sb[2].StatID = (uint) Stats.PhysicsFPS;
                sb[2].StatValue =  (float)Math.Round(physfps,1);

                sb[3].StatID = (uint) Stats.AgentUpdates;
                sb[3].StatValue = m_agentUpdates * updateTimeFactor;

                sb[4].StatID = (uint) Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID = (uint) Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID = (uint) Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID = (uint) Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                sb[8].StatID = (uint)Stats.FrameMS;
                sb[8].StatValue = totalFrameTime;

                sb[9].StatID = (uint)Stats.NetMS;
                sb[9].StatValue = m_netMS * perframefactor;

                sb[10].StatID = (uint)Stats.PhysicsMS;
                sb[10].StatValue = physicsMS;

                sb[11].StatID = (uint)Stats.ImageMS ;
                sb[11].StatValue = m_imageMS * perframefactor;

                sb[12].StatID = (uint)Stats.OtherMS;
                sb[12].StatValue = otherMS;

                sb[13].StatID = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (float)Math.Round(m_inPacketsPerSecond * updateTimeFactor);

                sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (float)Math.Round(m_outPacketsPerSecond * updateTimeFactor);

                sb[15].StatID = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID = (uint)Stats.AgentMS;
                sb[16].StatValue = agentMS;

                sb[17].StatID = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID = (uint)Stats.SimSleepMs;
                sb[20].StatValue = sleeptime;

                sb[21].StatID = (uint)Stats.SimSpareMs;
                sb[21].StatValue = sparetime;

                //  this should came from phys engine
                sb[22].StatID = (uint)Stats.SimPhysicsStepMs;
                sb[22].StatValue = 20;

                // send the ones we dont have as zeros, to clean viewers state
                // specially arriving from regions with wrond IDs in use

                sb[23].StatID = (uint)Stats.VirtualSizeKb;
                sb[23].StatValue = 0;

                sb[24].StatID = (uint)Stats.ResidentSizeKb;
                sb[24].StatValue = 0;
                
                sb[25].StatID = (uint)Stats.PendingLocalUploads;
                sb[25].StatValue = 0;
                
                sb[26].StatID = (uint)Stats.PhysicsPinnedTasks;
                sb[26].StatValue = 0;
                
                sb[27].StatID = (uint)Stats.PhysicsLodTasks;
                sb[27].StatValue = 0;

                sb[28].StatID = (uint)Stats.ScriptEps; // we actuall have this, but not messing array order AGAIN
                sb[28].StatValue = (float)Math.Round(m_scriptEventsPerSecond * updateTimeFactor);

                sb[29].StatID = (uint)Stats.SimAIStepTimeMS;
                sb[29].StatValue = 0;

                sb[30].StatID = (uint)Stats.SimIoPumpTime;
                sb[30].StatValue = 0;

                sb[31].StatID = (uint)Stats.SimPCTSscriptsRun;
                sb[31].StatValue = 0;

                sb[32].StatID = (uint)Stats.SimRegionIdle;
                sb[32].StatValue = 0;

                sb[33].StatID = (uint)Stats.SimRegionIdlePossible;
                sb[33].StatValue = 0;

                sb[34].StatID = (uint)Stats.SimSkippedSillouet_PS;
                sb[34].StatValue = 0;

                sb[35].StatID = (uint)Stats.SimSkippedCharsPerC;
                sb[35].StatValue = 0;

                sb[36].StatID = (uint)Stats.SimPhysicsMemory;
                sb[36].StatValue = 0;

                sb[37].StatID = (uint)Stats.ScriptMS;
                sb[37].StatValue = scriptTimeMS;

                for (int i = 0; i < m_statisticViewerArraySize; i++)
                {
                    lastReportedSimStats[i] = sb[i].StatValue;
                }


                // add extra stats for internal use

                for (int i = 0; i < m_statisticExtraArraySize; i++)
                {
                    sbex[i] = new SimStatsPacket.StatBlock();
                }

                sbex[0].StatID = (uint)Stats.LSLScriptLinesPerSecond;
                sbex[0].StatValue = m_scriptLinesPerSecond * updateTimeFactor;
                lastReportedSimStats[38] = m_scriptLinesPerSecond * updateTimeFactor;

                sbex[1].StatID = (uint)Stats.FrameDilation2;
                sbex[1].StatValue = (Single.IsNaN(timeDilation)) ? 0.1f : timeDilation;
                lastReportedSimStats[39] = (Single.IsNaN(timeDilation)) ? 0.1f : timeDilation;

                sbex[2].StatID = (uint)Stats.UsersLoggingIn;
                sbex[2].StatValue = m_usersLoggingIn;
                lastReportedSimStats[40] = m_usersLoggingIn;

                sbex[3].StatID = (uint)Stats.TotalGeoPrim;
                sbex[3].StatValue = m_numGeoPrim;
                lastReportedSimStats[41] = m_numGeoPrim;

                sbex[4].StatID = (uint)Stats.TotalMesh;
                sbex[4].StatValue = m_numMesh;
                lastReportedSimStats[42] = m_numMesh;

                sbex[5].StatID = (uint)Stats.ThreadCount;
                sbex[5].StatValue = m_inUseThreads;
                lastReportedSimStats[43] = m_inUseThreads;

                SimStats simStats 
                    = new SimStats(
                        ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
                        rb, sb, sbex, m_scene.RegionInfo.originRegionID);

                 handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }

                // Extra statistics that aren't currently sent to clients
                if (m_scene.PhysicsScene != null)
                {
                    lock (m_lastReportedExtraSimStats)
                    {
                        m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates * updateTimeFactor;
                        m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value;

                        Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
        
                        if (physicsStats != null)
                        {
                            foreach (KeyValuePair<string, float> tuple in physicsStats)
                            {
                                // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
                                // Need to change things so that stats source can indicate whether they are per second or
                                // per frame.
                                if (tuple.Key.EndsWith("MS"))
                                    m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframefactor;
                                else
                                    m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * updateTimeFactor;
                            }
                        }
                    }
                }

//                LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor;
                ResetValues();
                Monitor.Exit(m_statsLock);
            }
        }
Beispiel #14
0
        private void statsHeartBeat(object sender, EventArgs e)
        {
            if (!m_scene.Active)
            {
                return;
            }

            // dont do it if if still been done

            if (Monitor.TryEnter(m_statsLock))
            {
                // m_log.Debug("Firing Stats Heart Beat");

                SimStatsPacket.StatBlock[] sb   = new SimStatsPacket.StatBlock[m_statisticViewerArraySize];
                SimStatsPacket.StatBlock[] sbex = new SimStatsPacket.StatBlock[m_statisticExtraArraySize];
                SimStatsPacket.RegionBlock rb   = new SimStatsPacket.RegionBlock();
                uint regionFlags = 0;

                try
                {
                    if (estateModule == null)
                    {
                        estateModule = m_scene.RequestModuleInterface <IEstateModule>();
                    }
                    regionFlags = estateModule != null?estateModule.GetRegionFlags() : (uint)0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

                #region various statistic googly moogly
                double timeTmp = m_lastUpdateTS;
                m_lastUpdateTS = Util.GetTimeStampMS();
                float updateElapsed = (float)((m_lastUpdateTS - timeTmp) / 1000.0);

                // factor to consider updates integration time
                float updateTimeFactor = 1.0f / updateElapsed;


                // scene frame stats
                float reportedFPS;
                float physfps;
                float timeDilation;
                float agentMS;
                float physicsMS;
                float otherMS;
                float sleeptime;
                float scriptTimeMS;
                float totalFrameTime;

                float invFrameElapsed;

                // get a copy under lock and reset
                lock (m_statsFrameLock)
                {
                    timeDilation   = m_timeDilation;
                    reportedFPS    = m_fps;
                    physfps        = m_pfps;
                    agentMS        = m_agentMS;
                    physicsMS      = m_physicsMS;
                    otherMS        = m_otherMS;
                    sleeptime      = m_sleeptimeMS;
                    scriptTimeMS   = m_scriptTimeMS;
                    totalFrameTime = m_frameMS;
                    // still not inv
                    invFrameElapsed = (float)((m_FrameStatsTS - m_prevFrameStatsTS) / 1000.0);

                    ResetFrameStats();
                }

                if (invFrameElapsed / updateElapsed < 0.8)
                {
                    // scene is in trouble, its account of time is most likely wrong
                    // can even be in stall
                    invFrameElapsed = updateTimeFactor;
                }
                else
                {
                    invFrameElapsed = 1.0f / invFrameElapsed;
                }

                float perframefactor;
                if (reportedFPS <= 0)
                {
                    reportedFPS    = 0.0f;
                    physfps        = 0.0f;
                    perframefactor = 1.0f;
                    timeDilation   = 0.0f;
                }
                else
                {
                    timeDilation  /= reportedFPS;
                    reportedFPS   *= m_statisticsFPSfactor;
                    perframefactor = 1.0f / (float)reportedFPS;
                    reportedFPS   *= invFrameElapsed;
                    physfps       *= invFrameElapsed * m_statisticsFPSfactor;
                }

                // some engines track frame time with error related to the simulation step size
                if (physfps > reportedFPS)
                {
                    physfps = reportedFPS;
                }

                // save the reported value so there is something available for llGetRegionFPS
                lastReportedSimFPS = reportedFPS;

                // scale frame stats

                totalFrameTime *= perframefactor;
                sleeptime      *= perframefactor;
                otherMS        *= perframefactor;
                physicsMS      *= perframefactor;
                agentMS        *= perframefactor;
                scriptTimeMS   *= perframefactor;

                // estimate spare time
                float sparetime;
                sparetime = m_targetFrameTime - (physicsMS + agentMS + otherMS);

                if (sparetime < 0)
                {
                    sparetime = 0;
                }
                else if (sparetime > totalFrameTime)
                {
                    sparetime = totalFrameTime;
                }

                #endregion

                m_rootAgents           = m_scene.SceneGraph.GetRootAgentCount();
                m_childAgents          = m_scene.SceneGraph.GetChildAgentCount();
                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_activeScripts        = m_scene.SceneGraph.GetActiveScriptsCount();
                m_scriptLinesPerSecond = m_scene.SceneGraph.GetScriptLPS();

                // FIXME: Checking for stat sanity is a complex approach.  What we really need to do is fix the code
                // so that stat numbers are always consistent.
                CheckStatSanity();

                for (int i = 0; i < m_statisticViewerArraySize; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }

                sb[0].StatID    = (uint)Stats.TimeDilation;
                sb[0].StatValue = (Single.IsNaN(timeDilation)) ? 0.0f : (float)Math.Round(timeDilation, 3);

                sb[1].StatID    = (uint)Stats.SimFPS;
                sb[1].StatValue = (float)Math.Round(reportedFPS, 1);;

                sb[2].StatID    = (uint)Stats.PhysicsFPS;
                sb[2].StatValue = (float)Math.Round(physfps, 1);

                sb[3].StatID    = (uint)Stats.AgentUpdates;
                sb[3].StatValue = m_agentUpdates * updateTimeFactor;

                sb[4].StatID    = (uint)Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID    = (uint)Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID    = (uint)Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID    = (uint)Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                sb[8].StatID    = (uint)Stats.FrameMS;
                sb[8].StatValue = totalFrameTime;

                sb[9].StatID    = (uint)Stats.NetMS;
                sb[9].StatValue = m_netMS * perframefactor;

                sb[10].StatID    = (uint)Stats.PhysicsMS;
                sb[10].StatValue = physicsMS;

                sb[11].StatID    = (uint)Stats.ImageMS;
                sb[11].StatValue = m_imageMS * perframefactor;

                sb[12].StatID    = (uint)Stats.OtherMS;
                sb[12].StatValue = otherMS;

                sb[13].StatID    = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (float)Math.Round(m_inPacketsPerSecond * updateTimeFactor);

                sb[14].StatID    = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (float)Math.Round(m_outPacketsPerSecond * updateTimeFactor);

                sb[15].StatID    = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID    = (uint)Stats.AgentMS;
                sb[16].StatValue = agentMS;

                sb[17].StatID    = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID    = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID    = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID    = (uint)Stats.SimSleepMs;
                sb[20].StatValue = sleeptime;

                sb[21].StatID    = (uint)Stats.SimSpareMs;
                sb[21].StatValue = sparetime;

                //  this should came from phys engine
                sb[22].StatID    = (uint)Stats.SimPhysicsStepMs;
                sb[22].StatValue = 20;

                // send the ones we dont have as zeros, to clean viewers state
                // specially arriving from regions with wrond IDs in use

                sb[23].StatID    = (uint)Stats.VirtualSizeKb;
                sb[23].StatValue = 0;

                sb[24].StatID    = (uint)Stats.ResidentSizeKb;
                sb[24].StatValue = 0;

                sb[25].StatID    = (uint)Stats.PendingLocalUploads;
                sb[25].StatValue = 0;

                sb[26].StatID    = (uint)Stats.PhysicsPinnedTasks;
                sb[26].StatValue = 0;

                sb[27].StatID    = (uint)Stats.PhysicsLodTasks;
                sb[27].StatValue = 0;

                sb[28].StatID    = (uint)Stats.ScriptEps; // we actually have this, but not messing array order AGAIN
                sb[28].StatValue = (float)Math.Round(m_scriptEventsPerSecond * updateTimeFactor);

                sb[29].StatID    = (uint)Stats.SimAIStepTimeMS;
                sb[29].StatValue = 0;

                sb[30].StatID    = (uint)Stats.SimIoPumpTime;
                sb[30].StatValue = 0;

                sb[31].StatID    = (uint)Stats.SimPCTSscriptsRun;
                sb[31].StatValue = 0;

                sb[32].StatID    = (uint)Stats.SimRegionIdle;
                sb[32].StatValue = 0;

                sb[33].StatID    = (uint)Stats.SimRegionIdlePossible;
                sb[33].StatValue = 0;

                sb[34].StatID    = (uint)Stats.SimSkippedSillouet_PS;
                sb[34].StatValue = 0;

                sb[35].StatID    = (uint)Stats.SimSkippedCharsPerC;
                sb[35].StatValue = 0;

                sb[36].StatID    = (uint)Stats.SimPhysicsMemory;
                sb[36].StatValue = 0;

                sb[37].StatID    = (uint)Stats.ScriptMS;
                sb[37].StatValue = scriptTimeMS;

                for (int i = 0; i < m_statisticViewerArraySize; i++)
                {
                    lastReportedSimStats[i] = sb[i].StatValue;
                }


                // add extra stats for internal use

                for (int i = 0; i < m_statisticExtraArraySize; i++)
                {
                    sbex[i] = new SimStatsPacket.StatBlock();
                }

                sbex[0].StatID           = (uint)Stats.LSLScriptLinesPerSecond;
                sbex[0].StatValue        = m_scriptLinesPerSecond * updateTimeFactor;
                lastReportedSimStats[38] = m_scriptLinesPerSecond * updateTimeFactor;

                sbex[1].StatID           = (uint)Stats.FrameDilation2;
                sbex[1].StatValue        = (Single.IsNaN(timeDilation)) ? 0.1f : timeDilation;
                lastReportedSimStats[39] = (Single.IsNaN(timeDilation)) ? 0.1f : timeDilation;

                sbex[2].StatID           = (uint)Stats.UsersLoggingIn;
                sbex[2].StatValue        = m_usersLoggingIn;
                lastReportedSimStats[40] = m_usersLoggingIn;

                sbex[3].StatID           = (uint)Stats.TotalGeoPrim;
                sbex[3].StatValue        = m_numGeoPrim;
                lastReportedSimStats[41] = m_numGeoPrim;

                sbex[4].StatID           = (uint)Stats.TotalMesh;
                sbex[4].StatValue        = m_numMesh;
                lastReportedSimStats[42] = m_numMesh;

                sbex[5].StatID           = (uint)Stats.ThreadCount;
                sbex[5].StatValue        = m_inUseThreads;
                lastReportedSimStats[43] = m_inUseThreads;

                SimStats simStats
                    = new SimStats(
                          ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
                          rb, sb, sbex, m_scene.RegionInfo.originRegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }

                // Extra statistics that aren't currently sent to clients
                if (m_scene.PhysicsScene != null)
                {
                    lock (m_lastReportedExtraSimStats)
                    {
                        m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates * updateTimeFactor;
                        m_lastReportedExtraSimStats[SlowFramesStat.ShortName]         = (float)SlowFramesStat.Value;

                        Dictionary <string, float> physicsStats = m_scene.PhysicsScene.GetStats();

                        if (physicsStats != null)
                        {
                            foreach (KeyValuePair <string, float> tuple in physicsStats)
                            {
                                // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
                                // Need to change things so that stats source can indicate whether they are per second or
                                // per frame.
                                if (tuple.Key.EndsWith("MS"))
                                {
                                    m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframefactor;
                                }
                                else
                                {
                                    m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * updateTimeFactor;
                                }
                            }
                        }
                    }
                }

                //                LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor;
                ResetValues();
                Monitor.Exit(m_statsLock);
            }
        }
Beispiel #15
0
        private void statsHeartBeat(object sender, EventArgs e)
        {
            if (statsRunning) return;

            try
            {
                statsRunning = true;

                SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
                SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();

                uint regionFlags = 0;

                try
                {
                    if (estateModule == null)
                        estateModule = m_scene.RequestModuleInterface<IEstateModule>();
                    regionFlags = estateModule != null ? estateModule.GetRegionFlags() : (uint)0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

                float simfps = (int)m_fps;
                // save the reported value so there is something available for llGetRegionFPS 
                lastReportedSimFPS = (float)simfps / statsUpdateFactor;

                float physfps = m_pfps;

                if (physfps < 0)
                    physfps = 0;

                //Our time dilation is 0.91 when we're running a full speed,
                // therefore to make sure we get an appropriate range,
                // we have to factor in our error.   (0.10f * statsUpdateFactor)
                // multiplies the fix for the error times the amount of times it'll occur a second
                // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
                // Then we divide the whole amount by the amount of seconds pass in between stats updates.

                for (int i = 0; i < 21; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }

                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[1].StatID = (uint)Stats.SimFPS;
                sb[1].StatValue = simfps / statsUpdateFactor;

                sb[2].StatID = (uint)Stats.PhysicsFPS;
                sb[2].StatValue = physfps;

                sb[3].StatID = (uint)Stats.AgentUpdates;
                sb[3].StatValue = (m_agentUpdates / statsUpdateFactor);

                sb[4].StatID = (uint)Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID = (uint)Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID = (uint)Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID = (uint)Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                sb[8].StatID = (uint)Stats.FrameMS;
                sb[8].StatValue = m_frameMS / statsUpdateFactor;

                sb[9].StatID = (uint)Stats.NetMS;
                sb[9].StatValue = m_netMS / statsUpdateFactor;

                sb[10].StatID = (uint)Stats.PhysicsMS;
                sb[10].StatValue = m_physicsMS / statsUpdateFactor;

                sb[11].StatID = (uint)Stats.ImageMS;
                sb[11].StatValue = m_imageMS / statsUpdateFactor;

                sb[12].StatID = (uint)Stats.OtherMS;
                sb[12].StatValue = m_otherMS / statsUpdateFactor;

                sb[13].StatID = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (m_inPacketsPerSecond);

                sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);

                sb[15].StatID = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID = (uint)Stats.AgentMS;
                sb[16].StatValue = m_agentMS / statsUpdateFactor;

                sb[17].StatID = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
                sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;

                SimStats simStats
                    = new SimStats(
                        ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)objectCapacity, rb, sb, m_scene.RegionInfo.originRegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }
                resetvalues();
            }
            finally
            {
                statsRunning = false;
            }
        }
Beispiel #16
0
        private void statsHeartBeat(object sender, EventArgs e)
        {
            SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
            SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
            
            // Know what's not thread safe in Mono... modifying timers.
            // m_log.Debug("Firing Stats Heart Beat");
            lock (m_report)
            {
                uint regionFlags = 0;
                
                try
                {
                    if (estateModule == null)
                        estateModule = m_scene.RequestModuleInterface<IEstateModule>();
                    regionFlags = estateModule != null ? estateModule.GetRegionFlags() : (uint) 0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

#region various statistic googly moogly

                // 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);

                // save the reported value so there is something available for llGetRegionFPS 
                lastReportedSimFPS = reportedFPS / statsUpdateFactor;

                float physfps = ((m_pfps / 1000));

                //if (physfps > 600)
                //physfps = physfps - (physfps - 600);

                if (physfps < 0)
                    physfps = 0;

#endregion
                
                //Our time dilation is 0.91 when we're running a full speed,
                // therefore to make sure we get an appropriate range,
                // we have to factor in our error.   (0.10f * statsUpdateFactor)
                // multiplies the fix for the error times the amount of times it'll occur a second
                // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
                // Then we divide the whole amount by the amount of seconds pass in between stats updates.

                // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
                // values to X-per-second values.

                for (int i = 0; i < 21; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }
                
                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[1].StatID = (uint) Stats.SimFPS;
                sb[1].StatValue = reportedFPS / statsUpdateFactor;

                sb[2].StatID = (uint) Stats.PhysicsFPS;
                sb[2].StatValue = physfps / statsUpdateFactor;

                sb[3].StatID = (uint) Stats.AgentUpdates;
                sb[3].StatValue = (m_agentUpdates / statsUpdateFactor);

                sb[4].StatID = (uint) Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID = (uint) Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID = (uint) Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID = (uint) Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                sb[8].StatID = (uint)Stats.FrameMS;
                sb[8].StatValue = m_frameMS / statsUpdateFactor;

                sb[9].StatID = (uint)Stats.NetMS;
                sb[9].StatValue = m_netMS / statsUpdateFactor;

                sb[10].StatID = (uint)Stats.PhysicsMS;
                sb[10].StatValue = m_physicsMS / statsUpdateFactor;

                sb[11].StatID = (uint)Stats.ImageMS ;
                sb[11].StatValue = m_imageMS / statsUpdateFactor;

                sb[12].StatID = (uint)Stats.OtherMS;
                sb[12].StatValue = m_otherMS / statsUpdateFactor;

                sb[13].StatID = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor);

                sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);

                sb[15].StatID = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID = (uint)Stats.AgentMS;
                sb[16].StatValue = m_agentMS / statsUpdateFactor;

                sb[17].StatID = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
                sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;
                
                for (int i = 0; i < 21; i++)
                {
                    lastReportedSimStats[i] = sb[i].StatValue;
                }
              
                SimStats simStats 
                    = new SimStats(
                        ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
                        rb, sb, m_scene.RegionInfo.originRegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }

                // Extra statistics that aren't currently sent to clients
                LastReportedObjectUpdates = m_objectUpdates / statsUpdateFactor;

                resetvalues();
            }
        }
        private void statsHeartBeat(object sender, EventArgs e)
        {
            SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23];
            SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
            
            float factorByframe;
            float factor;

            // Know what's not thread safe in Mono... modifying timers.
            // m_log.Debug("Firing Stats Heart Beat");
            lock (m_report)
            {
                uint regionFlags = 0;
                
                try
                {
                    if (estateModule == null)
                        estateModule = m_scene.RequestModuleInterface<IEstateModule>();
                    regionFlags = estateModule != null ? estateModule.GetRegionFlags() : (uint) 0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

#region various statistic googly moogly  

                // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there
                // 0-50 is pretty close to 0-45
 // show real
                float simfps = (int) ((m_fps));
                if (simfps == 0.0)
                    simfps = 10; //  we still don't have stats on this

                // factor to convert things to per second
                factor = 1 / statsUpdateFactor;
                // factor to convert things for time per frame need because how acumulators work
                //                factorByframe = factor / simfps;
                factorByframe = 1 / simfps;
                				
                // save the reported value so there is something available for llGetRegionFPS 
                lastReportedSimFPS = simfps * factor;

                float physfps = ((m_pfps));

                if (physfps < 0)
                    physfps = 0;

#endregion
                
                for (int i = 0; i < 23; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }
                
                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[1].StatID = (uint) Stats.SimFPS;
                sb[1].StatValue = simfps * factor;
				
                sb[2].StatID = (uint) Stats.PhysicsFPS;
                sb[2].StatValue = physfps * factor;

                sb[3].StatID = (uint) Stats.AgentUpdates;
                sb[3].StatValue = (m_agentUpdates * factor);

                sb[4].StatID = (uint) Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID = (uint) Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID = (uint) Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID = (uint) Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                sb[8].StatID = (uint)Stats.FrameMS;
                //                sb[8].StatValue = m_frameMS * factorByframe;
                float simFrameTime = 1000.0f / (simfps * factor);
                sb[8].StatValue = simFrameTime;

                sb[9].StatID = (uint)Stats.NetMS;
                sb[9].StatValue = m_netMS * factorByframe;

                sb[10].StatID = (uint)Stats.PhysicsMS;
                sb[10].StatValue = m_physicsMS * factorByframe;

                sb[11].StatID = (uint)Stats.ImageMS ;
                sb[11].StatValue = m_imageMS * factorByframe;

                sb[12].StatID = (uint)Stats.OtherMS;
                float othertmp = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS;
                if (othertmp < 0)
                    othertmp = 0;

                sb[12].StatValue = othertmp * factorByframe;

                sb[13].StatID = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (m_inPacketsPerSecond * factor);

                sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (m_outPacketsPerSecond * factor);

                sb[15].StatID = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID = (uint)Stats.AgentMS;
                sb[16].StatValue = m_agentMS * factorByframe;

                sb[17].StatID = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
                sb[20].StatValue = m_scriptLinesPerSecond * factor;

                float spare = m_scene.m_simframetime - m_frameMS * factorByframe;
                if (spare < 0)
                    spare = 0;
                sb[21].StatID = (uint)Stats.SimSpareTime;
                sb[21].StatValue = spare;

                sb[22].StatID = (uint)Stats.SimSleepTime;
                sb[22].StatValue = m_sleeptimeMS * factorByframe;

                for (int i = 0; i < 23; i++)
                {
                    lastReportedSimStats[i] = sb[i].StatValue;
                }
              
                SimStats simStats 
                    = new SimStats(
                        ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
                        rb, sb, m_scene.RegionInfo.originRegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }

                // Extra statistics that aren't currently sent to clients
                LastReportedObjectUpdates = m_objectUpdates / statsUpdateFactor;

                resetvalues();
            }
        }
Beispiel #18
0
        private void statsHeartBeat(object sender, EventArgs e)
        {
            SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[33];
            SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
            
            // Know what's not thread safe in Mono... modifying timers.
            // m_log.Debug("Firing Stats Heart Beat");
            lock (m_report)
            {
                uint regionFlags = 0;
                
                try
                {
                    if (estateModule == null)
                        estateModule = m_scene.RequestModuleInterface<IEstateModule>();
                    regionFlags = estateModule != null ? estateModule.GetRegionFlags() : (uint) 0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

#region various statistic googly moogly

                // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there
                // 0-50 is pretty close to 0-45
                float simfps = (int) ((m_fps * 5));
                // save the reported value so there is something available for llGetRegionFPS 
                lastReportedSimFPS = (float)simfps / statsUpdateFactor;

                //if (simfps > 45)
                //simfps = simfps - (simfps - 45);
                //if (simfps < 0)
                //simfps = 0;

                //
                float physfps = ((m_pfps / 1000));

                //if (physfps > 600)
                //physfps = physfps - (physfps - 600);

                if (physfps < 0)
                    physfps = 0;

#endregion
                
                //Our time dilation is 0.91 when we're running a full speed,
                // therefore to make sure we get an appropriate range,
                // we have to factor in our error.   (0.10f * statsUpdateFactor)
                // multiplies the fix for the error times the amount of times it'll occur a second
                // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
                // Then we divide the whole amount by the amount of seconds pass in between stats updates.

                // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
                // values to X-per-second values.

                for (int i = 0; i<33;i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }

                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[1].StatID = (uint) Stats.SimFPS;
                sb[1].StatValue = simfps/statsUpdateFactor;

                sb[2].StatID = (uint) Stats.PhysicsFPS;
                sb[2].StatValue = physfps / statsUpdateFactor;

                sb[3].StatID = (uint) Stats.AgentUpdates;
                sb[3].StatValue = (m_agentUpdates / statsUpdateFactor);

                sb[4].StatID = (uint) Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID = (uint) Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID = (uint) Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID = (uint) Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                sb[8].StatID = (uint)Stats.FrameMS;
                sb[8].StatValue = m_frameMS / statsUpdateFactor;

                sb[9].StatID = (uint)Stats.NetMS;
                sb[9].StatValue = m_netMS / statsUpdateFactor;

                sb[10].StatID = (uint)Stats.PhysicsMS;
                sb[10].StatValue = m_physicsMS / statsUpdateFactor;

                sb[11].StatID = (uint)Stats.ImageMS ;
                sb[11].StatValue = m_imageMS / statsUpdateFactor;

                sb[12].StatID = (uint)Stats.OtherMS;
                sb[12].StatValue = m_otherMS / statsUpdateFactor;

                sb[13].StatID = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor);

                sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);

                sb[15].StatID = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID = (uint)Stats.AgentMS;
                sb[16].StatValue = m_agentMS / statsUpdateFactor;

                sb[17].StatID = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID = (uint)Stats.ScriptEventsPerSecond;
                sb[20].StatValue = m_scriptEventsPerSecond / statsUpdateFactor;

                sb[21].StatID = (uint)Stats.SpareTime;
                sb[21].StatValue = 0;

                sb[22].StatID = (uint)Stats.SleepTime;
                sb[22].StatValue = m_sleepTime;

                sb[23].StatID = (uint)Stats.PumpIO;
                sb[23].StatValue = 0;

                long pws = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;

                if (pws > Int32.MaxValue)
                    pws = Int32.MaxValue;
                if (pws < 0)
                    pws = 0;

                sb[25].StatID = (uint)Stats.MemoryAllocated;
                sb[25].StatValue = pws / 4096000;

                sb[26].StatID = (uint)Stats.PhysicsOther;
                sb[26].StatValue = m_physicsOther;

                sb[27].StatID = (uint)Stats.UpdatePhysicsShapes; 
                sb[27].StatValue = 0;

                sb[28].StatID = (uint)Stats.PhysicsStep;
                sb[28].StatValue = m_physicsStep;

                sb[29].StatID = (uint)Stats.LowLodObjects;
                sb[29].StatValue = 0;

                sb[30].StatID = (uint)Stats.PinnedObjects;
                sb[30].StatValue = 0;

                sb[31].StatID = (uint)Stats.UnknownA;
                sb[31].StatValue = 0;

                sb[32].StatID = (uint)Stats.UnknownB;
                sb[32].StatValue = 0;

                sb[24].StatID = (uint)Stats.UnknownC;
                sb[24].StatValue = 0;

                
                
                for (int i = 0; i < 33; i++)
                {
                    lastReportedSimStats[i] = sb[i].StatValue;
                }
              
                SimStats simStats 
                    = new SimStats(
                        ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)objectCapacity, rb, sb, m_scene.RegionInfo.RegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }
                resetvalues();
            }
        }
Beispiel #19
0
 public SimStats(
     uint regionX, uint regionY, uint regionFlags, uint objectCapacity, 
     SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock, UUID pRUUID)
 {
     regionUUID = pRUUID;
     m_regionX = regionX;
     m_regionY = regionY;
     m_regionFlags = regionFlags;
     m_objectCapacity = objectCapacity;
     m_regionBlock = regionBlock;
     m_statsBlock = statsBlock;
 }
        private void statsHeartBeat(object sender, EventArgs e)
        {
            SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
            SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();

            // Know what's not thread safe in Mono... modifying timers.
            // m_log.Debug("Firing Stats Heart Beat");
            lock (m_report)
            {
                uint regionFlags = 0;

                try
                {
                    if (estateModule == null)
                    {
                        estateModule = m_scene.RequestModuleInterface <IEstateModule>();
                    }
                    regionFlags = estateModule != null?estateModule.GetRegionFlags() : (uint)0;
                }
                catch (Exception)
                {
                    // leave region flags at 0
                }

                #region various statistic googly moogly

                // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there
                // 0-50 is pretty close to 0-45
                float simfps = (int)((m_fps * 5));
                // save the reported value so there is something available for llGetRegionFPS
                lastReportedSimFPS = (float)simfps / statsUpdateFactor;

                //if (simfps > 45)
                //simfps = simfps - (simfps - 45);
                //if (simfps < 0)
                //simfps = 0;

                //
                float physfps = ((m_pfps / 1000));

                //if (physfps > 600)
                //physfps = physfps - (physfps - 600);

                if (physfps < 0)
                {
                    physfps = 0;
                }

                #endregion

                //Our time dilation is 0.91 when we're running a full speed,
                // therefore to make sure we get an appropriate range,
                // we have to factor in our error.   (0.10f * statsUpdateFactor)
                // multiplies the fix for the error times the amount of times it'll occur a second
                // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
                // Then we divide the whole amount by the amount of seconds pass in between stats updates.

                for (int i = 0; i < 21; i++)
                {
                    sb[i] = new SimStatsPacket.StatBlock();
                }

                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[1].StatID    = (uint)Stats.SimFPS;
                sb[1].StatValue = simfps / statsUpdateFactor;

                sb[2].StatID    = (uint)Stats.PhysicsFPS;
                sb[2].StatValue = physfps / statsUpdateFactor;

                sb[3].StatID    = (uint)Stats.AgentUpdates;
                sb[3].StatValue = (m_agentUpdates / statsUpdateFactor);

                sb[4].StatID    = (uint)Stats.Agents;
                sb[4].StatValue = m_rootAgents;

                sb[5].StatID    = (uint)Stats.ChildAgents;
                sb[5].StatValue = m_childAgents;

                sb[6].StatID    = (uint)Stats.TotalPrim;
                sb[6].StatValue = m_numPrim;

                sb[7].StatID    = (uint)Stats.ActivePrim;
                sb[7].StatValue = m_activePrim;

                sb[8].StatID    = (uint)Stats.FrameMS;
                sb[8].StatValue = m_frameMS / statsUpdateFactor;

                sb[9].StatID    = (uint)Stats.NetMS;
                sb[9].StatValue = m_netMS / statsUpdateFactor;

                sb[10].StatID    = (uint)Stats.PhysicsMS;
                sb[10].StatValue = m_physicsMS / statsUpdateFactor;

                sb[11].StatID    = (uint)Stats.ImageMS;
                sb[11].StatValue = m_imageMS / statsUpdateFactor;

                sb[12].StatID    = (uint)Stats.OtherMS;
                sb[12].StatValue = m_otherMS / statsUpdateFactor;

                sb[13].StatID    = (uint)Stats.InPacketsPerSecond;
                sb[13].StatValue = (m_inPacketsPerSecond);

                sb[14].StatID    = (uint)Stats.OutPacketsPerSecond;
                sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);

                sb[15].StatID    = (uint)Stats.UnAckedBytes;
                sb[15].StatValue = m_unAckedBytes;

                sb[16].StatID    = (uint)Stats.AgentMS;
                sb[16].StatValue = m_agentMS / statsUpdateFactor;

                sb[17].StatID    = (uint)Stats.PendingDownloads;
                sb[17].StatValue = m_pendingDownloads;

                sb[18].StatID    = (uint)Stats.PendingUploads;
                sb[18].StatValue = m_pendingUploads;

                sb[19].StatID    = (uint)Stats.ActiveScripts;
                sb[19].StatValue = m_activeScripts;

                sb[20].StatID    = (uint)Stats.ScriptLinesPerSecond;
                sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;

                SimStats simStats
                    = new SimStats(
                          ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)objectCapacity, rb, sb, m_scene.RegionInfo.originRegionID);

                handlerSendStatResult = OnSendStatsResult;
                if (handlerSendStatResult != null)
                {
                    handlerSendStatResult(simStats);
                }
                resetvalues();
            }
        }
Beispiel #21
0
            /// <summary>
            /// This is called by a timer and makes a SimStats class of the current stats that we have in this simulator.
            ///  It then sends the packet to the client and triggers the events to tell followers about the updated stats
            ///   and updates the LastSet* values for monitors.
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void statsHeartBeat(object sender, EventArgs e)
            {
                SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();

                // Know what's not thread safe in Mono... modifying timers.
                lock (m_report)
                {
                    uint regionFlags = 0;

                    try
                    {
                        if (m_estateModule == null)
                        {
                            m_estateModule = m_currentScene.RequestModuleInterface <IEstateModule>();
                        }
                        regionFlags = m_estateModule != null?m_estateModule.GetRegionFlags() : (uint)0;
                    }
                    catch (Exception)
                    {
                        // leave region flags at 0
                    }

                    rb.ObjectCapacity = (uint)m_currentScene.RegionInfo.ObjectCapacity;
                    rb.RegionFlags    = regionFlags;
                    rb.RegionX        = (uint)m_currentScene.RegionInfo.RegionLocX / Constants.RegionSize;
                    rb.RegionY        = (uint)m_currentScene.RegionInfo.RegionLocY / Constants.RegionSize;

                    ISimFrameMonitor       simFrameMonitor         = (ISimFrameMonitor)GetMonitor("SimFrameStats");
                    ITimeDilationMonitor   timeDilationMonitor     = (ITimeDilationMonitor)GetMonitor("Time Dilation");
                    ITotalFrameTimeMonitor totalFrameMonitor       = (ITotalFrameTimeMonitor)GetMonitor("Total Frame Time");
                    ITimeMonitor           sleepFrameMonitor       = (ITimeMonitor)GetMonitor("Sleep Frame Time");
                    ITimeMonitor           otherFrameMonitor       = (ITimeMonitor)GetMonitor("Other Frame Time");
                    IPhysicsFrameMonitor   physicsFrameMonitor     = (IPhysicsFrameMonitor)GetMonitor("Total Physics Frame Time");
                    ITimeMonitor           physicsSyncFrameMonitor = (ITimeMonitor)GetMonitor("Physics Sync Frame Time");
                    ITimeMonitor           physicsTimeFrameMonitor = (ITimeMonitor)GetMonitor("Physics Update Frame Time");
                    IAgentUpdateMonitor    agentUpdateFrameMonitor = (IAgentUpdateMonitor)GetMonitor("Agent Update Count");
                    INetworkMonitor        networkMonitor          = (INetworkMonitor)GetMonitor("Network Monitor");
                    IMonitor            imagesMonitor      = GetMonitor("Images Frame Time");
                    ITimeMonitor        scriptMonitor      = (ITimeMonitor)GetMonitor("Script Frame Time");
                    IScriptCountMonitor totalScriptMonitor = (IScriptCountMonitor)GetMonitor("Total Script Count");

                    #region various statistic googly moogly

                    float simfps = simFrameMonitor.SimFPS / statsUpdateFactor;
                    // save the reported value so there is something available for llGetRegionFPS
                    simFrameMonitor.LastReportedSimFPS = simfps;

                    float physfps = (float)physicsFrameMonitor.PhysicsFPS / statsUpdateFactor;
                    physicsFrameMonitor.LastReportedPhysicsFPS = physfps;
                    //Update the time dilation with the newest physicsFPS
                    timeDilationMonitor.SetPhysicsFPS(physfps);

                    #endregion

                    #region Add the stats packets

                    //Some info on this packet http://wiki.secondlife.com/wiki/Statistics_Bar_Guide

                    sb[0].StatID    = (uint)Stats.TimeDilation;
                    sb[0].StatValue = (float)timeDilationMonitor.GetValue();

                    sb[1].StatID    = (uint)Stats.FPS;
                    sb[1].StatValue = simfps;

                    float realsimfps = simfps * 2;

                    sb[2].StatID    = (uint)Stats.PhysFPS;
                    sb[2].StatValue = physfps;

                    sb[3].StatID    = (uint)Stats.AgentUpdates;
                    sb[3].StatValue = (agentUpdateFrameMonitor.AgentUpdates / realsimfps);

                    sb[4].StatID = (uint)Stats.FrameMS;
                    float TotalFrames = (float)(totalFrameMonitor.GetValue() / realsimfps);
                    sb[4].StatValue = TotalFrames;

                    sb[5].StatID    = (uint)Stats.NetMS;
                    sb[5].StatValue = 0;//TODO: Implement this

                    sb[6].StatID    = (uint)Stats.SimOtherMS;
                    sb[6].StatValue = (float)(otherFrameMonitor.GetValue() / realsimfps);

                    sb[7].StatID = (uint)Stats.SimPhysicsMS;
                    float PhysicsMS = (float)(physicsTimeFrameMonitor.GetValue() / realsimfps);
                    sb[7].StatValue = PhysicsMS;

                    sb[8].StatID    = (uint)Stats.AgentMS;
                    sb[8].StatValue = (agentUpdateFrameMonitor.AgentFrameTime / realsimfps);

                    sb[9].StatID    = (uint)Stats.ImagesMS;
                    sb[9].StatValue = (float)(imagesMonitor.GetValue() / realsimfps);

                    sb[10].StatID = (uint)Stats.ScriptMS;
                    float ScriptMS = (float)(scriptMonitor.GetValue() / realsimfps);
                    sb[10].StatValue = ScriptMS;

                    sb[11].StatID = (uint)Stats.TotalObjects;
                    sb[12].StatID = (uint)Stats.ActiveObjects;
                    sb[13].StatID = (uint)Stats.NumAgentMain;
                    sb[14].StatID = (uint)Stats.NumAgentChild;

                    IEntityCountModule entityCountModule = m_currentScene.RequestModuleInterface <IEntityCountModule>();
                    if (entityCountModule != null)
                    {
                        sb[11].StatValue = entityCountModule.Objects;

                        sb[12].StatValue = entityCountModule.ActiveObjects;

                        sb[13].StatValue = entityCountModule.RootAgents;

                        sb[14].StatValue = entityCountModule.ChildAgents;
                    }

                    sb[15].StatID    = (uint)Stats.NumScriptActive;
                    sb[15].StatValue = totalScriptMonitor.ActiveScripts;

                    sb[16].StatID    = (uint)Stats.LSLIPS;
                    sb[16].StatValue = 0; //This isn't used anymore, and has been superseeded by LSLEPS

                    sb[17].StatID    = (uint)Stats.InPPS;
                    sb[17].StatValue = (float)(networkMonitor.InPacketsPerSecond / statsUpdateFactor);

                    sb[18].StatID    = (uint)Stats.OutPPS;
                    sb[18].StatValue = (float)(networkMonitor.OutPacketsPerSecond / statsUpdateFactor);

                    sb[19].StatID    = (uint)Stats.PendingDownloads;
                    sb[19].StatValue = (float)(networkMonitor.PendingDownloads);

                    sb[20].StatID    = (uint)Stats.PendingUploads;
                    sb[20].StatValue = (float)(networkMonitor.PendingUploads);

                    //21 and 22 are forced to the GC memory as they WILL make memory usage go up rapidly otherwise!
                    sb[21].StatID    = (uint)Stats.VirtualSizeKB;
                    sb[21].StatValue = GC.GetTotalMemory(false) / 1024;// System.Diagnostics.Process.GetCurrentProcess().WorkingSet64 / (1024);

                    sb[22].StatID    = (uint)Stats.ResidentSizeKB;
                    sb[22].StatValue = GC.GetTotalMemory(false) / 1024;//(float)System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64 / (1024);

                    sb[23].StatID    = (uint)Stats.PendingLocalUploads;
                    sb[23].StatValue = (float)(networkMonitor.PendingUploads / statsUpdateFactor);

                    sb[24].StatID    = (uint)Stats.TotalUnackedBytes;
                    sb[24].StatValue = (float)(networkMonitor.UnackedBytes);

                    sb[25].StatID    = (uint)Stats.PhysicsPinnedTasks;
                    sb[25].StatValue = 0;

                    sb[26].StatID    = (uint)Stats.PhysicsLODTasks;
                    sb[26].StatValue = 0;

                    sb[27].StatID    = (uint)Stats.SimPhysicsStepMS;
                    sb[27].StatValue = m_currentScene.PhysicsScene.StepTime;

                    sb[28].StatID    = (uint)Stats.SimPhysicsShape;
                    sb[28].StatValue = 0;

                    sb[29].StatID    = (uint)Stats.SimPhysicsOtherMS;
                    sb[29].StatValue = (float)(physicsSyncFrameMonitor.GetValue() / realsimfps);

                    sb[30].StatID    = (uint)Stats.SimPhysicsMemory;
                    sb[30].StatValue = 0;

                    sb[31].StatID    = (uint)Stats.ScriptEPS;
                    sb[31].StatValue = totalScriptMonitor.ScriptEPS / statsUpdateFactor;

                    sb[32].StatID = (uint)Stats.SimSpareTime;
                    //Spare time is the total time minus the stats that are in the same category in the client
                    // It is the sleep time, physics step, update physics shape, physics other, and pumpI0.
                    // Note: take out agent Update and script time for now, as they are not a part of the heartbeat right now and will mess this calc up
                    float SpareTime = (float)(TotalFrames - (/*NetMS + */ PhysicsMS +
                                                             otherFrameMonitor.GetValue() + /*(agentUpdateFrameMonitor.AgentFrameTime / statsUpdateFactor) +*/
                                                             (imagesMonitor.GetValue() / statsUpdateFactor) /* + ScriptMS*/));

                    sb[32].StatValue = SpareTime;

                    sb[33].StatID    = (uint)Stats.SimSleepTime;
                    sb[33].StatValue = (float)(sleepFrameMonitor.GetValue() / realsimfps);

                    //Info about this stat: http://blogs.secondlife.com/message/66098
                    sb[34].StatID    = (uint)Stats.IOPumpTime;
                    sb[34].StatValue = 0;//TODO: implement this

                    #endregion

                    for (int i = 0; i < sb.Length; i++)
                    {
                        if (float.IsInfinity(sb[i].StatValue) ||
                            float.IsNaN(sb[i].StatValue))
                        {
                            sb[i].StatValue = 0;
                        }
                        lastReportedSimStats[i] = sb[i].StatValue;
                    }

                    SimStats simStats
                        = new SimStats(rb, sb, m_currentScene.RegionInfo.RegionID);

                    //Fire the event and tell followers about the new stats
                    m_module.SendStatsResults(simStats);

                    //Tell all the scene presences about the new stats
                    foreach (IScenePresence agent in m_currentScene.GetScenePresences())
                    {
                        if (!agent.IsChildAgent)
                        {
                            agent.ControllingClient.SendSimStats(simStats);
                        }
                    }
                    //Now fix any values that require reseting
                    ResetValues();
                }
            }