From 20cd74917572eb3cce199ee5139396bb0d411caa Mon Sep 17 00:00:00 2001 From: Beq Date: Fri, 28 May 2021 02:22:53 +0100 Subject: [PATCH] Instrument threaded texture decode includes fix for timeout in slow decoded bakes --- indra/llimage/llimageworker.cpp | 34 +++++++++++++++++-- indra/llimagej2coj/llimagej2coj.cpp | 4 ++- indra/llkdu/llimagej2ckdu.cpp | 5 ++- indra/newview/llappviewer.cpp | 8 ++++- .../newview/skins/default/xui/en/strings.xml | 1 + 5 files changed, 46 insertions(+), 6 deletions(-) diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp index 0f44df12f2..53e02ee07f 100644 --- a/indra/llimage/llimageworker.cpp +++ b/indra/llimage/llimageworker.cpp @@ -25,7 +25,7 @@ */ #include "linden_common.h" - +#include "fstelemetry.h" // add telemetry support. #include "llimageworker.h" #include "llimagedxt.h" @@ -135,7 +135,12 @@ LLImageDecodeThread::~LLImageDecodeThread() // virtual S32 LLImageDecodeThread::update(F32 max_time_ms) { + FSZoneC(tracy::Color::Blue); // instrument image decodes LLMutexLock lock(mCreationMutex); + // instrument image decodes + { + FSZoneC(tracy::Color::Blue1); + // for (creation_list_t::iterator iter = mCreationList.begin(); iter != mCreationList.end(); ++iter) { @@ -155,13 +160,21 @@ S32 LLImageDecodeThread::update(F32 max_time_ms) } } mCreationList.clear(); + // instrument image decodes + } + { + FSZoneC(tracy::Color::Blue2); + // S32 res = LLQueuedThread::update(max_time_ms); + // FSPlot("img_decode_pending", (int64_t)res); // instrument image decodes return res; + } // instrument image decodes } LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(LLImageFormatted* image, U32 priority, S32 discard, BOOL needs_aux, Responder* responder) { + FSZoneC(tracy::Color::Orange); // instrument the image decode pipeline LLMutexLock lock(mCreationMutex); handle_t handle = generateHandle(); mCreationList.push_back(creation_info(handle, image, priority, discard, needs_aux, responder)); @@ -230,10 +243,19 @@ bool LLImageDecodeThread::ImageRequest::processRequest() bool LLImageDecodeThread::ImageRequest::processRequestIntern() { - const F32 decode_time_slice = .1f; + // allow longer timeout for async and add instrumentation + // const F32 decode_time_slice = .1f; + FSZoneC(tracy::Color::DarkOrange); + F32 decode_time_slice = .1f; + if(mFlags & FLAG_ASYNC) + { + decode_time_slice = 10.0f;// long time out as this is not an issue with async + } + // bool done = true; if (!mDecodedRaw && mFormattedImage.notNull()) { + FSZoneC(tracy::Color::DarkOrange1); // instrument the image decode pipeline // Decode primary channels if (mDecodedImageRaw.isNull()) { @@ -272,6 +294,7 @@ bool LLImageDecodeThread::ImageRequest::processRequestIntern() } if (done && mNeedsAux && !mDecodedAux && mFormattedImage.notNull()) { + FSZoneC(tracy::Color::DarkOrange2); // instrument the image decode pipeline // Decode aux channel if (!mDecodedImageAux) { @@ -282,7 +305,12 @@ bool LLImageDecodeThread::ImageRequest::processRequestIntern() done = mFormattedImage->decodeChannels(mDecodedImageAux, decode_time_slice, 4, 4); // 1ms mDecodedAux = done && mDecodedImageAux->getData(); } - + // report timeout on async thread (which leads to worker abort errors) + if(!done) + { + LL_WARNS("ImageDecode") << "Image decoding failed to complete with time slice=" << decode_time_slice << LL_ENDL; + } + // // Image thread pool from CoolVL if (mFlags & FLAG_ASYNC) { diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp index 0e605cf8b2..f46bcacb64 100644 --- a/indra/llimagej2coj/llimagej2coj.cpp +++ b/indra/llimagej2coj/llimagej2coj.cpp @@ -25,6 +25,7 @@ */ #include "linden_common.h" +#include "fstelemetry.h" // instrument image decodes #include "llimagej2coj.h" #define OPENJPEG2 @@ -258,10 +259,11 @@ bool LLImageJ2COJ::initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int block bool LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count) { // texture comment metadata reader + FSZone; // instrument image decodes U8* c_data = base.getData(); S32 c_size = base.getDataSize(); S32 position = 0; - + while (position < 1024 && position < (c_size - 7)) // the comment field should be in the first 1024 bytes. { if (c_data[position] == 0xff && c_data[position + 1] == 0x64) diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 300a60c551..e1e7863cca 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -32,7 +32,7 @@ #include "llpointer.h" #include "llmath.h" #include "llkdumem.h" - +#include "fstelemetry.h" // instrument image decodes #define kdu_xxxx "kdu_block_coding.h" #include "include_kdu_xxxx.h" @@ -287,6 +287,7 @@ void transfer_bytes(kdu_byte *dest, kdu_line_buf &src, int gap, int precision); // as well, when that still existed, with keep_codestream true and MODE_FAST. void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECodeStreamMode mode) { + FSZone; // instrument image decodes S32 data_size = base.getDataSize(); S32 max_bytes = (base.getMaxBytes() ? base.getMaxBytes() : data_size); @@ -436,6 +437,7 @@ bool LLImageJ2CKDU::initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int bloc // decodeImpl() usage matters for production. bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count, int discard_level, int* region) { + FSZone; // instrument image decodes base.resetLastError(); // *FIX: kdu calls our callback function if there's an error, and then bombs. @@ -519,6 +521,7 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco // Returns true to mean done, whether successful or not. bool LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count) { + FSZone; // instrument image decodes ECodeStreamMode mode = MODE_FAST; LLTimer decode_timer; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index e3d743e792..fc5ec952da 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1882,8 +1882,13 @@ bool LLAppViewer::doFrame() S32 work_pending = 0; S32 io_pending = 0; F32 max_time = llmin(gFrameIntervalSeconds.value() *10.f, 1.f); - + // instrument image decodes + { + FSZoneN("updateTextureThreads"); + // FSPlot("max_time_ms",max_time); + // work_pending += updateTextureThreads(max_time); + } // instrument image decodes { LL_RECORD_BLOCK_TIME(FTM_LFS); @@ -3822,6 +3827,7 @@ LLSD LLAppViewer::getViewerInfo() const // CPU info["CPU"] = gSysCPU.getCPUString(); info["MEMORY_MB"] = LLSD::Integer(gSysMemory.getPhysicalMemoryKB().valueInUnits()); + info["CONCURRENCY"] = LLSD::Integer((S32)boost::thread::hardware_concurrency()); // Add hardware concurrency to info // Moved hack adjustment to Windows memory size into llsys.cpp info["OS_VERSION"] = LLOSInfo::instance().getOSString(); info["GRAPHICS_CARD_VENDOR"] = ll_safe_string((const char*)(glGetString(GL_VENDOR))); diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 152d45b599..61377bc02a 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -51,6 +51,7 @@ You are in [REGION] CPU: [CPU] Memory: [MEMORY_MB] MB +Concurrency: [CONCURRENCY] OS Version: [OS_VERSION] Graphics Card Vendor: [GRAPHICS_CARD_VENDOR] Graphics Card: [GRAPHICS_CARD]