Incorporate Tracy profiler as 3p

master
Beq 2021-03-12 18:23:53 +00:00
parent 52abd2d9a5
commit d640123781
15 changed files with 177 additions and 12 deletions

View File

@ -76,6 +76,15 @@ endif (USE_AVX_OPTIMIZATION)
add_subdirectory(cmake)
# <FS:Beq> Tracy Profiler support
option(USE_TRACY_PROFILER "Tracy Profiler support" OFF)
if (USE_TRACY_PROFILER)
message(STATUS "Compiling with Tracy profiler")
else (USE_TRACY_PROFILER)
message(STATUS "Compiling without Tracy profiler")
endif (USE_TRACY_PROFILER)
# </FS:Beq> Tracy Profiler support
add_subdirectory(${LIBS_OPEN_PREFIX}llaudio)
add_subdirectory(${LIBS_OPEN_PREFIX}llappearance)
add_subdirectory(${LIBS_OPEN_PREFIX}llcharacter)

View File

@ -139,7 +139,11 @@ if (WINDOWS)
# /arch:SSE2
/fp:fast
)
# <FS:Beq> Add Tracy profiler support
if (USE_TRACY_PROFILER)
add_definitions( /DTRACY_ENABLE /DTRACY_NO_FASTTIMERS )
endif()
# </FS:Beq>
# Nicky: x64 implies SSE2
if( ADDRESS_SIZE EQUAL 32 )
add_definitions( /arch:SSE2 )

View File

@ -88,6 +88,7 @@ set(cmake_SOURCE_FILES
PulseAudio.cmake
Python.cmake
TemplateCheck.cmake
Tracy.cmake
Tut.cmake
UI.cmake
UnixInstall.cmake

View File

@ -4,12 +4,21 @@ include(APR)
include(Boost)
include(EXPAT)
include(ZLIB)
include(Tracy) # <FS:Beq> Tracy profiler
# <FS:Beq> Add Tracy profiler support
#set(LLCOMMON_INCLUDE_DIRS
# ${LIBS_OPEN_DIR}/llcommon
# ${APRUTIL_INCLUDE_DIR}
# ${APR_INCLUDE_DIR}
# )
set(LLCOMMON_INCLUDE_DIRS
${LIBS_OPEN_DIR}/llcommon
${APRUTIL_INCLUDE_DIR}
${APR_INCLUDE_DIR}
${TRACY_INCLUDE_DIR}
)
# </FS:Beq>
set(LLCOMMON_SYSTEM_INCLUDE_DIRS
${Boost_INCLUDE_DIRS}
)

15
indra/cmake/Tracy.cmake Normal file
View File

@ -0,0 +1,15 @@
# Tracy Profiler support.
if (USE_TRACY_PROFILER)
include(Prebuilt)
use_prebuilt_binary(Tracy)
if (WINDOWS)
# set(TRACY_LIBRARIES
# ${ARCH_PREBUILT_DIRS_RELEASE}/Tracy.lib
add_definitions(-DTRACY_ENABLE=1 -DTRACY_NO_FASTTIMERS)
set(TRACY_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/tracy)
elseif (DARWIN)
message(FATAL_ERROR "Tracy is not yet implemented in FS for OSX.")
else (WINDOWS)
message(FATAL_ERROR "Tracy is not yet implemented in FS for Linux.")
endif (WINDOWS)
endif (USE_TRACY_PROFILER)

View File

@ -256,6 +256,10 @@ set(llcommon_HEADER_FILES
)
# <FS:ND> Add all nd* files. memory pool, intrinsics, ...
# <FS:Beq> Tracy Profiler support
if (USE_TRACY_PROFILER)
list(APPEND llcommon_SOURCE_FILES FSTracyClient.cpp)
endif()
SET( llcommon_ND_SOURCE_FILES
nd/ndexceptions.cpp

View File

@ -0,0 +1,58 @@
//
// Tracy profiler
// ----------------
//
// For fast integration, compile and
// link with this source file (and none
// other) in your executable (or in the
// main DLL / shared object on multi-DLL
// projects).
//
// Define TRACY_ENABLE to enable profiler.
// #define __CYGWIN__
#include "common/TracySystem.cpp"
#ifdef TRACY_ENABLE
#ifdef _MSC_VER
# pragma warning(push, 0)
#endif
#include "common/tracy_lz4.cpp"
#include "client/TracyProfiler.cpp"
#include "client/TracyCallstack.cpp"
#include "client/TracySysTime.cpp"
#ifndef __CYGWIN__
#define __CYGWIN__
#include "client/TracySysTrace.cpp"
#undef __CYGWIN__
#else
#include "client/TracySysTrace.cpp"
#endif
#include "common/TracySocket.cpp"
#include "client/tracy_rpmalloc.cpp"
#include "client/TracyDxt1.cpp"
#if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6
# include "libbacktrace/alloc.cpp"
# include "libbacktrace/dwarf.cpp"
# include "libbacktrace/fileline.cpp"
# include "libbacktrace/mmapio.cpp"
# include "libbacktrace/posix.cpp"
# include "libbacktrace/sort.cpp"
# include "libbacktrace/state.cpp"
# if TRACY_HAS_CALLSTACK == 4
# include "libbacktrace/macho.cpp"
# else
# include "libbacktrace/elf.cpp"
# endif
#endif
#ifdef _MSC_VER
# pragma comment(lib, "ws2_32.lib")
# pragma comment(lib, "dbghelp.lib")
# pragma warning(pop)
#endif
#endif

View File

@ -54,13 +54,20 @@
#else
#error "architecture not supported"
#endif
// <FS:Beq> are we actively profiling?
#ifdef TRACY_ENABLE
namespace LLTrace
{
bool active{false};
}
// </FS:Beq>
#endif
namespace LLTrace
{
//////////////////////////////////////////////////////////////////////////////
// statics
bool BlockTimer::sLog = false;
std::string BlockTimer::sLogName = "";
bool BlockTimer::sMetricLog = false;

View File

@ -38,7 +38,31 @@
#define LL_FAST_TIMER_ON 1
#define LL_FASTTIMER_USE_RDTSC 1
#define LL_RECORD_BLOCK_TIME(timer_stat) const LLTrace::BlockTimer& LL_GLUE_TOKENS(block_time_recorder, __LINE__)(LLTrace::timeThisBlock(timer_stat)); (void)LL_GLUE_TOKENS(block_time_recorder, __LINE__);
// <FS:Beq> Add Tracy profiler support
// #define LL_RECORD_BLOCK_TIME(timer_stat) \
// const LLTrace::BlockTimer& LL_GLUE_TOKENS(block_time_recorder, __LINE__)(LLTrace::timeThisBlock(timer_stat)); (void)LL_GLUE_TOKENS(block_time_recorder, __LINE__);
#ifdef TRACY_ENABLE
#include "Tracy.hpp"
namespace LLTrace
{
extern bool active;
}
// #undef TRACY_NO_FASTTIMERS // Uncomment if you want FASTTIMERS as well.
#ifdef TRACY_NO_FASTTIMERS
#define LL_RECORD_BLOCK_TIME(timer_stat) \
ZoneNamedN( ___tracy_scoped_zone, #timer_stat , LLTrace::active);
#else // TRACY_NO_FASTTIMERS
#define LL_RECORD_BLOCK_TIME(timer_stat) \
ZoneNamedN( ___tracy_scoped_zone, #timer_stat , LLTrace::active); \
const LLTrace::BlockTimer& LL_GLUE_TOKENS(block_time_recorder, __LINE__)(LLTrace::timeThisBlock(timer_stat)); (void)LL_GLUE_TOKENS(block_time_recorder, __LINE__);
#endif // TRACY_NO_FASTTIMERS
#else // TRACY_ENABLE
#define LL_RECORD_BLOCK_TIME(timer_stat) \
const LLTrace::BlockTimer& LL_GLUE_TOKENS(block_time_recorder, __LINE__)(LLTrace::timeThisBlock(timer_stat)); (void)LL_GLUE_TOKENS(block_time_recorder, __LINE__);
#endif // TRACY_ENABLE
// </FS:Beq>
namespace LLTrace
{

View File

@ -24628,6 +24628,17 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<integer>0</integer>
</map>
<key>FSTracyEnableWhenConnected</key>
<map>
<key>Comment</key>
<string>Enable profiling as soon as a server connects</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
</map>
<key>FSFilterGrowlKeywordDuplicateIMs</key>
<map>
<key>Comment</key>

View File

@ -1652,7 +1652,19 @@ bool LLAppViewer::doFrame()
{
LLEventPump& mainloop(LLEventPumps::instance().obtain("mainloop"));
LLSD newFrame;
// <FS:Beq> Tracy enabling
static bool one_time{false};
static LLCachedControl<bool> tracy_enable_when_connected(gSavedSettings, "FSTracyEnableWhenConnected");
if( !one_time && (gFrameCount % 10 == 0) )
{
if(!LLTrace::active && tracy_enable_when_connected && TracyIsConnected)
{
LLTrace::active = true;
one_time=true; // prevent reset race if we disable manually.
LL_INFOS() << "Tracy profiler or collector connected" << LL_ENDL;
}
}
// </FS:Beq>
// <FS:Ansariel> MaxFPS Viewer-Chui merge error
LLTimer periodicRenderingTimer;
BOOL restore_rendering_masks = FALSE;
@ -1953,7 +1965,7 @@ bool LLAppViewer::doFrame()
LL_INFOS() << "Exiting main_loop" << LL_ENDL;
}
FrameMark; // <FS:Beq> Tracy support delineate Frame
return ! LLApp::isRunning();
}

View File

@ -1427,8 +1427,9 @@ void render_ui(F32 zoom_factor, int subfield)
// Finalize scene
gPipeline.renderFinalize();
LL_RECORD_BLOCK_TIME(FTM_RENDER_HUD);
render_hud_elements();
{// <FS:Beq/> give unique scope
LL_RECORD_BLOCK_TIME(FTM_RENDER_HUD);
render_hud_elements();
// [RLVa:KB] - Checked: RLVa-2.2 (@setoverlay)
if (RlvActions::hasBehaviour(RLV_BHVR_SETOVERLAY))
{
@ -1436,7 +1437,7 @@ void render_ui(F32 zoom_factor, int subfield)
}
// [/RLVa:KB]
render_hud_attachments();
} // <FS:Beq/> unique scope
LLGLSDefault gls_default;
LLGLSUIDefault gls_ui;
{

View File

@ -6349,9 +6349,10 @@ static LLTrace::BlockTimerStatHandle FTM_REBUILD_MESH_FLUSH("Flush Mesh");
void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
{
llassert(group);
LL_RECORD_BLOCK_TIME(FTM_REBUILD_VOLUME_VB);// <FS:Beq> move out one scope (but are these even useful as dupes?)
if (group && group->hasState(LLSpatialGroup::MESH_DIRTY) && !group->hasState(LLSpatialGroup::GEOM_DIRTY))
{
LL_RECORD_BLOCK_TIME(FTM_REBUILD_VOLUME_VB);
// LL_RECORD_BLOCK_TIME(FTM_REBUILD_VOLUME_VB);// <FS:Beq> move out one scope (but are these even useful as dupes?)
LL_RECORD_BLOCK_TIME(FTM_REBUILD_VOLUME_GEN_DRAW_INFO); //make sure getgeometryvolume shows up in the right place in timers
group->mBuilt = 1.f;

View File

@ -4753,7 +4753,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
{
LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred");
LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY);
// LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY);<FS:Beq> remove duplicate zone scope
LL_RECORD_BLOCK_TIME(FTM_DEFERRED_POOLS);

View File

@ -39,6 +39,7 @@ WANTS_SINGLEGRID=$FALSE
WANTS_AVX=$FALSE
WANTS_AVX2=$FALSE
WANTS_TESTBUILD=$FALSE
WANTS_TRACY=$FALSE
WANTS_BUILD=$FALSE
WANTS_CRASHREPORTING=$FALSE
TARGET_PLATFORM="darwin" # darwin, windows, linux
@ -77,6 +78,7 @@ showUsage()
echo " --singlegrid <login_uri> : Build for single grid usage (Requires --opensim)"
echo " --avx : Build with Advanced Vector Extensions"
echo " --avx2 : Build with Advanced Vector Extensions 2"
echo " --tracy : Build with Tracy Profiler support"
echo " --crashreporting : Build with crash reporting enabled"
echo " --testbuild <days> : Create time-limited test build (build date + <days>)"
echo " --platform <platform> : Build for specified platform (darwin | windows | linux)"
@ -92,7 +94,7 @@ getArgs()
# $* = the options passed in from main
{
if [ $# -gt 0 ]; then
while getoptex "clean build config version package no-package fmodstudio openal ninja vscode jobs: platform: kdu opensim no-opensim singlegrid: avx avx2 crashreporting testbuild: help chan: btype:" "$@" ; do
while getoptex "clean build config version package no-package fmodstudio openal ninja vscode jobs: platform: kdu opensim no-opensim singlegrid: avx avx2 tracy crashreporting testbuild: help chan: btype:" "$@" ; do
#ensure options are valid
if [ -z "$OPTOPT" ] ; then
@ -119,6 +121,7 @@ getArgs()
;;
avx) WANTS_AVX=$TRUE;;
avx2) WANTS_AVX2=$TRUE;;
tracy) WANTS_TRACY=$TRUE;;
crashreporting) WANTS_CRASHREPORTING=$TRUE;;
testbuild) WANTS_TESTBUILD=$TRUE
TESTBUILD_PERIOD="$OPTARG"
@ -308,6 +311,7 @@ else
fi
echo -e " AVX: `b2a $WANTS_AVX`" | tee -a $LOG
echo -e " AVX2: `b2a $WANTS_AVX2`" | tee -a $LOG
echo -e " TRACY: `b2a $WANTS_TRACY`" | tee -a $LOG
echo -e " CRASHREPORTING: `b2a $WANTS_CRASHREPORTING`" | tee -a $LOG
if [ $WANTS_TESTBUILD -eq $TRUE ] ; then
echo -e " TESTBUILD: `b2a $WANTS_TESTBUILD` ($TESTBUILD_PERIOD days)" | tee -a $LOG
@ -463,6 +467,11 @@ if [ $WANTS_CONFIG -eq $TRUE ] ; then
else
AVX2_OPTIMIZATION="-DUSE_AVX2_OPTIMIZATION:BOOL=OFF"
fi
if [ $WANTS_TRACY -eq $TRUE ] ; then
TRACY_PROFILER="-DUSE_TRACY_PROFILER:BOOL=ON"
else
TRACY_PROFILER="-DUSE_TRACY_PROFILER:BOOL=OFF"
fi
if [ $WANTS_TESTBUILD -eq $TRUE ] ; then
TESTBUILD="-DTESTBUILD:BOOL=ON -DTESTBUILDPERIOD:STRING=$TESTBUILD_PERIOD"
else
@ -531,7 +540,7 @@ if [ $WANTS_CONFIG -eq $TRUE ] ; then
UNATTENDED="-DUNATTENDED=ON"
fi
cmake -G "$TARGET" ../indra $CHANNEL ${GITHASH} $FMODSTUDIO $OPENAL $KDU $OPENSIM $SINGLEGRID $AVX_OPTIMIZATION $AVX2_OPTIMIZATION $TESTBUILD $PACKAGE \
cmake -G "$TARGET" ../indra $CHANNEL ${GITHASH} $FMODSTUDIO $OPENAL $KDU $OPENSIM $SINGLEGRID $AVX_OPTIMIZATION $AVX2_OPTIMIZATION $TRACY_PROFILER $TESTBUILD $PACKAGE \
$UNATTENDED -DLL_TESTS:BOOL=OFF -DADDRESS_SIZE:STRING=$AUTOBUILD_ADDRSIZE -DCMAKE_BUILD_TYPE:STRING=$BTYPE \
$CRASH_REPORTING -DVIEWER_SYMBOL_FILE:STRING="${VIEWER_SYMBOL_FILE:-}" -DROOT_PROJECT_NAME:STRING=Firestorm $LL_ARGS_PASSTHRU ${VSCODE_FLAGS:-} | tee $LOG