From 815490375bbb42ef8454fa5f474268084e08b62f Mon Sep 17 00:00:00 2001 From: David Steele Date: Thu, 22 Sep 2022 11:05:10 +0100 Subject: [PATCH] Memory Pool Logging Added methods to fetch the current capacity of graphics memory pools Added an environment variable DALI_MEMORY_POOL_INTERVAL to trigger logging of Core memory pools on a timer, and Graphics memory pools from inside the render thread. Added logging to PixelBuffer to log individual allocations (By setting DALI_LOG_PIXEL_BUFFER_SIZE to "1" or higher, and enabling debug). Added method to PixelData to log total allocation (By setting DALI_OBJECT_PROFILER_INTERVAL to a non-zero value and enabling debug). Change-Id: Ib65e16d33d7219456d0245bfe686c199dcfa330f --- .../test-graphics-application.h | 8 ++++++++ dali/internal/adaptor/common/adaptor-impl.cpp | 15 ++++++++++++++ dali/internal/adaptor/common/adaptor-impl.h | 22 +++++++++++++------- .../common/combined-update-render-controller.cpp | 12 ++++++++++- dali/internal/graphics/common/graphics-interface.h | 10 +++++++++ .../graphics/gles-impl/egl-graphics-controller.cpp | 24 ++++++++++++++-------- .../graphics/gles-impl/egl-graphics-controller.h | 15 +++++++++++++- .../gles-impl/gles-graphics-command-buffer.cpp | 17 ++++++++++++++- .../gles-impl/gles-graphics-command-buffer.h | 3 +++ dali/internal/graphics/gles/egl-graphics.cpp | 15 ++++++++++++++ dali/internal/graphics/gles/egl-graphics.h | 12 ++++++++++- dali/internal/imaging/common/pixel-buffer-impl.cpp | 24 ++++++++++++++++++++++ dali/internal/imaging/common/pixel-buffer-impl.h | 17 +++++++++++++++ .../internal/system/common/environment-options.cpp | 9 ++++++-- dali/internal/system/common/environment-options.h | 8 +++++++- .../internal/system/common/environment-variables.h | 3 ++- dali/internal/system/common/object-profiler.cpp | 13 ++++++++++-- 17 files changed, 201 insertions(+), 26 deletions(-) diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.h index a1f8a2e..66c9f7a 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.h +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.h @@ -195,6 +195,14 @@ public: return 320; } + void FrameStart() override + { + } + + void LogMemoryPools() override + { + } + /** * Store cached configurations */ diff --git a/dali/internal/adaptor/common/adaptor-impl.cpp b/dali/internal/adaptor/common/adaptor-impl.cpp index a9fbcfe..b7de74f 100644 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -189,6 +189,14 @@ void Adaptor::Initialize(GraphicsFactory& graphicsFactory) mObjectProfiler = new ObjectProfiler(mCore->GetObjectRegistry(), timeInterval); } + const uint32_t poolTimeInterval = mEnvironmentOptions->GetMemoryPoolInterval(); + if(0u < poolTimeInterval) + { + mMemoryPoolTimer = Dali::Timer::New(poolTimeInterval * 1000); + mMemoryPoolTimer.TickSignal().Connect(mMemoryPoolTimerSlotDelegate, &Adaptor::MemoryPoolTimeout); + mMemoryPoolTimer.Start(); + } + mNotificationTrigger = TriggerEventFactory::CreateTriggerEvent(MakeCallback(this, &Adaptor::ProcessCoreEvents), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER); mDisplayConnection = Dali::DisplayConnection::New(*mGraphics, defaultWindow->GetSurface()->GetSurfaceType()); @@ -1231,6 +1239,7 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, mKernelTracer(), mSystemTracer(), mObjectProfiler(nullptr), + mMemoryPoolTimerSlotDelegate(this), mSocketFactory(), mMutex(), mThreadMode(threadMode), @@ -1278,6 +1287,12 @@ void Adaptor::RemoveIdleEnterer(CallbackBase* callback) mCallbackManager->RemoveIdleEntererCallback(callback); } +bool Adaptor::MemoryPoolTimeout() +{ + mCore->LogMemoryPools(); + return true; // Keep logging forever +} + } // namespace Adaptor } // namespace Internal diff --git a/dali/internal/adaptor/common/adaptor-impl.h b/dali/internal/adaptor/common/adaptor-impl.h index 69a6b3f..d24b830 100644 --- a/dali/internal/adaptor/common/adaptor-impl.h +++ b/dali/internal/adaptor/common/adaptor-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_ADAPTOR_IMPL_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include #include #include @@ -620,6 +621,11 @@ private: */ void RemoveIdleEnterer(CallbackBase* callback); + /** + * Trigger to log the memory pools from Core and Adaptor + */ + bool MemoryPoolTimeout(); + private: /** * Constructor @@ -679,12 +685,14 @@ private: // Data KernelTrace mKernelTracer; ///< Kernel tracer SystemTrace mSystemTracer; ///< System tracer ObjectProfiler* mObjectProfiler; ///< Tracks object lifetime for profiling - SocketFactory mSocketFactory; ///< Socket factory - Mutex mMutex; ///< Mutex - ThreadMode mThreadMode; ///< The thread mode - const bool mEnvironmentOptionsOwned : 1; ///< Whether we own the EnvironmentOptions (and thus, need to delete it) - bool mUseRemoteSurface : 1; ///< whether the remoteSurface is used or not - Dali::LayoutDirection::Type mRootLayoutDirection; ///< LayoutDirection of window + Dali::Timer mMemoryPoolTimer; ///< Logs memory pool capacity + SlotDelegate mMemoryPoolTimerSlotDelegate; + SocketFactory mSocketFactory; ///< Socket factory + Mutex mMutex; ///< Mutex + ThreadMode mThreadMode; ///< The thread mode + const bool mEnvironmentOptionsOwned : 1; ///< Whether we own the EnvironmentOptions (and thus, need to delete it) + bool mUseRemoteSurface : 1; ///< whether the remoteSurface is used or not + Dali::LayoutDirection::Type mRootLayoutDirection; ///< LayoutDirection of window std::unique_ptr mAddOnManager; ///< Pointer to the addon manager diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp index 49d02f3..a3d81ac 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -528,6 +527,7 @@ void CombinedUpdateRenderController::UpdateRenderThread() // Update time uint64_t lastFrameTime; TimeService::GetNanoseconds(lastFrameTime); + uint64_t lastMemPoolLogTime = lastFrameTime; LOG_UPDATE_RENDER("THREAD INITIALISED"); @@ -536,6 +536,8 @@ void CombinedUpdateRenderController::UpdateRenderThread() uint64_t timeToSleepUntil = 0; int extraFramesDropped = 0; + const uint64_t memPoolInterval = mEnvironmentOptions.GetMemoryPoolInterval() * NANOSECONDS_PER_SECOND; + const unsigned int renderToFboInterval = mEnvironmentOptions.GetRenderToFboInterval(); const bool renderToFboEnabled = 0u != renderToFboInterval; unsigned int frameCount = 0u; @@ -647,6 +649,7 @@ void CombinedUpdateRenderController::UpdateRenderThread() // RENDER ////////////////////////////// + graphics.FrameStart(); mAdaptorInterfaces.GetDisplayConnectionInterface().ConsumeEvents(); if(mPreRenderCallback != NULL) @@ -746,6 +749,13 @@ void CombinedUpdateRenderController::UpdateRenderThread() TRACE_UPDATE_RENDER_END("DALI_RENDER"); AddPerformanceMarker(PerformanceInterface::RENDER_END); + // if the memory pool interval is set and has elapsed, log the graphics memory pools + if(0 < memPoolInterval && memPoolInterval < lastFrameTime - lastMemPoolLogTime) + { + lastMemPoolLogTime = lastFrameTime; + graphics.LogMemoryPools(); + } + mForceClear = false; // Trigger event thread to request Update/Render thread to sleep if update not required diff --git a/dali/internal/graphics/common/graphics-interface.h b/dali/internal/graphics/common/graphics-interface.h index 08cc77d..53fa462 100644 --- a/dali/internal/graphics/common/graphics-interface.h +++ b/dali/internal/graphics/common/graphics-interface.h @@ -181,6 +181,16 @@ public: */ virtual void CacheConfigurations(ConfigurationManager& configurationManager) = 0; + /** + * Initialize data for logging frame info + */ + virtual void FrameStart() = 0; + + /** + * Log total capacity of memory pools during this frame + */ + virtual void LogMemoryPools() = 0; + protected: Integration::DepthBufferAvailable mDepthBufferRequired; ///< Whether the depth buffer is required Integration::StencilBufferAvailable mStencilBufferRequired; ///< Whether the stencil buffer is required diff --git a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp b/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp index be7a0c3..b093c7f 100644 --- a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp +++ b/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp @@ -127,7 +127,7 @@ EglGraphicsController::~EglGraphicsController() void EglGraphicsController::InitializeGLES(Integration::GlAbstraction& glAbstraction) { - DALI_LOG_RELEASE_INFO("Initializing New Graphics Controller #1\n"); + DALI_LOG_RELEASE_INFO("Initializing Graphics Controller Phase 1\n"); mGlAbstraction = &glAbstraction; mContext = std::make_unique(*this); mCurrentContext = mContext.get(); @@ -137,7 +137,7 @@ void EglGraphicsController::Initialize(Integration::GraphicsSyncAbstraction& Integration::GlContextHelperAbstraction& glContextHelperAbstraction, Internal::Adaptor::GraphicsInterface& graphicsInterface) { - DALI_LOG_RELEASE_INFO("Initializing New Graphics Controller #2\n"); + DALI_LOG_RELEASE_INFO("Initializing Graphics Controller Phase 2\n"); auto* syncImplPtr = static_cast(&syncImplementation); mEglSyncImplementation = syncImplPtr; @@ -145,12 +145,19 @@ void EglGraphicsController::Initialize(Integration::GraphicsSyncAbstraction& mGraphics = &graphicsInterface; } +void EglGraphicsController::FrameStart() +{ + mCapacity = 0; // Reset the command buffer capacity at the start of the frame. +} + void EglGraphicsController::SubmitCommandBuffers(const SubmitInfo& submitInfo) { for(auto& cmdbuf : submitInfo.cmdBuffer) { // Push command buffers - mCommandQueue.push(static_cast(cmdbuf)); + auto* commandBuffer = static_cast(cmdbuf); + mCapacity += commandBuffer->GetCapacity(); + mCommandQueue.push(commandBuffer); } // If flush bit set, flush all pending tasks @@ -312,7 +319,7 @@ TextureProperties EglGraphicsController::GetTextureProperties(const Texture& tex properties.compressed = glesTexture->IsCompressed(); properties.extent2D = createInfo.size; properties.nativeHandle = glesTexture->GetGLTexture(); - //TODO: Skip format1, emulated, packed, directWriteAccessEnabled of TextureProperties for now + // TODO: Skip format1, emulated, packed, directWriteAccessEnabled of TextureProperties for now return properties; } @@ -331,7 +338,8 @@ void EglGraphicsController::CreateSurfaceContext(Dali::RenderSurfaceInterface* s void EglGraphicsController::DeleteSurfaceContext(Dali::RenderSurfaceInterface* surface) { mSurfaceContexts.erase(std::remove_if( - mSurfaceContexts.begin(), mSurfaceContexts.end(), [surface](SurfaceContextPair& iter) { return surface == iter.first; }), + mSurfaceContexts.begin(), mSurfaceContexts.end(), [surface](SurfaceContextPair& iter) + { return surface == iter.first; }), mSurfaceContexts.end()); } @@ -339,7 +347,6 @@ void EglGraphicsController::ActivateResourceContext() { mCurrentContext = mContext.get(); mCurrentContext->GlContextCreated(); - if(!mSharedContext) { auto eglGraphics = dynamic_cast(mGraphics); @@ -354,9 +361,8 @@ void EglGraphicsController::ActivateSurfaceContext(Dali::RenderSurfaceInterface* { if(surface && mGraphics->IsResourceContextSupported()) { - auto iter = std::find_if(mSurfaceContexts.begin(), mSurfaceContexts.end(), [surface](SurfaceContextPair& iter) { - return (iter.first == surface); - }); + auto iter = std::find_if(mSurfaceContexts.begin(), mSurfaceContexts.end(), [surface](SurfaceContextPair& iter) + { return (iter.first == surface); }); if(iter != mSurfaceContexts.end()) { diff --git a/dali/internal/graphics/gles-impl/egl-graphics-controller.h b/dali/internal/graphics/gles-impl/egl-graphics-controller.h index b89fa31..1db48a2 100644 --- a/dali/internal/graphics/gles-impl/egl-graphics-controller.h +++ b/dali/internal/graphics/gles-impl/egl-graphics-controller.h @@ -94,6 +94,13 @@ public: Internal::Adaptor::EglSyncImplementation& GetEglSyncImplementation(); /** + * Mark the start of the frame. + * + * Note, this is used for logging & debugging, so is not part of the main Graphics API. + */ + void FrameStart(); + + /** * @copydoc Dali::Graphics::SubmitCommandBuffers() */ void SubmitCommandBuffers(const SubmitInfo& submitInfo) override; @@ -775,6 +782,11 @@ public: return mSyncPool; } + std::size_t GetCapacity() const + { + return mCapacity; + } + private: Integration::GlAbstraction* mGlAbstraction{nullptr}; Integration::GlContextHelperAbstraction* mGlContextHelperAbstraction{nullptr}; @@ -823,10 +835,11 @@ private: GLES::TextureDependencyChecker mTextureDependencyChecker; // Checks if FBO textures need syncing GLES::SyncPool mSyncPool; + std::size_t mCapacity; ///< Memory Usage (of command buffers) }; } // namespace Graphics } // namespace Dali -#endif //DALI_EGL_GRAPHICS_CONTROLLER_H +#endif // DALI_EGL_GRAPHICS_CONTROLLER_H diff --git a/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.cpp b/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.cpp index d619842..bc463ab 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.cpp +++ b/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.cpp @@ -65,7 +65,7 @@ class CommandPool inline void resize(int newSize) { ptr = reinterpret_cast(realloc(ptr, newSize * sizeof(T))); - capacity = newSize; + capacity = newSize * sizeof(T); dataSize = newSize; } @@ -224,6 +224,11 @@ public: size = commandPool.size; return commandPool.data.ptr; } + + std::size_t GetTotalCapacity() const + { + return commandPool.data.capacity + memoryPool.data.capacity; + } }; CommandBuffer::CommandBuffer(const Graphics::CommandBufferCreateInfo& createInfo, EglGraphicsController& controller) @@ -558,4 +563,14 @@ void CommandBuffer::DiscardResource() GetController().DiscardResource(this); } +std::size_t CommandBuffer::GetCapacity() +{ + std::size_t total{0u}; + if(mCommandPool) + { + total = mCommandPool->GetTotalCapacity(); + } + return total; +} + } // namespace Dali::Graphics::GLES diff --git a/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h b/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h index 07c5561..c2ae566 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h +++ b/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h @@ -438,6 +438,9 @@ public: */ void DiscardResource() override; + // Get the total memory usage of this command buffer + std::size_t GetCapacity(); + private: std::unique_ptr mCommandPool; ///< Pool of commands and transient memory }; diff --git a/dali/internal/graphics/gles/egl-graphics.cpp b/dali/internal/graphics/gles/egl-graphics.cpp index 15e17f1..0786141 100644 --- a/dali/internal/graphics/gles/egl-graphics.cpp +++ b/dali/internal/graphics/gles/egl-graphics.cpp @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include #include #include #include // For Utils::MakeUnique @@ -251,6 +252,20 @@ void EglGraphics::CacheConfigurations(ConfigurationManager& configurationManager mGLES->SetShadingLanguageVersion(configurationManager.GetShadingLanguageVersion()); } +void EglGraphics::FrameStart() +{ + mGraphicsController.FrameStart(); +} + +void EglGraphics::LogMemoryPools() +{ + std::size_t graphicsCapacity = mGraphicsController.GetCapacity(); + DALI_LOG_RELEASE_INFO( + "EglGraphics:\n" + " GraphicsController Capacity: %lu\n", + graphicsCapacity); +} + } // namespace Adaptor } // namespace Internal } // namespace Dali diff --git a/dali/internal/graphics/gles/egl-graphics.h b/dali/internal/graphics/gles/egl-graphics.h index 48dd0b7..b431611 100644 --- a/dali/internal/graphics/gles/egl-graphics.h +++ b/dali/internal/graphics/gles/egl-graphics.h @@ -211,9 +211,19 @@ public: void CacheConfigurations(ConfigurationManager& configurationManager) override; + /** + * @copydoc Dali::Internal::Adaptor::GraphicsInterface::FrameStart() + */ + void FrameStart() override; + + /** + * @copydoc Dali::Internal::Adaptor::GraphicsInterface::LogMemoryPools() + */ + void LogMemoryPools() override; + private: // Eliminate copy and assigned operations - EglGraphics(const EglGraphics& rhs) = delete; + EglGraphics(const EglGraphics& rhs) = delete; EglGraphics& operator=(const EglGraphics& rhs) = delete; /** diff --git a/dali/internal/imaging/common/pixel-buffer-impl.cpp b/dali/internal/imaging/common/pixel-buffer-impl.cpp index f4a1743..ffdb355 100644 --- a/dali/internal/imaging/common/pixel-buffer-impl.cpp +++ b/dali/internal/imaging/common/pixel-buffer-impl.cpp @@ -23,6 +23,7 @@ #include // INTERNAL INCLUDES +#include #include #include #include @@ -36,6 +37,11 @@ namespace Adaptor { namespace { + +#if defined(DEBUG_ENABLED) +Debug::Filter* gPixelBufferFilter = Debug::Filter::New(Debug::NoLogging, false, "DALI_LOG_PIXEL_BUFFER_SIZE"); +#endif + const float TWO_PI = 2.f * Math::PI; ///< 360 degrees in radians // based on W3C Recommendations (https://www.w3.org/TR/AERT/#color-contrast) constexpr uint32_t BRIGHTNESS_CONSTANT_R = 299; @@ -43,6 +49,10 @@ constexpr uint32_t BRIGHTNESS_CONSTANT_G = 587; constexpr uint32_t BRIGHTNESS_CONSTANT_B = 114; } // namespace +#if defined(DEBUG_ENABLED) +uint32_t PixelBuffer::gPixelBufferAllocationTotal{0}; +#endif + PixelBuffer::PixelBuffer(uint8_t* buffer, uint32_t bufferSize, uint32_t width, @@ -74,7 +84,12 @@ PixelBufferPtr PixelBuffer::New(uint32_t width, if(bufferSize > 0) { buffer = static_cast(malloc(bufferSize)); +#if defined(DEBUG_ENABLED) + gPixelBufferAllocationTotal += bufferSize; +#endif } + DALI_LOG_INFO(gPixelBufferFilter, Debug::Concise, "Allocated PixelBuffer of size %u\n", bufferSize); + return new PixelBuffer(buffer, bufferSize, width, height, width, pixelFormat); } @@ -90,6 +105,9 @@ PixelBufferPtr PixelBuffer::New(uint8_t* buffer, Dali::PixelData PixelBuffer::Convert(PixelBuffer& pixelBuffer) { +#if defined(DEBUG_ENABLED) + gPixelBufferAllocationTotal -= pixelBuffer.mBufferSize; +#endif Dali::PixelData pixelData = Dali::PixelData::New(pixelBuffer.mBuffer, pixelBuffer.mBufferSize, pixelBuffer.mWidth, @@ -219,6 +237,9 @@ void PixelBuffer::ReleaseBuffer() { if(mBuffer) { +#if defined(DEBUG_ENABLED) + gPixelBufferAllocationTotal -= mBufferSize; +#endif free(mBuffer); } } @@ -228,6 +249,9 @@ void PixelBuffer::AllocateFixedSize(uint32_t size) ReleaseBuffer(); mBuffer = reinterpret_cast(malloc(size)); mBufferSize = size; +#if defined(DEBUG_ENABLED) + gPixelBufferAllocationTotal += size; +#endif } bool PixelBuffer::Rotate(Degree angle) diff --git a/dali/internal/imaging/common/pixel-buffer-impl.h b/dali/internal/imaging/common/pixel-buffer-impl.h index 0866dd4..45ff5dd 100644 --- a/dali/internal/imaging/common/pixel-buffer-impl.h +++ b/dali/internal/imaging/common/pixel-buffer-impl.h @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include #include // For ImageDimensions #include #include @@ -106,6 +107,18 @@ protected: public: /** + * Get the total allocated size of current pixel buffers + */ + static uint32_t GetTotalAllocatedSize() + { +#if defined(DEBUG_ENABLED) + return gPixelBufferAllocationTotal; +#else + return 0; +#endif + } + + /** * Get the width of the buffer in pixels. * @return The width of the buffer in pixels */ @@ -297,6 +310,10 @@ private: uint32_t mStride; ///< Buffer stride in bytes, 0 means the buffer is tightly packed Pixel::Format mPixelFormat; ///< Pixel format bool mPreMultiplied; ///< PreMultiplied + +#if defined(DEBUG_ENABLED) + static uint32_t gPixelBufferAllocationTotal; +#endif }; } // namespace Adaptor diff --git a/dali/internal/system/common/environment-options.cpp b/dali/internal/system/common/environment-options.cpp index 6de61e0..d1b0829 100644 --- a/dali/internal/system/common/environment-options.cpp +++ b/dali/internal/system/common/environment-options.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -206,6 +206,7 @@ EnvironmentOptions::EnvironmentOptions() mFpsFrequency(0), mUpdateStatusFrequency(0), mObjectProfilerInterval(0), + mMemoryPoolInterval(0), mPerformanceStatsLevel(0), mPerformanceStatsFrequency(DEFAULT_STATISTICS_LOG_FREQUENCY), mPerformanceTimeStampOutput(0), @@ -300,7 +301,10 @@ unsigned int EnvironmentOptions::GetObjectProfilerInterval() const { return mObjectProfilerInterval; } - +unsigned int EnvironmentOptions::GetMemoryPoolInterval() const +{ + return mMemoryPoolInterval; +} unsigned int EnvironmentOptions::GetPerformanceStatsLoggingOptions() const { return mPerformanceStatsLevel; @@ -522,6 +526,7 @@ void EnvironmentOptions::ParseEnvironmentOptions() mFpsFrequency = GetEnvironmentVariable(DALI_ENV_FPS_TRACKING, 0); mUpdateStatusFrequency = GetEnvironmentVariable(DALI_ENV_UPDATE_STATUS_INTERVAL, 0); mObjectProfilerInterval = GetEnvironmentVariable(DALI_ENV_OBJECT_PROFILER_INTERVAL, 0); + mMemoryPoolInterval = GetEnvironmentVariable(DALI_ENV_MEMORY_POOL_INTERVAL, 0); mPerformanceStatsLevel = GetEnvironmentVariable(DALI_ENV_LOG_PERFORMANCE_STATS, 0); mPerformanceStatsFrequency = GetEnvironmentVariable(DALI_ENV_LOG_PERFORMANCE_STATS_FREQUENCY, 0); mPerformanceTimeStampOutput = GetEnvironmentVariable(DALI_ENV_PERFORMANCE_TIMESTAMP_OUTPUT, 0); diff --git a/dali/internal/system/common/environment-options.h b/dali/internal/system/common/environment-options.h index 4ba290c..13299e6 100644 --- a/dali/internal/system/common/environment-options.h +++ b/dali/internal/system/common/environment-options.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_ADAPTOR_ENVIRONMENT_OPTIONS_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -100,6 +100,11 @@ public: unsigned int GetObjectProfilerInterval() const; /** + * @return memory pool status interval (0==off) + */ + unsigned int GetMemoryPoolInterval() const; + + /** * @return performance statistics log level ( 0 == off ) */ unsigned int GetPerformanceStatsLoggingOptions() const; @@ -354,6 +359,7 @@ private: // Data unsigned int mFpsFrequency; ///< how often fps is logged out in seconds unsigned int mUpdateStatusFrequency; ///< how often update status is logged out in frames unsigned int mObjectProfilerInterval; ///< how often object counts are logged out in seconds + uint32_t mMemoryPoolInterval; ///< how often memory pool capacities are logged out in seconds unsigned int mPerformanceStatsLevel; ///< performance statistics logging bitmask unsigned int mPerformanceStatsFrequency; ///< performance statistics logging frequency (seconds) unsigned int mPerformanceTimeStampOutput; ///< performance time stamp output ( bitmask) diff --git a/dali/internal/system/common/environment-variables.h b/dali/internal/system/common/environment-variables.h index c262bd7..59329f0 100644 --- a/dali/internal/system/common/environment-variables.h +++ b/dali/internal/system/common/environment-variables.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_ADAPTOR_ENVIRONMENT_VARIABLES_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -53,6 +53,7 @@ namespace Adaptor #define DALI_ENV_UPDATE_STATUS_INTERVAL "DALI_UPDATE_STATUS_INTERVAL" #define DALI_ENV_OBJECT_PROFILER_INTERVAL "DALI_OBJECT_PROFILER_INTERVAL" +#define DALI_ENV_MEMORY_POOL_INTERVAL "DALI_MEMORY_POOL_INTERVAL" // Pan-Gesture configuration: // Prediction Modes 1 & 2: diff --git a/dali/internal/system/common/object-profiler.cpp b/dali/internal/system/common/object-profiler.cpp index 4be76bd..f7f417a 100644 --- a/dali/internal/system/common/object-profiler.cpp +++ b/dali/internal/system/common/object-profiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 20217 Samsung Electronics Co., Ltd. + * Copyright (c) 20227 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. @@ -21,9 +21,12 @@ // EXTERNAL INCLUDES #include #include +#include +#include #include #include #include + #include using std::string; @@ -72,6 +75,11 @@ void ObjectProfiler::DisplayInstanceCounts() bool ObjectProfiler::OnTimeout() { + uint32_t pixelDataSize = Dali::PixelData::GetTotalAllocatedSize(); + uint32_t pixelBufferSize = Dali::Internal::Adaptor::PixelBuffer::GetTotalAllocatedSize(); + LogMessage(Debug::DebugInfo, "Total PixelData: %9.1fkb\n", ((float)pixelDataSize) / 1024.0f); + LogMessage(Debug::DebugInfo, "Total PixelBuffer: %9.1fkb\n", ((float)pixelBufferSize) / 1024.0f); + DisplayInstanceCounts(); return true; } @@ -117,7 +125,8 @@ void ObjectProfiler::OnObjectDestroyed(const Dali::RefObject* object) { auto&& countIter = std::find_if(mInstanceCountContainer.begin(), mInstanceCountContainer.end(), - [theType](const InstanceCountPair& instance) { return instance.first == theType; }); + [theType](const InstanceCountPair& instance) + { return instance.first == theType; }); if(countIter != mInstanceCountContainer.end()) { (*countIter).second--; -- 2.7.4