Performance trace for some bottleneck of update/render manager 48/311648/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 23 May 2024 05:13:06 +0000 (14:13 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Thu, 23 May 2024 06:30:04 +0000 (15:30 +0900)
Let we check trace the top 5 area of update : update itself / animation /
frame update callback / update renderer / transform
and top 2 area of render : render instruction process / flush

TODO : Since the name of environment need to be sync with peformance
trace tool, we'd better change it after the system prepared.

Change-Id: I4a9e38b6b957508138737ee225c0cfa9ad94a8f9
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/render/common/render-algorithms.cpp
dali/internal/render/common/render-manager.cpp
dali/internal/update/manager/frame-callback-processor.cpp
dali/internal/update/manager/transform-manager.cpp
dali/internal/update/manager/update-manager.cpp

index 9c00289..8048a6f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
 #include <dali/internal/render/common/render-algorithms.h>
 
 // INTERNAL INCLUDES
+#include <dali/integration-api/trace.h>
 #include <dali/internal/render/common/render-debug.h>
 #include <dali/internal/render/common/render-instruction.h>
 #include <dali/internal/render/common/render-list.h>
@@ -390,6 +391,9 @@ inline void SetupDepthBuffer(const RenderItem& item, Graphics::CommandBuffer& co
   }
 }
 
+// TODO : The name of trace marker is from VD specific.
+// We might need to change it as DALI_TRACE_RENDER_PROCESS.
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_COMBINED, false);
 } // Unnamed namespace
 
 /**
@@ -744,6 +748,10 @@ void RenderAlgorithms::ProcessRenderInstruction(const RenderInstruction&
                                                 int                                 orientation,
                                                 const Uint16Pair&                   sceneSize)
 {
+  DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_RENDER_INSTRUCTION_PROCESS", [&](std::ostringstream& oss) {
+    oss << "[" << instruction.RenderListCount() << "]";
+  });
+
   DALI_PRINT_RENDER_INSTRUCTION(instruction, bufferIndex);
 
   const Matrix* viewMatrix       = instruction.GetViewMatrix(bufferIndex);
@@ -790,6 +798,7 @@ void RenderAlgorithms::ProcessRenderInstruction(const RenderInstruction&
       mGraphicsCommandBuffer->ExecuteCommandBuffers(std::move(buffers));
     }
   }
+  DALI_TRACE_END(gTraceFilter, "DALI_RENDER_INSTRUCTION_PROCESS");
 }
 
 } // namespace Render
index 3997f9e..5beba0c 100644 (file)
@@ -24,6 +24,7 @@
 // INTERNAL INCLUDES
 #include <dali/integration-api/core.h>
 #include <dali/integration-api/ordered-set.h>
+#include <dali/integration-api/trace.h>
 
 #include <dali/internal/event/common/scene-impl.h>
 
@@ -145,6 +146,10 @@ inline void AlignDamagedRect(Rect<int32_t>& rect)
   rect.width       = ((right + 16) / 16) * 16 - rect.x;
   rect.height      = ((bottom + 16) / 16) * 16 - rect.y;
 }
+
+// TODO : The name of trace marker is from VD specific.
+// We might need to change it as DALI_TRACE_RENDER_PROCESS.
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_COMBINED, false);
 } // namespace
 
 /**
@@ -1139,21 +1144,33 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
     mainCommandBuffer->EndRenderPass(syncObject);
   }
 
+  if(targetstoPresent.size() > 0u)
+  {
+    DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_RENDER_FINISHED", [&](std::ostringstream& oss) {
+      oss << "[" << targetstoPresent.size() << "]";
+    });
+  }
+
   // Flush UBOs
   mImpl->uniformBufferManager->Flush(sceneObject, renderToFbo);
   mImpl->renderAlgorithms.SubmitCommandBuffer();
   mImpl->commandBufferSubmitted = true;
 
-  std::sort(targetstoPresent.begin(), targetstoPresent.end());
-
-  Graphics::RenderTarget* rt = nullptr;
-  for(auto& target : targetstoPresent)
+  if(targetstoPresent.size() > 0u)
   {
-    if(target != rt)
+    std::sort(targetstoPresent.begin(), targetstoPresent.end());
+
+    Graphics::RenderTarget* rt = nullptr;
+    for(auto& target : targetstoPresent)
     {
-      mImpl->graphicsController.PresentRenderTarget(target);
-      rt = target;
+      if(target != rt)
+      {
+        mImpl->graphicsController.PresentRenderTarget(target);
+        rt = target;
+      }
     }
+
+    DALI_TRACE_END(gTraceFilter, "DALI_RENDER_FINISHED");
   }
 }
 
index fc05171..6c40c72 100644 (file)
@@ -37,7 +37,9 @@
 
 namespace
 {
-DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
+// TODO : The name of trace marker is from VD specific.
+// We might need to change it as DALI_TRACE_UPDATE_PROCESS.
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_COMBINED, false);
 
 #ifdef TRACE_ENABLED
 uint64_t GetNanoseconds()
index 5608192..f5e3bac 100644 (file)
@@ -29,6 +29,7 @@
 #include <dali/public-api/common/constants.h>
 
 #include <dali/integration-api/debug.h>
+#include <dali/integration-api/trace.h>
 
 namespace Dali
 {
@@ -77,6 +78,9 @@ inline void CalculateCenterPosition(
   }
 }
 
+// TODO : The name of trace marker is from VD specific.
+// We might need to change it as DALI_TRACE_UPDATE_PROCESS.
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_COMBINED, false);
 } // unnamed namespace
 
 TransformManager::TransformManager()
@@ -235,8 +239,13 @@ bool TransformManager::Update()
 {
   bool componentsChanged = false;
 
+  DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_TRANSFORM_UPDATE", [&](std::ostringstream& oss) {
+    oss << "[" << mComponentCount << "]";
+  });
+
   if(mReorder)
   {
+    DALI_TRACE_SCOPE(gTraceFilter, "DALI_TRANSFORM_REORDER");
     //If some transform component has change its parent or has been removed since last update
     //we need to reorder the vectors
     ReorderComponents();
@@ -357,6 +366,10 @@ bool TransformManager::Update()
     mComponentDirty[i] = false;
   }
 
+  DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_TRANSFORM_UPDATE", [&](std::ostringstream& oss) {
+    oss << "[componentsChanged:" << componentsChanged << "]";
+  });
+
   return componentsChanged;
 }
 
index 3790b00..e7cbc2e 100644 (file)
@@ -27,6 +27,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/core.h>
+#include <dali/integration-api/trace.h>
 
 #include <dali/internal/common/owner-key-container.h>
 
@@ -80,6 +81,12 @@ namespace
 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_UPDATE_MANAGER");
 } // unnamed namespace
 #endif
+namespace
+{
+// TODO : The name of trace marker is from VD specific.
+// We might need to change it as DALI_TRACE_UPDATE_PROCESS.
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_COMBINED, false);
+} // namespace
 
 using namespace Dali::Integration;
 using Dali::Internal::Update::MessageQueue;
@@ -883,8 +890,17 @@ bool UpdateManager::Animate(BufferIndex bufferIndex, float elapsedSeconds)
 {
   bool animationActive = false;
 
+  if(mImpl->animations.Empty())
+  {
+    return animationActive;
+  }
+
   auto&& iter = mImpl->animations.Begin();
 
+  DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_ANIMATION_ANIMATE", [&](std::ostringstream& oss) {
+    oss << "[" << mImpl->animations.Count() << "]";
+  });
+
   while(iter != mImpl->animations.End())
   {
     Animation* animation             = *iter;
@@ -928,6 +944,10 @@ bool UpdateManager::Animate(BufferIndex bufferIndex, float elapsedSeconds)
     mImpl->notificationManager.QueueNotification(&mImpl->animationPlaylist, std::move(mImpl->notifyRequiredAnimations));
   }
 
+  DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_ANIMATION_ANIMATE", [&](std::ostringstream& oss) {
+    oss << "[" << mImpl->animations.Count() << "]";
+  });
+
   return animationActive;
 }
 
@@ -1016,6 +1036,15 @@ void UpdateManager::ForwardCompiledShadersToEventThread()
 
 void UpdateManager::UpdateRenderers(PropertyOwnerContainer& postPropertyOwners, BufferIndex bufferIndex)
 {
+  if(mImpl->renderers.Empty())
+  {
+    return;
+  }
+
+  DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_UPDATE_RENDERERS", [&](std::ostringstream& oss) {
+    oss << "[" << mImpl->renderers.Count() << "]";
+  });
+
   for(const auto& rendererKey : mImpl->renderers)
   {
     // Apply constraints
@@ -1028,6 +1057,8 @@ void UpdateManager::UpdateRenderers(PropertyOwnerContainer& postPropertyOwners,
 
     mImpl->renderingRequired = renderer->PrepareRender(bufferIndex) || mImpl->renderingRequired;
   }
+
+  DALI_TRACE_END(gTraceFilter, "DALI_UPDATE_RENDERERS");
 }
 
 void UpdateManager::UpdateNodes(PropertyOwnerContainer& postPropertyOwners, BufferIndex bufferIndex)
@@ -1111,6 +1142,15 @@ uint32_t UpdateManager::Update(float    elapsedSeconds,
   // We should not start skipping update steps or reusing lists until there has been two frames where nothing changes
   if(updateScene || mImpl->previousUpdateScene)
   {
+    DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_UPDATE_INTERNAL", [&](std::ostringstream& oss) {
+      oss << "[n:" << mImpl->nodes.Size() << ",";
+      oss << "c:" << mImpl->customObjects.Size() << ",";
+      oss << "a:" << mImpl->animations.Size() << ",";
+      oss << "r:" << mImpl->renderers.Size() << ",";
+      oss << "t:" << mImpl->textureSets.Size() << ",";
+      oss << "s:" << mImpl->shaders.Size() << "]";
+    });
+
     // Animate
     bool animationActive = Animate(bufferIndex, elapsedSeconds);
 
@@ -1237,6 +1277,8 @@ uint32_t UpdateManager::Update(float    elapsedSeconds,
 
       DALI_LOG_INFO(gLogFilter, Debug::General, "Update: numberOfRenderTasks(%d), Render Instructions(%d)\n", numberOfRenderTasks, numberOfRenderInstructions);
     }
+
+    DALI_TRACE_END(gTraceFilter, "DALI_UPDATE_INTERNAL");
   }
 
   if(!uploadOnly)