cleanup WANT_DETAILED_PROFILING

This commit is contained in:
Andrew Meadows 2017-10-19 14:31:50 -07:00
parent 339edc67c8
commit c79bf3bc04
7 changed files with 42 additions and 74 deletions

View file

@ -25,7 +25,7 @@ The above dependencies will be downloaded, built, linked and included automatica
These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared. Should you want to force a re-download and re-compile of a specific external, you can simply remove that directory from the appropriate subfolder in `build/ext`. Should you want to force a re-download and re-compile of all externals, just remove the `build/ext` folder. These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared. Should you want to force a re-download and re-compile of a specific external, you can simply remove that directory from the appropriate subfolder in `build/ext`. Should you want to force a re-download and re-compile of all externals, just remove the `build/ext` folder.
If you would like to use a specific install of a dependency instead of the version that would be grabbed as a CMake ExternalProject, you can pass -DUSE_LOCAL_$NAME=0 (where $NAME is the name of the subfolder in [cmake/externals](cmake/externals)) when you run CMake to tell it not to get that dependency as an external project. If you would like to use a specific install of a dependency instead of the version that would be grabbed as a CMake ExternalProject, you can pass -DUSE\_LOCAL\_$NAME=0 (where $NAME is the name of the subfolder in [cmake/externals](cmake/externals)) when you run CMake to tell it not to get that dependency as an external project.
### OS Specific Build Guides ### OS Specific Build Guides

View file

@ -32,8 +32,6 @@
#include "AnimUtil.h" #include "AnimUtil.h"
#include "IKTarget.h" #include "IKTarget.h"
// uncomment WANT_DETAILED_PROFILING for profiling that would otherwise impact performance
//#define WANT_DETAILED_PROFILING
static int nextRigId = 1; static int nextRigId = 1;
static std::map<int, Rig*> rigRegistry; static std::map<int, Rig*> rigRegistry;
@ -1002,17 +1000,13 @@ void Rig::updateAnimationStateHandlers() { // called on avatar update thread (wh
} }
void Rig::updateAnimations(float deltaTime, const glm::mat4& rootTransform, const glm::mat4& rigToWorldTransform) { void Rig::updateAnimations(float deltaTime, const glm::mat4& rootTransform, const glm::mat4& rigToWorldTransform) {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE_EX(simulation_animation_detail, __FUNCTION__, 0xffff00ff, 0);
PROFILE_RANGE_EX(simulation_animation_detail, __FUNCTION__, 0xffff00ff, 0); DETAILED_PERFORMANCE_TIMER("updateAnimations");
PerformanceTimer perfTimer("updateAnimations");
#endif
setModelOffset(rootTransform); setModelOffset(rootTransform);
if (_animNode && _enabledAnimations) { if (_animNode && _enabledAnimations) {
#ifdef WANT_DETAILED_PROFILING DETAILED_PERFORMANCE_TIMER("handleTriggers");
PerformanceTimer perfTimer("handleTriggers");
#endif
updateAnimationStateHandlers(); updateAnimationStateHandlers();
_animVars.setRigToGeometryTransform(_rigToGeometryTransform); _animVars.setRigToGeometryTransform(_rigToGeometryTransform);
@ -1664,9 +1658,7 @@ bool Rig::getModelRegistrationPoint(glm::vec3& modelRegistrationPointOut) const
} }
void Rig::applyOverridePoses() { void Rig::applyOverridePoses() {
#ifdef WANT_DETAILED_PROFILING DETAILED_PERFORMANCE_TIMER("override");
PerformanceTimer perfTimer("override");
#endif
if (_numOverrides == 0 || !_animSkeleton) { if (_numOverrides == 0 || !_animSkeleton) {
return; return;
} }
@ -1683,9 +1675,7 @@ void Rig::applyOverridePoses() {
} }
void Rig::buildAbsoluteRigPoses(const AnimPoseVec& relativePoses, AnimPoseVec& absolutePosesOut) { void Rig::buildAbsoluteRigPoses(const AnimPoseVec& relativePoses, AnimPoseVec& absolutePosesOut) {
#ifdef WANT_DETAILED_PROFILING DETAILED_PERFORMANCE_TIMER("buildAbsolute");
PerformanceTimer perfTimer("buildAbsolute");
#endif
if (!_animSkeleton) { if (!_animSkeleton) {
return; return;
} }
@ -1740,10 +1730,9 @@ void Rig::copyJointsIntoJointData(QVector<JointData>& jointDataVec) const {
} }
void Rig::copyJointsFromJointData(const QVector<JointData>& jointDataVec) { void Rig::copyJointsFromJointData(const QVector<JointData>& jointDataVec) {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(simulation_animation_detail, "copyJoints");
PROFILE_RANGE(simulation_animation_detail, "copyJoints"); DETAILED_PERFORMANCE_TIMER("copyJoints");
PerformanceTimer perfTimer("copyJoints");
#endif
if (!_animSkeleton) { if (!_animSkeleton) {
return; return;
} }

View file

@ -26,8 +26,6 @@
#include "RenderableWebEntityItem.h" #include "RenderableWebEntityItem.h"
#include "RenderableZoneEntityItem.h" #include "RenderableZoneEntityItem.h"
// uncomment WANT_DETAILED_PROFILING to see some of the interesting profiling contexts
//#define WANT_DETAILED_PROFILING
using namespace render; using namespace render;
using namespace render::entities; using namespace render::entities;
@ -274,9 +272,7 @@ void EntityRenderer::removeFromScene(const ScenePointer& scene, Transaction& tra
} }
void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& transaction) { void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& transaction) {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__);
PROFILE_RANGE(simulation_physics, __FUNCTION__);
#endif
if (!isValidRenderItem()) { if (!isValidRenderItem()) {
return; return;
} }
@ -336,9 +332,7 @@ bool EntityRenderer::needsRenderUpdateFromEntity(const EntityItemPointer& entity
} }
void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) { void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__);
PROFILE_RANGE(simulation_physics, __FUNCTION__);
#endif
withWriteLock([&] { withWriteLock([&] {
auto transparent = isTransparent(); auto transparent = isTransparent();
if (_prevIsTransparent && !transparent) { if (_prevIsTransparent && !transparent) {

View file

@ -34,8 +34,6 @@
#include "EntityTreeRenderer.h" #include "EntityTreeRenderer.h"
#include "EntitiesRendererLogging.h" #include "EntitiesRendererLogging.h"
// uncomment WANT_DETAILED_PROFILING to profile the interesting contexts
//#define WANT_DETAILED_PROFILING
static CollisionRenderMeshCache collisionMeshCache; static CollisionRenderMeshCache collisionMeshCache;
@ -110,9 +108,7 @@ QVariantMap parseTexturesToMap(QString textures, const QVariantMap& defaultTextu
} }
void RenderableModelEntityItem::doInitialModelSimulation() { void RenderableModelEntityItem::doInitialModelSimulation() {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__);
PROFILE_RANGE(simulation_physics, __FUNCTION__);
#endif
ModelPointer model = getModel(); ModelPointer model = getModel();
if (!model) { if (!model) {
return; return;
@ -144,9 +140,7 @@ void RenderableModelEntityItem::autoResizeJointArrays() {
} }
bool RenderableModelEntityItem::needsUpdateModelBounds() const { bool RenderableModelEntityItem::needsUpdateModelBounds() const {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__);
PROFILE_RANGE(simulation_physics, __FUNCTION__);
#endif
ModelPointer model = getModel(); ModelPointer model = getModel();
if (!hasModel() || !model) { if (!hasModel() || !model) {
return false; return false;
@ -191,9 +185,7 @@ bool RenderableModelEntityItem::needsUpdateModelBounds() const {
} }
void RenderableModelEntityItem::updateModelBounds() { void RenderableModelEntityItem::updateModelBounds() {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(simulation_physics, "updateModelBounds");
PROFILE_RANGE(simulation_physics, "updateModelBounds");
#endif
if (!_dimensionsInitialized || !hasModel()) { if (!_dimensionsInitialized || !hasModel()) {
return; return;
@ -352,9 +344,7 @@ bool RenderableModelEntityItem::isReadyToComputeShape() const {
// we have both URLs AND both geometries AND they are both fully loaded. // we have both URLs AND both geometries AND they are both fully loaded.
if (_needsInitialSimulation) { if (_needsInitialSimulation) {
// the _model's offset will be wrong until _needsInitialSimulation is false // the _model's offset will be wrong until _needsInitialSimulation is false
#ifdef WANT_DETAILED_PROFILING DETAILED_PERFORMANCE_TIMER("_model->simulate");
PerformanceTimer perfTimer("_model->simulate");
#endif
const_cast<RenderableModelEntityItem*>(this)->doInitialModelSimulation(); const_cast<RenderableModelEntityItem*>(this)->doInitialModelSimulation();
} }
return true; return true;
@ -900,9 +890,7 @@ void RenderableModelEntityItem::setJointTranslationsSet(const QVector<bool>& tra
} }
void RenderableModelEntityItem::locationChanged(bool tellPhysics) { void RenderableModelEntityItem::locationChanged(bool tellPhysics) {
#ifdef WANT_DETAILED_PROFILING DETAILED_PERFORMANCE_TIMER("locationChanged");
PerformanceTimer pertTimer("locationChanged");
#endif
EntityItem::locationChanged(tellPhysics); EntityItem::locationChanged(tellPhysics);
auto model = getModel(); auto model = getModel();
if (model && model->isLoaded()) { if (model && model->isLoaded()) {
@ -1182,9 +1170,7 @@ bool ModelEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoin
} }
void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__);
PROFILE_RANGE(simulation_physics, __FUNCTION__);
#endif
if (_hasModel != entity->hasModel()) { if (_hasModel != entity->hasModel()) {
_hasModel = entity->hasModel(); _hasModel = entity->hasModel();
} }
@ -1274,9 +1260,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
// TODO? early exit here when not visible? // TODO? early exit here when not visible?
{ {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(simulation_physics, "Fixup");
PROFILE_RANGE(simulation_physics, "Fixup");
#endif
if (model->needsFixupInScene()) { if (model->needsFixupInScene()) {
model->removeFromScene(scene, transaction); model->removeFromScene(scene, transaction);
render::Item::Status::Getters statusGetters; render::Item::Status::Getters statusGetters;
@ -1292,9 +1276,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
} }
{ {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(simulation_physics, "CheckAnimation");
PROFILE_RANGE(simulation_physics, "CheckAnimation");
#endif
// make a copy of the animation properites // make a copy of the animation properites
auto newAnimationProperties = entity->getAnimationProperties(); auto newAnimationProperties = entity->getAnimationProperties();
if (newAnimationProperties != _renderAnimationProperties) { if (newAnimationProperties != _renderAnimationProperties) {
@ -1306,9 +1288,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
} }
if (_animating) { if (_animating) {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(simulation_physics, "Animate");
PROFILE_RANGE(simulation_physics, "Animate");
#endif
if (!jointsMapped()) { if (!jointsMapped()) {
mapJoints(entity, model->getJointNames()); mapJoints(entity, model->getJointNames());
} }
@ -1319,10 +1299,8 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
// NOTE: this only renders the "meta" portion of the Model, namely it renders debugging items // NOTE: this only renders the "meta" portion of the Model, namely it renders debugging items
void ModelEntityRenderer::doRender(RenderArgs* args) { void ModelEntityRenderer::doRender(RenderArgs* args) {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(render_detail, "MetaModelRender");
PROFILE_RANGE(render_detail, "MetaModelRender"); DETAILED_PERFORMANCE_TIMER("RMEIrender");
PerformanceTimer perfTimer("RMEIrender");
#endif
ModelPointer model; ModelPointer model;
withReadLock([&]{ withReadLock([&]{

View file

@ -32,9 +32,6 @@
#include "RenderUtilsLogging.h" #include "RenderUtilsLogging.h"
#include <Trace.h> #include <Trace.h>
// uncomment WANT_DETAILED_PROFILING to enable profiling that causes measureable performance impact
//#define WANT_DETAILED_PROFILING
using namespace std; using namespace std;
int nakedModelPointerTypeId = qRegisterMetaType<ModelPointer>(); int nakedModelPointerTypeId = qRegisterMetaType<ModelPointer>();
@ -966,9 +963,7 @@ Blender::Blender(ModelPointer model, int blendNumber, const Geometry::WeakPointe
} }
void Blender::run() { void Blender::run() {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } });
PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } });
#endif
QVector<glm::vec3> vertices, normals; QVector<glm::vec3> vertices, normals;
if (_model) { if (_model) {
int offset = 0; int offset = 0;
@ -1089,10 +1084,7 @@ void Model::snapToRegistrationPoint() {
} }
void Model::simulate(float deltaTime, bool fullUpdate) { void Model::simulate(float deltaTime, bool fullUpdate) {
#ifdef WANT_DETAILED_PROFILING DETAILED_PROFILE_RANGE(simulation_detail, __FUNCTION__);
PROFILE_RANGE(simulation_detail, __FUNCTION__);
PerformanceTimer perfTimer("Model::simulate");
#endif
fullUpdate = updateGeometry() || fullUpdate || (_scaleToFit && !_scaledToFit) fullUpdate = updateGeometry() || fullUpdate || (_scaleToFit && !_scaledToFit)
|| (_snapModelToRegistrationPoint && !_snappedToRegistrationPoint); || (_snapModelToRegistrationPoint && !_snappedToRegistrationPoint);
@ -1130,9 +1122,7 @@ void Model::computeMeshPartLocalBounds() {
// virtual // virtual
void Model::updateClusterMatrices() { void Model::updateClusterMatrices() {
#ifdef WANT_DETAILED_PROFILING DETAILED_PERFORMANCE_TIMER("Model::updateClusterMatrices");
PerformanceTimer perfTimer("Model::updateClusterMatrices");
#endif
if (!_needsUpdateClusterMatrices || !isLoaded()) { if (!_needsUpdateClusterMatrices || !isLoaded()) {
return; return;

View file

@ -97,5 +97,12 @@ private:
static QMap<QString, PerformanceTimerRecord> _records; static QMap<QString, PerformanceTimerRecord> _records;
}; };
// uncomment WANT_DETAILED_PERFORMANCE_TIMERS definition to enable performance timers in high-frequency contexts
//#define WANT_DETAILED_PERFORMANCE_TIMERS
#ifdef WANT_DETAILED_PERFORMANCE_TIMERS
#define DETAILED_PERFORMANCE_TIMER(name) PerformanceTimer detailedPerformanceTimer(name);
#else // WANT_DETAILED_PERFORMANCE_TIMERS
#define DETAILED_PERFORMANCE_TIMER(name) ; // no-op
#endif // WANT_DETAILED_PERFORMANCE_TIMERS
#endif // hifi_PerfStat_h #endif // hifi_PerfStat_h

View file

@ -108,4 +108,14 @@ inline void metadata(const QString& metadataType, const QVariantMap& args) {
#define SAMPLE_PROFILE_COUNTER(chance, category, name, ...) if (randFloat() <= chance) { PROFILE_COUNTER(category, name, ##__VA_ARGS__); } #define SAMPLE_PROFILE_COUNTER(chance, category, name, ...) if (randFloat() <= chance) { PROFILE_COUNTER(category, name, ##__VA_ARGS__); }
#define SAMPLE_PROFILE_INSTANT(chance, category, name, ...) if (randFloat() <= chance) { PROFILE_INSTANT(category, name, ##__VA_ARGS__); } #define SAMPLE_PROFILE_INSTANT(chance, category, name, ...) if (randFloat() <= chance) { PROFILE_INSTANT(category, name, ##__VA_ARGS__); }
// uncomment WANT_DETAILED_PROFILING definition to enable profiling in high-frequency contexts
//#define WANT_DETAILED_PROFILING
#ifdef WANT_DETAILED_PROFILING
#define DETAILED_PROFILE_RANGE(category, name) Duration profileRangeThis(trace_##category(), name);
#define DETAILED_PROFILE_RANGE_EX(category, name, argbColor, payload, ...) Duration profileRangeThis(trace_##category(), name, argbColor, (uint64_t)payload, ##__VA_ARGS__);
#else // WANT_DETAILED_PROFILING
#define DETAILED_PROFILE_RANGE(category, name) ; // no-op
#define DETAILED_PROFILE_RANGE_EX(category, name, argbColor, payload, ...) ; // no-op
#endif // WANT_DETAILED_PROFILING
#endif #endif