From ace32193b477b73eb23b1912e513b8a54ab023a5 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 13 Apr 2018 16:20:29 -0700 Subject: [PATCH 1/3] more correct stat names --- interface/src/Application.cpp | 16 ++++++++-------- interface/src/ui/Stats.cpp | 13 ++++++++++--- libraries/physics/src/PhysicsEngine.cpp | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6ffb7f6dee..f9795e1233 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5256,12 +5256,12 @@ void Application::update(float deltaTime) { QSharedPointer avatarManager = DependencyManager::get(); { - PROFILE_RANGE(simulation_physics, "Physics"); - PerformanceTimer perfTimer("physics"); + PROFILE_RANGE(simulation_physics, "Simulation"); + PerformanceTimer perfTimer("simulation"); if (_physicsEnabled) { { - PROFILE_RANGE(simulation_physics, "PreStep"); - PerformanceTimer perfTimer("preStep)"); + PROFILE_RANGE(simulation_physics, "PrePhysics"); + PerformanceTimer perfTimer("prePhysics)"); { const VectorOfMotionStates& motionStates = _entitySimulation->getObjectsToRemoveFromPhysics(); _physicsEngine->removeObjects(motionStates); @@ -5295,15 +5295,15 @@ void Application::update(float deltaTime) { }); } { - PROFILE_RANGE(simulation_physics, "Step"); - PerformanceTimer perfTimer("step"); + PROFILE_RANGE(simulation_physics, "StepPhysics"); + PerformanceTimer perfTimer("stepPhysics"); getEntities()->getTree()->withWriteLock([&] { _physicsEngine->stepSimulation(); }); } { - PROFILE_RANGE(simulation_physics, "PostStep"); - PerformanceTimer perfTimer("postStep"); + PROFILE_RANGE(simulation_physics, "PostPhysics"); + PerformanceTimer perfTimer("postPhysics"); if (_physicsEngine->hasOutgoingChanges()) { // grab the collision events BEFORE handleOutgoingChanges() because at this point // we have a better idea of which objects we own or should own. diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index 64ee492716..ad7585597b 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -60,7 +60,7 @@ Stats::Stats(QQuickItem* parent) : QQuickItem(parent) { bool Stats::includeTimingRecord(const QString& name) { if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails)) { if (name.startsWith("/idle/update/")) { - if (name.startsWith("/idle/update/physics/")) { + if (name.startsWith("/idle/update/simulation/")) { return Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsSimulationTiming); } else if (name.startsWith("/idle/update/myAvatar/")) { if (name.startsWith("/idle/update/myAvatar/simulate/")) { @@ -75,7 +75,7 @@ bool Stats::includeTimingRecord(const QString& name) { return Menu::getInstance()->isOptionChecked(MenuOption::ExpandPaintGLTiming); } else if (name.startsWith("/paintGL/")) { return Menu::getInstance()->isOptionChecked(MenuOption::ExpandPaintGLTiming); - } else if (name.startsWith("step/")) { + } else if (name.startsWith("physics/")) { return Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsSimulationTiming); } return true; @@ -479,7 +479,14 @@ void Stats::updateStats(bool force) { float dt = (float)itr.value().getMovingAverage() / (float)USECS_PER_MSEC; _gameUpdateStats = QString("/idle/update = %1 ms").arg(dt); - QVector categories = { "devices", "physics", "otherAvatars", "MyAvatar", "misc" }; + QVector categories = { + "devices", + "MyAvatar", + "otherAvatars", + "pickManager", + "pointerManager", + "simulation" + }; for (int32_t j = 0; j < categories.size(); ++j) { QString recordKey = "/idle/update/" + categories[j]; itr = allRecords.find(recordKey); diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 1d4c385f07..7c2ad55405 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -413,7 +413,7 @@ void PhysicsEngine::harvestPerformanceStats() { if (QString(itr->Get_Current_Name()) == "stepSimulation") { itr->Enter_Child(childIndex); StatsHarvester harvester; - harvester.recurse(itr, "step/"); + harvester.recurse(itr, "physics/"); break; } itr->Next(); From 4d3109b84938507a55fd79c407a83a844058359c Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 13 Apr 2018 16:20:40 -0700 Subject: [PATCH 2/3] cleanup some comments --- libraries/physics/src/EntityMotionState.h | 2 +- libraries/physics/src/PhysicalEntitySimulation.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/physics/src/EntityMotionState.h b/libraries/physics/src/EntityMotionState.h index 807acbfe80..a542c61d43 100644 --- a/libraries/physics/src/EntityMotionState.h +++ b/libraries/physics/src/EntityMotionState.h @@ -132,7 +132,7 @@ protected: // // (2) For locally owned simulation: we store the last values sent to the server, integrated forward over time // according to how we think the server doing it. We calculate the error between the true local transform - // and the remote to decide when to send another update. + // and the remote to decide whether to send another update or not. // glm::vec3 _serverPosition; // in simulation-frame (not world-frame) glm::quat _serverRotation; diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index 06e7069f72..ab7c2ec252 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -41,7 +41,7 @@ void PhysicalEntitySimulation::init( // begin EntitySimulation overrides void PhysicalEntitySimulation::updateEntitiesInternal(uint64_t now) { - // Do nothing here because the "internal" update the PhysicsEngine::stepSimualtion() which is done elsewhere. + // Do nothing here because the "internal" update the PhysicsEngine::stepSimulation() which is done elsewhere. } void PhysicalEntitySimulation::addEntityInternal(EntityItemPointer entity) { From a80cf49eb3ed1d4b6c0661851d2ea497ef296aea Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 13 Apr 2018 17:01:38 -0700 Subject: [PATCH 3/3] split 'ETRupdate' out of 'postPhysics' stat context --- interface/src/Application.cpp | 76 ++++++++++++++++++----------------- interface/src/Menu.cpp | 3 +- interface/src/Menu.h | 3 +- interface/src/ui/Stats.cpp | 4 +- 4 files changed, 46 insertions(+), 40 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f9795e1233..9099969bd5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5302,52 +5302,56 @@ void Application::update(float deltaTime) { }); } { - PROFILE_RANGE(simulation_physics, "PostPhysics"); - PerformanceTimer perfTimer("postPhysics"); if (_physicsEngine->hasOutgoingChanges()) { - // grab the collision events BEFORE handleOutgoingChanges() because at this point - // we have a better idea of which objects we own or should own. - auto& collisionEvents = _physicsEngine->getCollisionEvents(); + { + PROFILE_RANGE(simulation_physics, "PostPhysics"); + PerformanceTimer perfTimer("postPhysics"); + // grab the collision events BEFORE handleChangedMotionStates() because at this point + // we have a better idea of which objects we own or should own. + auto& collisionEvents = _physicsEngine->getCollisionEvents(); - getEntities()->getTree()->withWriteLock([&] { - PROFILE_RANGE(simulation_physics, "HandleChanges"); - PerformanceTimer perfTimer("handleChanges"); + getEntities()->getTree()->withWriteLock([&] { + PROFILE_RANGE(simulation_physics, "HandleChanges"); + PerformanceTimer perfTimer("handleChanges"); - const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates(); - _entitySimulation->handleChangedMotionStates(outgoingChanges); - avatarManager->handleChangedMotionStates(outgoingChanges); + const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates(); + _entitySimulation->handleChangedMotionStates(outgoingChanges); + avatarManager->handleChangedMotionStates(outgoingChanges); - const VectorOfMotionStates& deactivations = _physicsEngine->getDeactivatedMotionStates(); - _entitySimulation->handleDeactivatedMotionStates(deactivations); - }); + const VectorOfMotionStates& deactivations = _physicsEngine->getDeactivatedMotionStates(); + _entitySimulation->handleDeactivatedMotionStates(deactivations); + }); - if (!_aboutToQuit) { - // handleCollisionEvents() AFTER handleOutgoingChanges() - { - PROFILE_RANGE(simulation_physics, "CollisionEvents"); - avatarManager->handleCollisionEvents(collisionEvents); - // Collision events (and their scripts) must not be handled when we're locked, above. (That would risk - // deadlock.) - _entitySimulation->handleCollisionEvents(collisionEvents); + if (!_aboutToQuit) { + // handleCollisionEvents() AFTER handleChangedMotionStates() + { + PROFILE_RANGE(simulation_physics, "CollisionEvents"); + avatarManager->handleCollisionEvents(collisionEvents); + // Collision events (and their scripts) must not be handled when we're locked, above. (That would risk + // deadlock.) + _entitySimulation->handleCollisionEvents(collisionEvents); + } } + { + PROFILE_RANGE(simulation_physics, "MyAvatar"); + myAvatar->harvestResultsFromPhysicsSimulation(deltaTime); + } + + if (PerformanceTimer::isActive() && + Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails) && + Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsTiming)) { + _physicsEngine->harvestPerformanceStats(); + } + // NOTE: the PhysicsEngine stats are written to stdout NOT to Qt log framework + _physicsEngine->dumpStatsIfNecessary(); + } + + if (!_aboutToQuit) { // NOTE: the getEntities()->update() call below will wait for lock - // and will simulate entity motion (the EntityTree has been given an EntitySimulation). + // and will provide non-physical entity motion getEntities()->update(true); // update the models... } - - { - PROFILE_RANGE(simulation_physics, "MyAvatar"); - myAvatar->harvestResultsFromPhysicsSimulation(deltaTime); - } - - if (PerformanceTimer::isActive() && - Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails) && - Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsSimulationTiming)) { - _physicsEngine->harvestPerformanceStats(); - } - // NOTE: the PhysicsEngine stats are written to stdout NOT to Qt log framework - _physicsEngine->dumpStatsIfNecessary(); } } } else { diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index df7546cd33..83199f5ba7 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -683,11 +683,12 @@ Menu::Menu() { qApp, SLOT(enablePerfStats(bool))); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::OnlyDisplayTopTen, 0, true); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandUpdateTiming, 0, false); + addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandSimulationTiming, 0, false); + addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandPhysicsTiming, 0, false); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandMyAvatarTiming, 0, false); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandMyAvatarSimulateTiming, 0, false); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandOtherAvatarTiming, 0, false); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandPaintGLTiming, 0, false); - addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandPhysicsSimulationTiming, 0, false); addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::FrameTimer); addActionToQMenuAndActionHash(timingMenu, MenuOption::RunTimingTests, 0, qApp, SLOT(runTests())); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 4d418a16d2..bba70a6a89 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -105,7 +105,8 @@ namespace MenuOption { const QString ExpandMyAvatarTiming = "Expand /myAvatar"; const QString ExpandOtherAvatarTiming = "Expand /otherAvatar"; const QString ExpandPaintGLTiming = "Expand /paintGL"; - const QString ExpandPhysicsSimulationTiming = "Expand /physics"; + const QString ExpandSimulationTiming = "Expand /simulation"; + const QString ExpandPhysicsTiming = "Expand /physics"; const QString ExpandUpdateTiming = "Expand /update"; const QString FirstPerson = "First Person"; const QString FirstPersonHMD = "Enter First Person Mode in HMD"; diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index ad7585597b..d54faf8b28 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -61,7 +61,7 @@ bool Stats::includeTimingRecord(const QString& name) { if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails)) { if (name.startsWith("/idle/update/")) { if (name.startsWith("/idle/update/simulation/")) { - return Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsSimulationTiming); + return Menu::getInstance()->isOptionChecked(MenuOption::ExpandSimulationTiming); } else if (name.startsWith("/idle/update/myAvatar/")) { if (name.startsWith("/idle/update/myAvatar/simulate/")) { return Menu::getInstance()->isOptionChecked(MenuOption::ExpandMyAvatarSimulateTiming); @@ -76,7 +76,7 @@ bool Stats::includeTimingRecord(const QString& name) { } else if (name.startsWith("/paintGL/")) { return Menu::getInstance()->isOptionChecked(MenuOption::ExpandPaintGLTiming); } else if (name.startsWith("physics/")) { - return Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsSimulationTiming); + return Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsTiming); } return true; }