Remove RAD (pending future interface for external profiler registration)

Signed-off-by: Jeremy Ong <jcong@amazon.com>
This commit is contained in:
Jeremy Ong
2021-08-18 17:20:27 -06:00
parent 11d4543442
commit ec6e9407f6
44 changed files with 12 additions and 1184 deletions
@@ -11,7 +11,6 @@
#include <AzCore/Component/Component.h>
#include <AzCore/Component/Entity.h>
#include <AzCore/Component/TickBus.h>
#include <AzCore/Debug/ProfileModuleInit.h>
#include <AzCore/Memory/AllocationRecords.h>
#include <AzCore/Memory/OSAllocator.h>
#include <AzCore/Module/DynamicModuleHandle.h>
@@ -38,17 +38,6 @@ namespace AZ
}
}
#ifdef AZ_PROFILE_TELEMETRY
# define AZ_TRACE_METHOD_NAME_CATEGORY(name, category) AZ::Debug::EventTrace::ScopedSlice AZ_JOIN(ScopedSlice__, __LINE__)(name, category);
# define AZ_TRACE_METHOD_NAME(name) \
AZ_TRACE_METHOD_NAME_CATEGORY(name, "") \
AZ_PROFILE_SCOPE(AzTrace, name)
# define AZ_TRACE_METHOD() \
AZ_TRACE_METHOD_NAME_CATEGORY(AZ_FUNCTION_SIGNATURE, "") \
AZ_PROFILE_FUNCTION(AzTrace)
#else
# define AZ_TRACE_METHOD_NAME_CATEGORY(name, category)
# define AZ_TRACE_METHOD_NAME(name) AZ_TRACE_METHOD_NAME_CATEGORY(name, "")
# define AZ_TRACE_METHOD() AZ_TRACE_METHOD_NAME(AZ_FUNCTION_SIGNATURE)
#endif
#define AZ_TRACE_METHOD_NAME_CATEGORY(name, category)
#define AZ_TRACE_METHOD_NAME(name) AZ_TRACE_METHOD_NAME_CATEGORY(name, "")
#define AZ_TRACE_METHOD() AZ_TRACE_METHOD_NAME(AZ_FUNCTION_SIGNATURE)
@@ -1,53 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/Debug/ProfileModuleInit.h>
#ifdef AZ_PROFILE_TELEMETRY
# include <RADTelemetry/ProfileTelemetryBus.h>
// Define the per-module RAD Telemetry instance pointer
struct tm_api;
tm_api* g_radTmApi;
#endif
namespace AZ
{
namespace Debug
{
void ProfileModuleInit()
{
#if defined(AZ_PROFILE_TELEMETRY)
{
if (!g_radTmApi)
{
using namespace RADTelemetry;
ProfileTelemetryRequestBus::BroadcastResult(g_radTmApi, &ProfileTelemetryRequests::GetApiInstance);
}
}
#endif
// Add additional per-DLL required profiler initialization here
}
ProfileModuleInitializer::ProfileModuleInitializer()
{
ProfilerNotificationBus::Handler::BusConnect();
}
ProfileModuleInitializer::~ProfileModuleInitializer()
{
ProfilerNotificationBus::Handler::BusDisconnect();
}
void ProfileModuleInitializer::OnProfileSystemInitialized()
{
ProfileModuleInit();
}
}
}
@@ -1,36 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/Debug/ProfilerBus.h>
namespace AZ
{
namespace Debug
{
//! Perform any required per-module initialization of the current profiler
void ProfileModuleInit();
/*!
* ProfileModuleInitializer
* Helper class that calls ProfileModuleInit when OnProfileSystemInitialized is fired.
*/
class ProfileModuleInitializer
: private AZ::Debug::ProfilerNotificationBus::Handler
{
public:
ProfileModuleInitializer();
~ProfileModuleInitializer() override;
private:
void OnProfileSystemInitialized() override;
};
}
}
@@ -15,10 +15,6 @@
#include <WinPixEventRuntime/pix3.h>
#endif
#ifdef AZ_PROFILE_TELEMETRY
# include <RADTelemetry/ProfileTelemetry.h>
#endif
#if defined(AZ_PROFILER_MACRO_DISABLE) // by default we never disable the profiler registers as their overhead should be minimal, you can still do that for your code though.
# define AZ_PROFILE_SCOPE(...)
# define AZ_PROFILE_FUNCTION(...)
@@ -38,7 +34,6 @@
#endif // AZ_PROFILER_MACRO_DISABLE
#ifndef AZ_PROFILE_INTERVAL_START
// No other profiler has defined the performance markers AZ_PROFILE_INTERVAL_START/END, fallback to a Driller implementation (currently empty)
# define AZ_PROFILE_INTERVAL_START(...)
# define AZ_PROFILE_INTERVAL_START_COLORED(...)
# define AZ_PROFILE_INTERVAL_END(...)
@@ -46,7 +41,6 @@
#endif
#ifndef AZ_PROFILE_DATAPOINT
// No other profiler has defined the performance markers AZ_PROFILE_DATAPOINT, fallback to a Driller implementation (currently empty)
# define AZ_PROFILE_DATAPOINT(...)
# define AZ_PROFILE_DATAPOINT_PERCENT(...)
#endif
@@ -9,7 +9,6 @@
#define AZCORE_MODULE_INCLUDE_H 1
#include <AzCore/Component/Component.h>
#include <AzCore/Debug/ProfileModuleInit.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Module/Environment.h>
#include <AzCore/Interface/Interface.h>
@@ -78,9 +77,6 @@ namespace AZ
protected:
AZStd::list<AZ::ComponentDescriptor*> m_descriptors;
private:
AZ::Debug::ProfileModuleInitializer m_moduleProfilerInit;
};
} // namespace AZ
@@ -287,14 +287,6 @@ void ScriptSystemComponent::OnSystemTick()
contextContainer.m_context->GetDebugContext()->ProcessDebugCommands();
}
#ifdef AZ_PROFILE_TELEMETRY
if (contextContainer.m_context->GetId() == ScriptContextIds::DefaultScriptContextId)
{
size_t memoryUsageBytes = contextContainer.m_context->GetMemoryUsage();
AZ_PROFILE_DATAPOINT(Script, memoryUsageBytes / 1024.0, "Script Memory (KB)");
}
#endif // AZ_PROFILE_TELEMETRY
contextContainer.m_context->GarbageCollectStep(contextContainer.m_garbageCollectorSteps);
}
}
@@ -17,7 +17,7 @@
#include <AzCore/Debug/Profiler.h>
#if !defined(AZ_PROFILE_TELEMETRY) && defined(AZ_STATISTICAL_PROFILING_ENABLED)
#if defined(AZ_STATISTICAL_PROFILING_ENABLED)
#if defined(AZ_PROFILE_SCOPE)
#undef AZ_PROFILE_SCOPE
@@ -27,7 +27,7 @@
static const AZStd::string AZ_JOIN(blockName, __LINE__)(scopeNameId); \
AZ::Statistics::StatisticalProfilerProxy::TimedScope AZ_JOIN(scope, __LINE__)(profiler, AZ_JOIN(blockName, __LINE__));
#endif //#if !defined(AZ_PROFILE_TELEMETRY)
#endif //#if defined(AZ_STATISTICAL_PROFILING_ENABLED)
namespace AZ::Statistics
{
@@ -100,8 +100,6 @@ set(FILES
Debug/FrameProfilerComponent.h
Debug/IEventLogger.h
Debug/MemoryProfiler.h
Debug/ProfileModuleInit.cpp
Debug/ProfileModuleInit.h
Debug/Profiler.cpp
Debug/Profiler.h
Debug/ProfilerBus.h
-11
View File
@@ -12,13 +12,6 @@
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME})
ly_get_list_relative_pal_filename(common_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/Common)
if(LY_RAD_TELEMETRY_ENABLED)
set(AZ_CORE_RADTELEMETRY_FILES ${common_dir}/azcore_profile_telemetry_files.cmake)
set(AZ_CORE_RADTELEMETRY_PLATFORM_INCLUDES ${pal_dir}/profile_telemetry_platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
set(AZ_CORE_RADTELEMETRY_INCLUDE_DIRECTORIES ${common_dir})
set(AZ_CORE_RADTELEMETRY_BUILD_DEPENDENCIES 3rdParty::RadTelemetry)
endif()
if(PAL_TRAIT_PROF_PIX_SUPPORTED AND LY_PIX_ENABLED)
set(LY_PIX_PATH "${LY_3RDPARTY_PATH}/winpixeventruntime" CACHE PATH "Path to the Windows Pix Event Runtime.")
set(AZ_CORE_PIX_BUILD_DEPENDENCIES 3rdParty::pix)
@@ -32,16 +25,13 @@ ly_add_target(
AzCore/azcore_files.cmake
AzCore/std/azstd_files.cmake
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
${AZ_CORE_RADTELEMETRY_FILES}
PLATFORM_INCLUDE_FILES
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
${AZ_CORE_RADTELEMETRY_PLATFORM_INCLUDES}
INCLUDE_DIRECTORIES
PUBLIC
.
${pal_dir}
${common_dir}
${AZ_CORE_RADTELEMETRY_INCLUDE_DIRECTORIES}
BUILD_DEPENDENCIES
PUBLIC
3rdParty::Lua
@@ -50,7 +40,6 @@ ly_add_target(
3rdParty::zlib
3rdParty::zstd
3rdParty::cityhash
${AZ_CORE_RADTELEMETRY_BUILD_DEPENDENCIES}
${AZ_CORE_PIX_BUILD_DEPENDENCIES}
COMPILE_DEFINITIONS
PUBLIC
@@ -11,7 +11,3 @@
# NOTE: functions in cmake are global, therefore adding functions to this file
# is being avoided to prevent overriding functions declared in other targets platfrom
# specific cmake files
if(LY_RAD_TELEMETRY_ENABLED)
set(LY_COMPILE_DEFINITIONS PUBLIC AZ_PROFILE_TELEMETRY)
endif()
@@ -1,143 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#ifdef AZ_PROFILE_TELEMETRY
/*!
* ProfileTelemetry.h provides a RAD Telemetry specific implementation of the AZ_PROFILE_FUNCTION, AZ_PROFILE_SCOPE, and AZ_PROFILE_SCOPE_DYNAMIC performance instrumentation markers
*/
#define TM_API_PTR g_radTmApi
#include <rad_tm.h>
#include <AzCore/Math/Color.h>
namespace ProfileTelemetryInternal
{
inline constexpr tm_uint32 ConvertColor(uint32_t rgba)
{
return
((rgba >> 24) & 0x000000ff) | // move byte 3 to byte 0
((rgba << 8) & 0x00ff0000) | // move byte 1 to byte 2
((rgba >> 8) & 0x0000ff00) | // move byte 2 to byte 1
((rgba << 24) & 0xff000000); // byte 0 to byte 3
}
inline constexpr tm_uint32 ConvertColor(const AZ::Color& color)
{
return ConvertColor(color.ToU32());
}
}
#define AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category) (static_cast<uint32_t>(1) << static_cast<uint32_t>(category))
// Helpers
#define AZ_INTERNAL_PROF_MEMORY_CAT_TO_FLAGS(category) (AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category) | \
AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(AZ::Debug::ProfileCategory::MemoryReserved))
#define AZ_INTERNAL_PROF_VERIFY_INTERVAL_ID(id) static_assert(sizeof(id) <= sizeof(tm_uint64), "Interval id must be a unique value no larger than 64-bits")
#define AZ_INTERNAL_PROF_TM_FUNC_VERIFY_CAT(category, flags) \
tmFunction(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), flags)
#define AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, flags, ...) \
tmZone(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), flags, __VA_ARGS__)
// AZ_PROFILE_FUNCTION
#define AZ_PROFILE_FUNCTION(category) \
AZ_INTERNAL_PROF_TM_FUNC_VERIFY_CAT(category, TMZF_NONE)
#define AZ_PROFILE_FUNCTION_STALL(category) \
AZ_INTERNAL_PROF_TM_FUNC_VERIFY_CAT(category, TMZF_STALL)
#define AZ_PROFILE_FUNCTION_IDLE(category) \
AZ_INTERNAL_PROF_TM_FUNC_VERIFY_CAT(category, TMZF_IDLE)
// AZ_PROFILE_SCOPE
#define AZ_PROFILE_SCOPE(category, name) \
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_NONE, name)
#define AZ_PROFILE_SCOPE_STALL(category, name) \
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_STALL, name)
#define AZ_PROFILE_SCOPE_IDLE(category, name) \
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_IDLE, name)
// AZ_PROFILE_SCOPE_DYNAMIC
// For profiling events with dynamic scope names
// Note: the first variable argument must be a const format string
// Usage: AZ_PROFILE_SCOPE_DYNAMIC(AZ::Debug::ProfileCategory, <printf style const format string>, format args...)
#define AZ_PROFILE_SCOPE_DYNAMIC(category, ...) \
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_NONE, __VA_ARGS__)
#define AZ_PROFILE_SCOPE_STALL_DYNAMIC(category, ...) \
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_STALL, __VA_ARGS__)
#define AZ_PROFILE_SCOPE_IDLE_DYNAMIC(category, ...) \
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_IDLE, __VA_ARGS__)
// AZ_PROFILE_EVENT_BEGIN/END
// For profiling events that do not start and stop in the same scope (they MUST start/stop on the same thread)
// ALWAYS favor using scoped events (AZ_PROFILE_FUNCTION, AZ_PROFILE_SCOPE) as debugging an unmatched begin/end can be challenging
#define AZ_PROFILE_EVENT_BEGIN(category, name) \
tmEnter(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), TMZF_NONE, name)
#define AZ_PROFILE_EVENT_END(category) \
tmLeave(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category))
// AZ_PROFILE_INTERVAL (mapped to Telemetry Timespan APIs)
// Note: using C-style casting as we allow either pointers or integral types as IDs
#define AZ_PROFILE_INTERVAL_START(category, id, ...) \
AZ_INTERNAL_PROF_VERIFY_INTERVAL_ID(id); \
tmBeginTimeSpan(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), (tm_uint64)(id), TMZF_NONE, __VA_ARGS__)
#define AZ_PROFILE_INTERVAL_START_COLORED(category, id, color, ...) \
AZ_INTERNAL_PROF_VERIFY_INTERVAL_ID(id); \
tmBeginColoredTimeSpan(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), (tm_uint64)(id), 0, ProfileTelemetryInternal::ConvertColor(color), TMZF_NONE, __VA_ARGS__)
#define AZ_PROFILE_INTERVAL_END(category, id) \
AZ_INTERNAL_PROF_VERIFY_INTERVAL_ID(id); \
tmEndTimeSpan(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), (tm_uint64)(id))
// AZ_PROFILE_INTERVAL_SCOPED
// Scoped interval event that implicitly starts and ends in the same scope
// Note: using C-style casting as we allow either pointers or integral types as IDs
// Note: the first variable argument must be a const format string
// Usage: AZ_PROFILE_INTERVAL_SCOPED(AZ::Debug::ProfileCategory, <unique interval id>, <printf style const format string>, format args...)
#define AZ_PROFILE_INTERVAL_SCOPED(category, id, ...) \
AZ_INTERNAL_PROF_VERIFY_INTERVAL_ID(id); \
tmTimeSpan(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), (tm_uint64)(id), TM_MIN_TIME_SPAN_TRACK_ID + static_cast<AZ::Debug::ProfileCategoryPrimitiveType>(category), 0, TMZF_NONE, __VA_ARGS__)
// AZ_PROFILE_DATAPOINT (mapped to tmPlot APIs)
// Note: data points can have static or dynamic names, if using a dynamic name the first variable argument must be a const format string
// Usage: AZ_PROFILE_DATAPOINT(AZ::Debug::ProfileCategory, <printf style const format string>, format args...)
#define AZ_PROFILE_DATAPOINT(category, value, ...) \
tmPlot(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), TM_PLOT_UNITS_REAL, TM_PLOT_DRAW_LINE, static_cast<double>(value), __VA_ARGS__)
#define AZ_PROFILE_DATAPOINT_PERCENT(category, value, ...) \
tmPlot(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), TM_PLOT_UNITS_PERCENTAGE_DIRECT, TM_PLOT_DRAW_LINE, static_cast<double>(value), __VA_ARGS__)
// AZ_PROFILE_MEMORY_ALLOC
#define AZ_PROFILE_MEMORY_ALLOC(category, address, size, context) \
tmAlloc(AZ_INTERNAL_PROF_MEMORY_CAT_TO_FLAGS(category), address, size, context)
#define AZ_PROFILE_MEMORY_ALLOC_EX(category, filename, lineNumber, address, size, context) \
tmAllocEx(AZ_INTERNAL_PROF_MEMORY_CAT_TO_FLAGS(category), filename, lineNumber, address, size, context)
#define AZ_PROFILE_MEMORY_FREE(category, address) \
tmFree(AZ_INTERNAL_PROF_MEMORY_CAT_TO_FLAGS(category), address)
#define AZ_PROFILE_MEMORY_FREE_EX(category, filename, lineNumber, address) \
tmFreeEx(AZ_INTERNAL_PROF_MEMORY_CAT_TO_FLAGS(category), filename, lineNumber, address)
#endif
@@ -1,49 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#ifdef AZ_PROFILE_TELEMETRY
#include <AzCore/base.h>
#include <AzCore/Debug/Profiler.h>
#include <AzCore/Debug/ProfilerBus.h>
#include <AzCore/EBus/EBus.h>
struct tm_api;
namespace RADTelemetry
{
class ProfileTelemetryRequests
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
virtual ~ProfileTelemetryRequests() = default;
virtual void ToggleEnabled() = 0;
virtual void SetAddress(const char* address, AZ::u16 port) = 0;
virtual void SetCaptureMask(AZ::Debug::ProfileCategoryPrimitiveType mask) = 0;
virtual void SetFrameAdvanceType(AZ::Debug::ProfileFrameAdvanceType type) = 0;
virtual AZ::Debug::ProfileCategoryPrimitiveType GetCaptureMask() = 0;
virtual AZ::Debug::ProfileCategoryPrimitiveType GetDefaultCaptureMask() = 0;
virtual tm_api* GetApiInstance() = 0;
};
using ProfileTelemetryRequestBus = AZ::EBus<ProfileTelemetryRequests>;
}
#endif
@@ -11,7 +11,3 @@
# NOTE: functions in cmake are global, therefore adding functions to this file
# is being avoided to prevent overriding functions declared in other targets platfrom
# specific cmake files
if(LY_RAD_TELEMETRY_ENABLED)
set(LY_COMPILE_DEFINITIONS PUBLIC AZ_PROFILE_TELEMETRY)
endif()
@@ -11,7 +11,3 @@
# NOTE: functions in cmake are global, therefore adding functions to this file
# is being avoided to prevent overriding functions declared in other targets platfrom
# specific cmake files
if(LY_RAD_TELEMETRY_ENABLED)
set(LY_COMPILE_DEFINITIONS PUBLIC AZ_PROFILE_TELEMETRY)
endif()
@@ -5,7 +5,3 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
if(LY_RAD_TELEMETRY_ENABLED)
set(LY_COMPILE_DEFINITIONS PUBLIC AZ_PROFILE_TELEMETRY)
endif()
@@ -83,7 +83,7 @@ namespace UnitTest
int ChildFunction0(int numIterations, int sleepTimeMilliseconds)
{
AZ_PROFILE_TIMER("UnitTest", CHILD_TIMER_STAT0);
AZ_PROFILE_SCOPE(UnitTest, CHILD_TIMER_STAT0);
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(sleepTimeMilliseconds));
int result = 5;
for (int i = 0; i < numIterations; ++i)
@@ -95,7 +95,7 @@ namespace UnitTest
int ChildFunction1(int numIterations, int sleepTimeMilliseconds)
{
AZ_PROFILE_TIMER("UnitTest", CHILD_TIMER_STAT1);
AZ_PROFILE_SCOPE(UnitTest, CHILD_TIMER_STAT1);
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(sleepTimeMilliseconds));
int result = 5;
for (int i = 0; i < numIterations; ++i)
@@ -107,7 +107,7 @@ namespace UnitTest
int ParentFunction(int numIterations, int sleepTimeMilliseconds)
{
AZ_PROFILE_TIMER("UnitTest", PARENT_TIMER_STAT);
AZ_PROFILE_SCOPE(UnitTest, PARENT_TIMER_STAT);
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(sleepTimeMilliseconds));
int result = 0;
result += ChildFunction0(numIterations, sleepTimeMilliseconds);
@@ -198,9 +198,10 @@ namespace UnitTest
AZStd::unique_ptr<Statistics::TimeDataStatisticsManager> m_statsManager;
};//class TimeDataStatisticsManagerTest
TEST_F(TimeDataStatisticsManagerTest, Test)
// TODO:BUDGETS disabled until profiler budgets system comes online
// TEST_F(TimeDataStatisticsManagerTest, Test)
{
run();
// run();
}
//End of all Tests of TimeDataStatisticsManagerTest