From 07201a5cfea304c87074ab0bc034bc2ee30456a1 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Fri, 5 Apr 2013 20:19:00 +0200 Subject: [PATCH] Add AICurlInterface::getNumHTTPRunning Replaces LLTextureFetch::getNumHTTPRequests. Returns AICurlInterface::Stats::running_handles. This is work in progress that temporarily doesn't compile because LLTextureFetch::getNumHTTPRequests is still being used somewhere. --- indra/llmessage/aicurl.cpp | 7 +++++++ indra/llmessage/aicurl.h | 5 +++++ indra/llmessage/aicurlthread.cpp | 7 +++++-- indra/newview/lltexturefetch.cpp | 15 ++++++--------- indra/newview/lltexturefetch.h | 1 - indra/newview/lltextureview.cpp | 13 ++++++++++++- indra/newview/llviewertexturelist.cpp | 1 + 7 files changed, 36 insertions(+), 13 deletions(-) diff --git a/indra/llmessage/aicurl.cpp b/indra/llmessage/aicurl.cpp index 3e3e510e1..f84ce373f 100644 --- a/indra/llmessage/aicurl.cpp +++ b/indra/llmessage/aicurl.cpp @@ -298,6 +298,7 @@ LLAtomicU32 Stats::easy_init_errors; LLAtomicU32 Stats::easy_cleanup_calls; LLAtomicU32 Stats::multi_calls; LLAtomicU32 Stats::multi_errors; +LLAtomicU32 Stats::running_handles; LLAtomicU32 Stats::AICurlEasyRequest_count; LLAtomicU32 Stats::AICurlEasyRequestStateMachine_count; LLAtomicU32 Stats::BufferedCurlEasyRequest_count; @@ -460,6 +461,12 @@ void setCAPath(std::string const& path) CertificateAuthority_w->path = path; } +// THREAD-SAFE +U32 getNumHTTPRunning(void) +{ + return Stats::running_handles; +} + //static void Stats::print(void) { diff --git a/indra/llmessage/aicurl.h b/indra/llmessage/aicurl.h index 9244839b7..d8aafe3b3 100644 --- a/indra/llmessage/aicurl.h +++ b/indra/llmessage/aicurl.h @@ -133,6 +133,7 @@ struct Stats { static LLAtomicU32 easy_cleanup_calls; static LLAtomicU32 multi_calls; static LLAtomicU32 multi_errors; + static LLAtomicU32 running_handles; static LLAtomicU32 AICurlEasyRequest_count; static LLAtomicU32 AICurlEasyRequestStateMachine_count; static LLAtomicU32 BufferedCurlEasyRequest_count; @@ -185,6 +186,10 @@ void setCAFile(std::string const& file); // Can be used to set the path to the Certificate Authority file. void setCAPath(std::string const& file); +// This used to be LLAppViewer::getTextureFetch()->getNumHTTPRequests(). +// Returns the number of active curl easy handles (that are actually attempting to download something). +U32 getNumHTTPRunning(void); + } // namespace AICurlInterface // Forward declaration (see aicurlprivate.h). diff --git a/indra/llmessage/aicurlthread.cpp b/indra/llmessage/aicurlthread.cpp index 64b35c683..dc68b37b3 100644 --- a/indra/llmessage/aicurlthread.cpp +++ b/indra/llmessage/aicurlthread.cpp @@ -1653,6 +1653,7 @@ CURLMcode MultiHandle::socket_action(curl_socket_t sockfd, int ev_bitmask) } while(res == CURLM_CALL_MULTI_PERFORM); llassert(mAddedEasyRequests.size() >= (size_t)running_handles); + AICurlInterface::Stats::running_handles = running_handles; return res; } @@ -1696,7 +1697,8 @@ void MultiHandle::add_easy_request(AICurlEasyRequest const& easy_request) { // ... to here. std::pair res = mAddedEasyRequests.insert(easy_request); llassert(res.second); // May not have been added before. - Dout(dc::curl, "MultiHandle::add_easy_request: Added AICurlEasyRequest " << (void*)easy_request.get_ptr().get() << "; now processing " << mAddedEasyRequests.size() << " easy handles."); + Dout(dc::curl, "MultiHandle::add_easy_request: Added AICurlEasyRequest " << (void*)easy_request.get_ptr().get() << + "; now processing " << mAddedEasyRequests.size() << " easy handles [running_handles = " << AICurlInterface::Stats::running_handles << "]."); return; } // The request could not be added, we have to queue it. @@ -1748,7 +1750,8 @@ CURLMcode MultiHandle::remove_easy_request(addedEasyRequests_type::iterator cons #endif mAddedEasyRequests.erase(iter); #if CWDEBUG - Dout(dc::curl, "MultiHandle::remove_easy_request: Removed AICurlEasyRequest " << (void*)lockobj << "; now processing " << mAddedEasyRequests.size() << " easy handles."); + Dout(dc::curl, "MultiHandle::remove_easy_request: Removed AICurlEasyRequest " << (void*)lockobj << + "; now processing " << mAddedEasyRequests.size() << " easy handles [running_handles = " << AICurlInterface::Stats::running_handles << "]."); #endif // Attempt to add a queued request, if any. diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 5efd486e0..22b98c1c5 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1305,6 +1305,12 @@ bool LLTextureFetchWorker::doWork(S32 param) mLoaded = FALSE; mGetStatus = 0; mGetReason.clear(); + // Note: comparing mFetcher->getTextureBandwidth() with throttle_bandwidth is a bit like + // comparing apples and oranges, but it's only debug output. The first is the averaged + // bandwidth used for the body of successfully downloaded textures, averaged over roughtly + // 10 seconds, in kbits/s. The latter is the limit of the actual http curl downloads, + // including header and failures for anything (not just textures), averaged over the last + // second, also in kbits/s. static const LLCachedControl throttle_bandwidth("HTTPThrottleBandwidth", 2000); LL_DEBUGS("Texture") << "HTTP GET: " << mID << " Offset: " << mRequestedOffset << " Bytes: " << mRequestedSize @@ -2261,15 +2267,6 @@ S32 LLTextureFetch::getNumRequests() return size ; } -S32 LLTextureFetch::getNumHTTPRequests() -{ - mNetworkQueueMutex.lock() ; - S32 size = (S32)mHTTPTextureQueue.size(); - mNetworkQueueMutex.unlock() ; - - return size ; -} - U32 LLTextureFetch::getTotalNumHTTPRequests() { mNetworkQueueMutex.lock() ; diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index f23961083..7d2d86135 100644 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -88,7 +88,6 @@ public: U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p, bool& can_use_http); void dump(); S32 getNumRequests() ; - S32 getNumHTTPRequests() ; U32 getTotalNumHTTPRequests() ; // Public for access by callbacks diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index e57fbc3a2..8541dff47 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -64,6 +64,11 @@ LLTextureSizeView *gTextureCategoryView = NULL; //static std::set LLTextureView::sDebugImages; +// Forward declaration. +namespace AICurlInterface { + U32 getNumHTTPRunning(void); +} // namespace AICurlInterface + //////////////////////////////////////////////////////////////////////////// static std::string title_string1a("Tex UUID Area DDis(Req) DecodePri(Fetch) [download] pk/max"); @@ -601,7 +606,7 @@ void LLGLTexMemBar::draw() LLLFSThread::sLocal->getPending(), LLAppViewer::getImageDecodeThread()->getPending(), LLImageRaw::sRawImageCount, LLImageRaw::sRawImageCachedCount, - LLAppViewer::getTextureFetch()->getNumHTTPRequests(), + AICurlInterface::getNumHTTPRunning(), LLAppViewer::getImageDecodeThread()->getPending(), gTextureList.mCreateTextureList.size()); @@ -609,7 +614,13 @@ void LLGLTexMemBar::draw() text_color, LLFontGL::LEFT, LLFontGL::TOP); left += LLFontGL::getFontMonospace()->getWidth(text); + // This bandwidth is averaged over roughly 10 seconds (in kbps) and therefore pretty inaccurate. + // Also, it only takes into account actual texture data (not headers etc). But all it is used for + // is for the color of some text in the texture console, so I guess it doesn't matter. F32 bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth(); + // This is the maximum bandwidth allowed for curl transactions (of any type and averaged per second), + // that is actually used to limit the number of HTTP texture requests (and only those). + // Comparing that with 'bandwidth' is a bit like comparing apples and oranges, but again... who really cares. F32 max_bandwidth = gSavedSettings.getF32("HTTPThrottleBandwidth"); color = bandwidth > max_bandwidth ? LLColor4::red : bandwidth > max_bandwidth*.75f ? LLColor4::yellow : text_color; color[VALPHA] = text_color[VALPHA]; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 7a7b70f9b..1daf21e0c 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1340,6 +1340,7 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d { received_size = msg->getReceiveSize() ; } + // Only used for statistics and texture console. gTextureList.sTextureBits += received_size * 8; gTextureList.sTexturePackets++;