Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • alchemy/viewer
  • Miezhiko/alchemy-next
  • JennaHuntsman/xdg-integration
  • logue/alchemy-next
  • FelixWolf/alchemy-viewer
  • XenHat/xdg-integration
6 results
Show changes
Commits on Source (5)
......@@ -54,6 +54,11 @@ FetchContent_Declare(
GIT_REPOSITORY https://git.alchemyviewer.org/alchemy/mirrors/abseil-cpp.git
GIT_TAG 9a7e447c511dae7276ab65fde4d04f6ed52b39c9
)
FetchContent_Declare(
readerwriterqueue
GIT_REPOSITORY https://github.com/cameron314/readerwriterqueue
GIT_TAG v1.0.5
)
# This is a hack because absl has dumb cmake
set(OLD_BUILD_TEST ${BUILD_TESTING})
......@@ -94,5 +99,7 @@ set(JSON_Install OFF CACHE INTERNAL "")
set(JSON_BuildTests OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(nlohmann_json)
FetchContent_MakeAvailable(readerwriterqueue)
unset(CMAKE_FOLDER)
unset(CMAKE_POSITION_INDEPENDENT_CODE)
......@@ -467,8 +467,9 @@ S32 LLQueuedThread::processNextRequest()
yield();
}
}
#ifndef LL_RELEASE_FOR_DOWNLOAD
LLTrace::get_thread_recorder()->pushToParent();
#endif
}
S32 pending = getPending();
......@@ -497,7 +498,9 @@ void LLQueuedThread::run()
if (isQuitting())
{
#ifndef LL_RELEASE_FOR_DOWNLOAD
LLTrace::get_thread_recorder()->pushToParent();
#endif
endThread();
break;
}
......
......@@ -138,8 +138,10 @@ void LLThread::threadRun()
// this is the first point at which we're actually running in the new thread
mID = currentID();
#ifndef LL_RELEASE_FOR_DOWNLOAD
// for now, hard code all LLThreads to report to single master thread recorder, which is known to be running on main thread
mRecorder = new LLTrace::ThreadRecorder(*LLTrace::get_master_thread_recorder());
#endif
// Run the user supplied function
do
......@@ -164,9 +166,10 @@ void LLThread::threadRun()
//LL_INFOS() << "LLThread::staticRun() Exiting: " << threadp->mName << LL_ENDL;
#ifndef LL_RELEASE_FOR_DOWNLOAD
delete mRecorder;
mRecorder = NULL;
#endif
// We're done with the run function, this thread is done executing now.
//NB: we are using this flag to sync across threads...we really need memory barriers here
......@@ -179,8 +182,10 @@ LLThread::LLThread(const std::string& name, apr_pool_t *poolp) :
mPaused(FALSE),
mName(name),
mThreadp(NULL),
mStatus(STOPPED),
mRecorder(NULL)
mStatus(STOPPED)
#ifndef LL_RELEASE_FOR_DOWNLOAD
, mRecorder(NULL)
#endif
{
mRunCondition = new LLCondition();
mDataLock = new LLMutex();
......@@ -250,9 +255,10 @@ void LLThread::shutdown()
#else
pthread_cancel(mNativeHandle);
#endif
#ifndef LL_RELEASE_FOR_DOWNLOAD
delete mRecorder;
mRecorder = NULL;
#endif
mStatus = STOPPED;
return;
}
......@@ -265,7 +271,7 @@ void LLThread::shutdown()
delete mDataLock;
mDataLock = NULL;
#ifndef LL_RELEASE_FOR_DOWNLOAD
if (mRecorder)
{
// missed chance to properly shut down recorder (needs to be done in thread context)
......@@ -273,6 +279,7 @@ void LLThread::shutdown()
// so just leak it and remove it from parent
LLTrace::get_master_thread_recorder()->removeChildRecorder(mRecorder);
}
#endif
}
......
......@@ -106,7 +106,9 @@ class LL_COMMON_API LLThread
std::thread *mThreadp;
EThreadStatus mStatus;
id_t mID;
#ifndef LL_RELEASE_FOR_DOWNLOAD
LLTrace::ThreadRecorder* mRecorder;
#endif
//a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used.
//Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes.
......
......@@ -79,6 +79,7 @@ target_link_libraries(llimage
${JPEG_LIBRARIES}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
readerwriterqueue
)
if(${CMAKE_VERSION} VERSION_GREATER "3.15.0")
......@@ -90,6 +91,13 @@ endif()
# Add tests
if (LL_TESTS)
set_source_files_properties(
llimageworker.cpp
PROPERTIES
LL_TEST_ADDITIONAL_LIBRARIES "${LLPRIMITIVE_LIBRARIES};readerwriterqueue"
)
SET(llimage_TEST_SOURCE_FILES
llimageworker.cpp
)
......
......@@ -28,54 +28,49 @@
#include "llimageworker.h"
#include "llimagedxt.h"
#include <readerwriterqueue.h>
std::atomic< U32 > sImageThreads;
std::atomic< U32 > sImageThreads = 0;
class PoolWorkerThread : public LLThread
{
public:
PoolWorkerThread(std::string name) : LLThread(name),
mCurrentRequest(NULL)
PoolWorkerThread(std::string name) : LLThread(name), mRequestQueue(30)
{
}
virtual void run()
{
while (!isQuitting())
{
auto *pReq = mCurrentRequest.exchange(nullptr);
if (pReq)
pReq->processRequestIntern();
checkPause();
checkPause();
LLImageDecodeThread::ImageRequest* req = nullptr;
while (!isQuitting() && mRequestQueue.try_dequeue(req))
{
if (req)
{
req->processRequestIntern();
}
}
}
}
bool isBusy()
{
auto *pReq = mCurrentRequest.load();
if (!pReq)
return false;
auto status = pReq->getStatus();
return status == LLQueuedThread::STATUS_QUEUED || status == LLQueuedThread::STATUS_INPROGRESS;
}
bool runCondition()
{
return mCurrentRequest != NULL;
{
return mRequestQueue.size_approx() > 0;
}
bool setRequest(LLImageDecodeThread::ImageRequest* req)
{
LLImageDecodeThread::ImageRequest* pOld{ nullptr };
bool bSuccess = mCurrentRequest.compare_exchange_strong(pOld, req);
bool bSuccess = mRequestQueue.try_enqueue(req);
wake();
return bSuccess;
}
private:
std::atomic< LLImageDecodeThread::ImageRequest * > mCurrentRequest;
moodycamel::ReaderWriterQueue<LLImageDecodeThread::ImageRequest*> mRequestQueue;
};
//----------------------------------------------------------------------------
......@@ -240,7 +235,7 @@ bool LLImageDecodeThread::ImageRequest::processRequest()
return processRequestIntern();
// Try to dispatch to a new thread, if this isn't possible decode on this thread
if (!mQueue->enqueRequest(this))
if (!mQueue || !mQueue->enqueRequest(this))
return processRequestIntern();
return true;
}
......@@ -344,7 +339,7 @@ bool LLImageDecodeThread::enqueRequest(ImageRequest * req)
mLastPoolAllocation = 0;
}
auto& thread = mThreadPool[mLastPoolAllocation++];
if (!thread->isBusy() && thread->setRequest(req))
if (thread->setRequest(req))
{
return true;
}
......
......@@ -143,7 +143,7 @@ namespace tut
mRequest = new LLImageDecodeThread::ImageRequest(0, 0,
LLQueuedThread::PRIORITY_NORMAL, 0, FALSE,
new responder_test(&done));
new responder_test(&done), nullptr);
}
~imagerequest_test()
{
......@@ -193,7 +193,7 @@ namespace tut
void imagedecodethread_object_t::test<1>()
{
// Test a *non threaded* instance of the class
mThread = new LLImageDecodeThread(false);
mThread = new LLImageDecodeThread(false, 1);
ensure("LLImageDecodeThread: non threaded constructor failed", mThread != NULL);
// Test that we start with an empty list right at creation
ensure("LLImageDecodeThread: non threaded init state incorrect", mThread->tut_size() == 0);
......@@ -216,7 +216,7 @@ namespace tut
void imagedecodethread_object_t::test<2>()
{
// Test a *threaded* instance of the class
mThread = new LLImageDecodeThread(true);
mThread = new LLImageDecodeThread(true, 1);
ensure("LLImageDecodeThread: threaded constructor failed", mThread != NULL);
// Test that we start with an empty list right at creation
ensure("LLImageDecodeThread: threaded init state incorrect", mThread->tut_size() == 0);
......
......@@ -2071,14 +2071,17 @@ bool LLTextureFetchWorker::doWork(S32 param)
// virtual
void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response)
{
#ifndef LL_RELEASE_FOR_DOWNLOAD
static LLCachedControl<bool> log_to_viewer_log(gSavedSettings, "LogTextureDownloadsToViewerLog", false);
static LLCachedControl<bool> log_to_sim(gSavedSettings, "LogTextureDownloadsToSimulator", false);
#endif
static LLCachedControl<bool> log_texture_traffic(gSavedSettings, "LogTextureNetworkTraffic", false) ;
LLMutexLock lock(&mWorkMutex); // +Mw
mHttpActive = false;
#ifndef LL_RELEASE_FOR_DOWNLOAD
if (log_to_viewer_log || log_to_sim)
{
mFetcher->mTextureInfo.setRequestStartTime(mID, mMetricsStartTime.value());
......@@ -2087,6 +2090,7 @@ void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRe
mFetcher->mTextureInfo.setRequestOffset(mID, mRequestedOffset);
mFetcher->mTextureInfo.setRequestCompleteTimeAndLog(mID, LLTimer::getTotalTime());
}
#endif
static LLCachedControl<F32> fake_failure_rate(gSavedSettings, "TextureFetchFakeFailureRate", 0.0f);
F32 rand_val = ll_frand();
......@@ -2633,11 +2637,15 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
mFetchDebugger(NULL),
mFetchSource(LLTextureFetch::FROM_ALL),
mOriginFetchSource(LLTextureFetch::FROM_ALL),
mFetcherLocked(FALSE),
mTextureInfoMainThread(false)
mFetcherLocked(FALSE)
#ifndef LL_RELEASE_FOR_DOWNLOAD
, mTextureInfoMainThread(false)
#endif
{
mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
#ifndef LL_RELEASE_FOR_DOWNLOAD
mTextureInfo.setLogging(true);
#endif
LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp());
mHttpRequest = new LLCore::HttpRequest;
......@@ -3182,7 +3190,9 @@ void LLTextureFetch::shutDownImageDecodeThread()
// Threads: Ttf
void LLTextureFetch::startThread()
{
#ifndef LL_RELEASE_FOR_DOWNLOAD
mTextureInfo.startRecording();
#endif
}
// Threads: Ttf
......@@ -3193,8 +3203,9 @@ void LLTextureFetch::endThread()
<< ", ResWaits: " << mTotalResourceWaitCount
<< ", TotalHTTPReq: " << getTotalNumHTTPRequests()
<< LL_ENDL;
#ifndef LL_RELEASE_FOR_DOWNLOAD
mTextureInfo.stopRecording();
#endif
}
// Threads: Ttf
......@@ -3340,6 +3351,7 @@ void LLTextureFetch::sendRequestListToSimulators()
// LL_INFOS(LOG_TXT) << "IMAGE REQUEST: " << req->mID << " Discard: " << req->mDesiredDiscard
// << " Packet: " << packet << " Priority: " << req->mImagePriority << LL_ENDL;
#ifndef LL_RELEASE_FOR_DOWNLOAD
static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog", false);
static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator", false);
if (log_to_viewer_log || log_to_sim)
......@@ -3349,6 +3361,7 @@ void LLTextureFetch::sendRequestListToSimulators()
mTextureInfo.setRequestSize(req->mID, 0);
mTextureInfo.setRequestType(req->mID, LLTextureInfoDetails::REQUEST_TYPE_UDP);
}
#endif
req->lockWorkMutex(); // +Mw
req->mSentRequest = LLTextureFetchWorker::SENT_SIM;
......@@ -3587,6 +3600,7 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1
removeFromNetworkQueue(worker, true); // failsafe
}
#ifndef LL_RELEASE_FOR_DOWNLOAD
if (packet_num >= (worker->mTotalPackets - 1))
{
static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog", false);
......@@ -3599,6 +3613,7 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1
mTextureInfoMainThread.setRequestCompleteTimeAndLog(id, timeNow);
}
}
#endif
worker->unlockWorkMutex(); // -Mw
return res;
......
......@@ -334,8 +334,10 @@ class LLTextureFetch : public LLWorkerThread
cancel_queue_t mCancelQueue; // Mfnq
F32 mTextureBandwidth; // <none>
std::atomic<F32> mMaxBandwidth;
#ifndef LL_RELEASE_FOR_DOWNLOAD
LLTextureInfo mTextureInfo;
LLTextureInfo mTextureInfoMainThread;
#endif
// XXX possible delete
std::atomic<U32Bits> mHTTPTextureBits;
......
......@@ -1897,7 +1897,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
//don't spam them if they are getting flooded
if (check_offer_throttle(mFromName, true))
{
log_message = "<nolink>" + chatHistory_string + "</nolink> " + LLTrans::getString("InvOfferGaveYou") + " " + getSanitizedDescription() + LLTrans::getString(".");
log_message = chatHistory_string + " " + LLTrans::getString("InvOfferGaveYou") + " " + getSanitizedDescription() + LLTrans::getString(".");
LLSD args;
args["MESSAGE"] = log_message;
LLNotificationsUtil::add("SystemMessageTip", args);
......@@ -2117,7 +2117,7 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const
//don't spam user if flooded
if (check_offer_throttle(mFromName, true))
{
log_message = "<nolink>" + chatHistory_string + "</nolink> " + LLTrans::getString("InvOfferGaveYou") + " " + getSanitizedDescription() + LLTrans::getString(".");
log_message = chatHistory_string + " " + LLTrans::getString("InvOfferGaveYou") + " " + getSanitizedDescription() + LLTrans::getString(".");
LLSD args;
args["MESSAGE"] = log_message;
LLNotificationsUtil::add("SystemMessageTip", args);
......