From ac145cb21f382b8eab9f770cecfa23ea9d58aac6 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 14 Mar 2023 23:21:26 +0200 Subject: SL-18629 WIP Fetch Inventory using AIS caps --- indra/newview/llinventorymodelbackgroundfetch.cpp | 214 ++++++++++++++++++---- 1 file changed, 178 insertions(+), 36 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 406c8b89d0..1905a9c9a4 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -27,6 +27,7 @@ #include "llviewerprecompiledheaders.h" #include "llinventorymodelbackgroundfetch.h" +#include "llaisapi.h" #include "llagent.h" #include "llappviewer.h" #include "llcallbacklist.h" @@ -184,12 +185,12 @@ const char * const LOG_INV("Inventory"); ///---------------------------------------------------------------------------- LLInventoryModelBackgroundFetch::LLInventoryModelBackgroundFetch(): - mBackgroundFetchActive(FALSE), + mBackgroundFetchActive(false), mFolderFetchActive(false), mFetchCount(0), - mAllFoldersFetched(FALSE), - mRecursiveInventoryFetchStarted(FALSE), - mRecursiveLibraryFetchStarted(FALSE), + mAllFoldersFetched(false), + mRecursiveInventoryFetchStarted(false), + mRecursiveLibraryFetchStarted(false), mMinTimeBetweenFetches(0.3f) {} @@ -241,17 +242,17 @@ BOOL LLInventoryModelBackgroundFetch::folderFetchActive() const return mFolderFetchActive; } -void LLInventoryModelBackgroundFetch::addRequestAtFront(const LLUUID & id, BOOL recursive, bool is_category) +void LLInventoryModelBackgroundFetch::addRequestAtFront(const LLUUID & id, bool recursive, bool is_category) { mFetchQueue.push_front(FetchQueueInfo(id, recursive, is_category)); } -void LLInventoryModelBackgroundFetch::addRequestAtBack(const LLUUID & id, BOOL recursive, bool is_category) +void LLInventoryModelBackgroundFetch::addRequestAtBack(const LLUUID & id, bool recursive, bool is_category) { mFetchQueue.push_back(FetchQueueInfo(id, recursive, is_category)); } -void LLInventoryModelBackgroundFetch::start(const LLUUID& id, BOOL recursive) +void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) { LLViewerInventoryCategory * cat(gInventory.getCategory(id)); @@ -260,31 +261,57 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, BOOL recursive) // it's a folder, do a bulk fetch LL_DEBUGS(LOG_INV) << "Start fetching category: " << id << ", recursive: " << recursive << LL_ENDL; - mBackgroundFetchActive = TRUE; + mBackgroundFetchActive = true; mFolderFetchActive = true; if (id.isNull()) { if (! mRecursiveInventoryFetchStarted) { mRecursiveInventoryFetchStarted |= recursive; - mFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursive)); + if (recursive && AISAPI::isAvailable()) + { + mRecursiveFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursive)); + } + else + { + mFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursive)); + } gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } if (! mRecursiveLibraryFetchStarted) { mRecursiveLibraryFetchStarted |= recursive; - mFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursive)); + if (recursive && AISAPI::isAvailable()) + { + mRecursiveFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursive)); + } + else + { + mFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursive)); + } gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } else { - // Specific folder requests go to front of queue. - if (mFetchQueue.empty() || mFetchQueue.front().mUUID != id) - { - mFetchQueue.push_front(FetchQueueInfo(id, recursive)); - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); - } + if (recursive && AISAPI::isAvailable()) + { + // AIS does depth requests, recursive requests will need to be prioritizes + if (mRecursiveFetchQueue.empty() || mRecursiveFetchQueue.back().mUUID != id) + { + mRecursiveFetchQueue.push_back(FetchQueueInfo(id, recursive)); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + } + } + else + { + // Specific folder requests go to front of queue. + if (mFetchQueue.empty() || mFetchQueue.front().mUUID != id) + { + mFetchQueue.push_front(FetchQueueInfo(id, recursive)); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + } + } if (id == gInventory.getLibraryRootFolderID()) { mRecursiveLibraryFetchStarted |= recursive; @@ -299,7 +326,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, BOOL recursive) { if (! itemp->mIsComplete && (mFetchQueue.empty() || mFetchQueue.front().mUUID != id)) { - mBackgroundFetchActive = TRUE; + mBackgroundFetchActive = true; mFetchQueue.push_front(FetchQueueInfo(id, false, false)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); @@ -309,9 +336,9 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, BOOL recursive) void LLInventoryModelBackgroundFetch::findLostItems() { - mBackgroundFetchActive = TRUE; + mBackgroundFetchActive = true; mFolderFetchActive = true; - mFetchQueue.push_back(FetchQueueInfo(LLUUID::null, TRUE)); + mFetchQueue.push_back(FetchQueueInfo(LLUUID::null, true)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } @@ -320,7 +347,7 @@ void LLInventoryModelBackgroundFetch::setAllFoldersFetched() if (mRecursiveInventoryFetchStarted && mRecursiveLibraryFetchStarted) { - mAllFoldersFetched = TRUE; + mAllFoldersFetched = true; //LL_INFOS(LOG_INV) << "All folders fetched, validating" << LL_ENDL; //gInventory.validate(); } @@ -338,8 +365,15 @@ void LLInventoryModelBackgroundFetch::backgroundFetch() { if (mBackgroundFetchActive && gAgent.getRegion() && gAgent.getRegion()->capabilitiesReceived()) { - // If we'll be using the capability, we'll be sending batches and the background thing isn't as important. - bulkFetch(); + if (AISAPI::isAvailable()) + { + bulkFetchViaAis(); + } + else + { + // If we'll be using the capability, we'll be sending batches and the background thing isn't as important. + bulkFetch(); + } } } @@ -352,9 +386,118 @@ void LLInventoryModelBackgroundFetch::incrFetchCount(S32 fetching) mFetchCount = 0; } } +void ais_callback(const LLUUID& inv_id) +{ + LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1); +} static LLTrace::BlockTimerStatHandle FTM_BULK_FETCH("Bulk Fetch"); +void LLInventoryModelBackgroundFetch::bulkFetchViaAis() +{ + LL_RECORD_BLOCK_TIME(FTM_BULK_FETCH); + //Background fetch is called from gIdleCallbacks in a loop until background fetch is stopped. + if (gDisconnected) + { + return; + } + + static const S32 max_concurrent_fetches(12); + + if (mFetchCount >= max_concurrent_fetches) + { + return; + } + + // Start with recursive queue since it can get multiple categories + // in a single request and might contain what other requests want + while (!mRecursiveFetchQueue.empty() && mFetchCount < max_concurrent_fetches) + { + const FetchQueueInfo & fetch_info(mRecursiveFetchQueue.front()); + bulkFetchViaAis(fetch_info); + mRecursiveFetchQueue.pop_front(); + } + + while (!mFetchQueue.empty() && mFetchCount < max_concurrent_fetches) + { + const FetchQueueInfo & fetch_info(mFetchQueue.front()); + bulkFetchViaAis(fetch_info); + mFetchQueue.pop_front(); + } + + if (isBulkFetchProcessingComplete()) + { + setAllFoldersFetched(); + } +} + +void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetch_info) +{ + if (fetch_info.mIsCategory) + { + const LLUUID & cat_id(fetch_info.mUUID); + if (cat_id.isNull()) // Lost and found + { + AISAPI::FetchCategoryChildren(LLUUID::null, AISAPI::INVENTORY, false, ais_callback); + mFetchCount++; + } + else + { + const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); + + if (cat) + { + if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion()) + { + if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) + { + AISAPI::FetchCategoryChildren(cat->getUUID(), AISAPI::LIBRARY, fetch_info.mRecursive, ais_callback); + } + else + { + AISAPI::FetchCategoryChildren(cat->getUUID(), AISAPI::INVENTORY, fetch_info.mRecursive, ais_callback); + } + mFetchCount++; + } + else + { + // Already fetched, check if anything inside needs fetching + if (fetch_info.mRecursive) + { + LLInventoryModel::cat_array_t * categories(NULL); + LLInventoryModel::item_array_t * items(NULL); + gInventory.getDirectDescendentsOf(cat->getUUID(), categories, items); + for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); + it != categories->end(); + ++it) + { + mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); + } + } + } + } + // else??? + } + } + else + { + LLViewerInventoryItem * itemp(gInventory.getItem(fetch_info.mUUID)); + + if (itemp) + { + if (itemp->getPermissions().getOwner() == gAgent.getID()) + { + AISAPI::FetchItem(itemp->getUUID(), AISAPI::INVENTORY, ais_callback); + } + else + { + AISAPI::FetchItem(itemp->getUUID(), AISAPI::LIBRARY, ais_callback); + } + mFetchCount++; + } + } +} + // Bundle up a bunch of requests to send all at once. void LLInventoryModelBackgroundFetch::bulkFetch() { @@ -374,13 +517,6 @@ void LLInventoryModelBackgroundFetch::bulkFetch() // inventory more quickly. static const U32 max_batch_size(10); static const S32 max_concurrent_fetches(12); // Outstanding requests, not connections - static const F32 new_min_time(0.05f); // *HACK: Clean this up when old code goes away entirely. - - mMinTimeBetweenFetches = new_min_time; - if (mMinTimeBetweenFetches < new_min_time) - { - mMinTimeBetweenFetches = new_min_time; // *HACK: See above. - } if (mFetchCount) { @@ -394,8 +530,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() gInventory.notifyObservers(); } - if ((mFetchCount > max_concurrent_fetches) || - (mFetchTimer.getElapsedTimeF32() < mMinTimeBetweenFetches)) + if (mFetchCount > max_concurrent_fetches) { return; } @@ -414,6 +549,13 @@ void LLInventoryModelBackgroundFetch::bulkFetch() LLSD item_request_body; LLSD item_request_body_lib; + if (!mRecursiveFetchQueue.empty()) + { + LL_DEBUGS(LOG_INV) << "Request was sheduled for AIS, using legacy" << LL_ENDL; + mFetchQueue.insert(mFetchQueue.begin(), mRecursiveFetchQueue.begin(), mRecursiveFetchQueue.end()); + mRecursiveFetchQueue.clear(); + } + while (! mFetchQueue.empty() && (item_count + folder_count) < max_batch_size) { @@ -421,14 +563,14 @@ void LLInventoryModelBackgroundFetch::bulkFetch() if (fetch_info.mIsCategory) { const LLUUID & cat_id(fetch_info.mUUID); - if (cat_id.isNull()) //DEV-17797 + if (cat_id.isNull()) //DEV-17797 Lost and found { LLSD folder_sd; folder_sd["folder_id"] = LLUUID::null.asString(); folder_sd["owner_id"] = gAgent.getID(); folder_sd["sort_order"] = LLSD::Integer(sort_order); - folder_sd["fetch_folders"] = LLSD::Boolean(FALSE); - folder_sd["fetch_items"] = LLSD::Boolean(TRUE); + folder_sd["fetch_folders"] = LLSD::Boolean(false); + folder_sd["fetch_items"] = LLSD::Boolean(true); folder_request_body["folders"].append(folder_sd); folder_count++; } @@ -444,8 +586,8 @@ void LLInventoryModelBackgroundFetch::bulkFetch() folder_sd["folder_id"] = cat->getUUID(); folder_sd["owner_id"] = cat->getOwnerID(); folder_sd["sort_order"] = LLSD::Integer(sort_order); - folder_sd["fetch_folders"] = LLSD::Boolean(TRUE); //(LLSD::Boolean)sFullFetchStarted; - folder_sd["fetch_items"] = LLSD::Boolean(TRUE); + folder_sd["fetch_folders"] = LLSD::Boolean(true); //(LLSD::Boolean)sFullFetchStarted; + folder_sd["fetch_items"] = LLSD::Boolean(true); if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) { -- cgit v1.2.3 From 83811ff846d9c046e694708c209a6d4dc0bb45a3 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 15 Mar 2023 03:29:03 +0200 Subject: SL-18629 WIP Fetch Inventory using AIS caps #2 --- indra/newview/llinventorymodelbackgroundfetch.cpp | 164 ++++++++++++++-------- 1 file changed, 107 insertions(+), 57 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 1905a9c9a4..5ea8fe4cba 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -244,12 +244,14 @@ BOOL LLInventoryModelBackgroundFetch::folderFetchActive() const void LLInventoryModelBackgroundFetch::addRequestAtFront(const LLUUID & id, bool recursive, bool is_category) { - mFetchQueue.push_front(FetchQueueInfo(id, recursive, is_category)); + ERecursionType recursion_type = recursive ? RT_RECURSIVE : RT_NONE; + mFetchQueue.push_front(FetchQueueInfo(id, recursion_type, is_category)); } void LLInventoryModelBackgroundFetch::addRequestAtBack(const LLUUID & id, bool recursive, bool is_category) { - mFetchQueue.push_back(FetchQueueInfo(id, recursive, is_category)); + ERecursionType recursion_type = recursive ? RT_RECURSIVE : RT_NONE; + mFetchQueue.push_back(FetchQueueInfo(id, recursion_type, is_category)); } void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) @@ -263,6 +265,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) mBackgroundFetchActive = true; mFolderFetchActive = true; + ERecursionType recursion_type = recursive ? RT_RECURSIVE : RT_NONE; if (id.isNull()) { if (! mRecursiveInventoryFetchStarted) @@ -270,11 +273,14 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) mRecursiveInventoryFetchStarted |= recursive; if (recursive && AISAPI::isAvailable()) { - mRecursiveFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursive)); + // Not only root folder can be massive, but + // most system folders will be requested independently + // so request root folder and content separately + mRecursiveFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), RT_CONTENT)); } else { - mFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursive)); + mFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursion_type)); } gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } @@ -283,11 +289,11 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) mRecursiveLibraryFetchStarted |= recursive; if (recursive && AISAPI::isAvailable()) { - mRecursiveFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursive)); + mRecursiveFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursion_type)); } else { - mFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursive)); + mFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursion_type)); } gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } @@ -299,7 +305,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) // AIS does depth requests, recursive requests will need to be prioritizes if (mRecursiveFetchQueue.empty() || mRecursiveFetchQueue.back().mUUID != id) { - mRecursiveFetchQueue.push_back(FetchQueueInfo(id, recursive)); + mRecursiveFetchQueue.push_back(FetchQueueInfo(id, recursion_type)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } @@ -308,7 +314,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) // Specific folder requests go to front of queue. if (mFetchQueue.empty() || mFetchQueue.front().mUUID != id) { - mFetchQueue.push_front(FetchQueueInfo(id, recursive)); + mFetchQueue.push_front(FetchQueueInfo(id, recursion_type)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } @@ -328,7 +334,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) { mBackgroundFetchActive = true; - mFetchQueue.push_front(FetchQueueInfo(id, false, false)); + mFetchQueue.push_front(FetchQueueInfo(id, RT_NONE, false)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } @@ -338,7 +344,7 @@ void LLInventoryModelBackgroundFetch::findLostItems() { mBackgroundFetchActive = true; mFolderFetchActive = true; - mFetchQueue.push_back(FetchQueueInfo(LLUUID::null, true)); + mFetchQueue.push_back(FetchQueueInfo(LLUUID::null, RT_RECURSIVE)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } @@ -386,11 +392,45 @@ void LLInventoryModelBackgroundFetch::incrFetchCount(S32 fetching) mFetchCount = 0; } } -void ais_callback(const LLUUID& inv_id) + +void ais_simple_callback(const LLUUID& inv_id) { LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1); } +void LLInventoryModelBackgroundFetch::onAISCalback(const LLUUID &request_id, const LLUUID &response_id, ERecursionType recursion) +{ + incrFetchCount(-1); + if (response_id.isNull()) // Failure + { + if (recursion == RT_RECURSIVE) + { + // A full recursive request failed. + // Try requesting folder and nested content separately + mBackgroundFetchActive = true; + mFolderFetchActive = true; + mRecursiveFetchQueue.push_back(FetchQueueInfo(request_id, RT_CONTENT)); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + } + } + else + { + if (recursion == RT_CONTENT) + { + // Got the folder, now recursively request content + LLInventoryModel::cat_array_t * categories(NULL); + LLInventoryModel::item_array_t * items(NULL); + gInventory.getDirectDescendentsOf(request_id, categories, items); + for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); + it != categories->end(); + ++it) + { + mRecursiveFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), RT_RECURSIVE)); + } + } + } +} + static LLTrace::BlockTimerStatHandle FTM_BULK_FETCH("Bulk Fetch"); void LLInventoryModelBackgroundFetch::bulkFetchViaAis() @@ -438,45 +478,54 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc const LLUUID & cat_id(fetch_info.mUUID); if (cat_id.isNull()) // Lost and found { - AISAPI::FetchCategoryChildren(LLUUID::null, AISAPI::INVENTORY, false, ais_callback); + AISAPI::FetchCategoryChildren(LLUUID::null, AISAPI::INVENTORY, false, ais_simple_callback); mFetchCount++; } else { - const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); - if (cat) + if (!gInventory.isCategoryComplete(cat_id)) { - if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion()) + const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); + if (cat) { if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) { - AISAPI::FetchCategoryChildren(cat->getUUID(), AISAPI::LIBRARY, fetch_info.mRecursive, ais_callback); + AISAPI::FetchCategoryChildren(cat->getUUID(), AISAPI::LIBRARY, fetch_info.mRecursive == RT_RECURSIVE, ais_simple_callback); } else { - AISAPI::FetchCategoryChildren(cat->getUUID(), AISAPI::INVENTORY, fetch_info.mRecursive, ais_callback); + LLUUID cat_id = cat->getUUID(); + ERecursionType type = fetch_info.mRecursive; + AISAPI::FetchCategoryChildren( + cat_id, + AISAPI::INVENTORY, + type == RT_RECURSIVE, + [cat_id, type](const LLUUID &response_id) + { + LLInventoryModelBackgroundFetch::instance().onAISCalback(cat_id, response_id, type); + }); } mFetchCount++; } - else + // else? + } + else + { + // Already fetched, check if anything inside needs fetching + if (fetch_info.mRecursive) { - // Already fetched, check if anything inside needs fetching - if (fetch_info.mRecursive) + LLInventoryModel::cat_array_t * categories(NULL); + LLInventoryModel::item_array_t * items(NULL); + gInventory.getDirectDescendentsOf(cat_id, categories, items); + for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); + it != categories->end(); + ++it) { - LLInventoryModel::cat_array_t * categories(NULL); - LLInventoryModel::item_array_t * items(NULL); - gInventory.getDirectDescendentsOf(cat->getUUID(), categories, items); - for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); - it != categories->end(); - ++it) - { - mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); - } + mRecursiveFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); } } } - // else??? } } else @@ -487,11 +536,11 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc { if (itemp->getPermissions().getOwner() == gAgent.getID()) { - AISAPI::FetchItem(itemp->getUUID(), AISAPI::INVENTORY, ais_callback); + AISAPI::FetchItem(itemp->getUUID(), AISAPI::INVENTORY, ais_simple_callback); } else { - AISAPI::FetchItem(itemp->getUUID(), AISAPI::LIBRARY, ais_callback); + AISAPI::FetchItem(itemp->getUUID(), AISAPI::LIBRARY, ais_simple_callback); } mFetchCount++; } @@ -576,36 +625,37 @@ void LLInventoryModelBackgroundFetch::bulkFetch() } else { - const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); - - if (cat) - { - if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion()) - { - LLSD folder_sd; - folder_sd["folder_id"] = cat->getUUID(); - folder_sd["owner_id"] = cat->getOwnerID(); - folder_sd["sort_order"] = LLSD::Integer(sort_order); - folder_sd["fetch_folders"] = LLSD::Boolean(true); //(LLSD::Boolean)sFullFetchStarted; - folder_sd["fetch_items"] = LLSD::Boolean(true); - - if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) - { - folder_request_body_lib["folders"].append(folder_sd); - } - else - { - folder_request_body["folders"].append(folder_sd); - } - folder_count++; - } - + if (!gInventory.isCategoryComplete(cat_id)) + { + const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); + if (cat) + { + LLSD folder_sd; + folder_sd["folder_id"] = cat->getUUID(); + folder_sd["owner_id"] = cat->getOwnerID(); + folder_sd["sort_order"] = LLSD::Integer(sort_order); + folder_sd["fetch_folders"] = LLSD::Boolean(true); //(LLSD::Boolean)sFullFetchStarted; + folder_sd["fetch_items"] = LLSD::Boolean(true); + + if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) + { + folder_request_body_lib["folders"].append(folder_sd); + } + else + { + folder_request_body["folders"].append(folder_sd); + } + folder_count++; + } + } + else + { // May already have this folder, but append child folders to list. if (fetch_info.mRecursive) { LLInventoryModel::cat_array_t * categories(NULL); LLInventoryModel::item_array_t * items(NULL); - gInventory.getDirectDescendentsOf(cat->getUUID(), categories, items); + gInventory.getDirectDescendentsOf(cat_id, categories, items); for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); it != categories->end(); ++it) -- cgit v1.2.3 From 7a70d93c437a7065b0c0be7fa63d36f511a9cef2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 15 Mar 2023 20:03:53 +0200 Subject: SL-18629 Fetch Inventory using AIS caps #3 --- indra/newview/llinventorymodelbackgroundfetch.cpp | 50 ++++++++--------------- 1 file changed, 17 insertions(+), 33 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 5ea8fe4cba..098ced4ec9 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -276,7 +276,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) // Not only root folder can be massive, but // most system folders will be requested independently // so request root folder and content separately - mRecursiveFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), RT_CONTENT)); + mFetchQueue.push_front(FetchQueueInfo(gInventory.getRootFolderID(), RT_CONTENT)); } else { @@ -287,25 +287,18 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) if (! mRecursiveLibraryFetchStarted) { mRecursiveLibraryFetchStarted |= recursive; - if (recursive && AISAPI::isAvailable()) - { - mRecursiveFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursion_type)); - } - else - { - mFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursion_type)); - } + mFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursion_type)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } else { - if (recursive && AISAPI::isAvailable()) + if (AISAPI::isAvailable() && !recursive) { - // AIS does depth requests, recursive requests will need to be prioritizes - if (mRecursiveFetchQueue.empty() || mRecursiveFetchQueue.back().mUUID != id) + // Specific folder requests go to front of queue. + if (mFetchQueue.empty() || mFetchQueue.back().mUUID != id) { - mRecursiveFetchQueue.push_back(FetchQueueInfo(id, recursion_type)); + mFetchQueue.push_back(FetchQueueInfo(id, recursion_type)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } @@ -318,6 +311,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } + if (id == gInventory.getLibraryRootFolderID()) { mRecursiveLibraryFetchStarted |= recursive; @@ -409,7 +403,7 @@ void LLInventoryModelBackgroundFetch::onAISCalback(const LLUUID &request_id, con // Try requesting folder and nested content separately mBackgroundFetchActive = true; mFolderFetchActive = true; - mRecursiveFetchQueue.push_back(FetchQueueInfo(request_id, RT_CONTENT)); + mFetchQueue.push_front(FetchQueueInfo(request_id, RT_CONTENT)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } @@ -425,7 +419,13 @@ void LLInventoryModelBackgroundFetch::onAISCalback(const LLUUID &request_id, con it != categories->end(); ++it) { - mRecursiveFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), RT_RECURSIVE)); + mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), RT_RECURSIVE)); + } + if (!mFetchQueue.empty()) + { + mBackgroundFetchActive = true; + mFolderFetchActive = true; + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } } @@ -442,22 +442,13 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() return; } - static const S32 max_concurrent_fetches(12); + static const S32 max_concurrent_fetches(50); if (mFetchCount >= max_concurrent_fetches) { return; } - // Start with recursive queue since it can get multiple categories - // in a single request and might contain what other requests want - while (!mRecursiveFetchQueue.empty() && mFetchCount < max_concurrent_fetches) - { - const FetchQueueInfo & fetch_info(mRecursiveFetchQueue.front()); - bulkFetchViaAis(fetch_info); - mRecursiveFetchQueue.pop_front(); - } - while (!mFetchQueue.empty() && mFetchCount < max_concurrent_fetches) { const FetchQueueInfo & fetch_info(mFetchQueue.front()); @@ -522,7 +513,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc it != categories->end(); ++it) { - mRecursiveFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); + mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); } } } @@ -598,13 +589,6 @@ void LLInventoryModelBackgroundFetch::bulkFetch() LLSD item_request_body; LLSD item_request_body_lib; - if (!mRecursiveFetchQueue.empty()) - { - LL_DEBUGS(LOG_INV) << "Request was sheduled for AIS, using legacy" << LL_ENDL; - mFetchQueue.insert(mFetchQueue.begin(), mRecursiveFetchQueue.begin(), mRecursiveFetchQueue.end()); - mRecursiveFetchQueue.clear(); - } - while (! mFetchQueue.empty() && (item_count + folder_count) < max_batch_size) { -- cgit v1.2.3 From 3a5c41a20e6044c8cfa71dfd1583fea0809d6a68 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 17 Mar 2023 03:23:15 +0200 Subject: SL-18629 Fetch Inventory using AIS caps #4 --- indra/newview/llinventorymodelbackgroundfetch.cpp | 28 +++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 098ced4ec9..282d234cf3 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -293,23 +293,20 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) } else { - if (AISAPI::isAvailable() && !recursive) + if (mFetchQueue.empty() || mFetchQueue.front().mUUID != id) { - // Specific folder requests go to front of queue. - if (mFetchQueue.empty() || mFetchQueue.back().mUUID != id) + if (AISAPI::isAvailable()) { + // On AIS make sure root goes to the top and follow up recursive + // fetches, not individual requests mFetchQueue.push_back(FetchQueueInfo(id, recursion_type)); - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } - } - else - { - // Specific folder requests go to front of queue. - if (mFetchQueue.empty() || mFetchQueue.front().mUUID != id) + else { + // Specific folder requests go to front of queue. mFetchQueue.push_front(FetchQueueInfo(id, recursion_type)); - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } if (id == gInventory.getLibraryRootFolderID()) @@ -419,7 +416,7 @@ void LLInventoryModelBackgroundFetch::onAISCalback(const LLUUID &request_id, con it != categories->end(); ++it) { - mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), RT_RECURSIVE)); + mFetchQueue.push_front(FetchQueueInfo((*it)->getUUID(), RT_RECURSIVE)); } if (!mFetchQueue.empty()) { @@ -449,11 +446,17 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() return; } - while (!mFetchQueue.empty() && mFetchCount < max_concurrent_fetches) + // Don't loop for too long (in case of large, fully loaded inventory) + F64 curent_time = LLTimer::getTotalSeconds(); + const F64 max_time = 0.006f; // 6 ms + const F64 end_time = curent_time + max_time; + + while (!mFetchQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) { const FetchQueueInfo & fetch_info(mFetchQueue.front()); bulkFetchViaAis(fetch_info); mFetchQueue.pop_front(); + curent_time = LLTimer::getTotalSeconds(); } if (isBulkFetchProcessingComplete()) @@ -513,6 +516,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc it != categories->end(); ++it) { + // not push_front to not cause an infinite loop mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); } } -- cgit v1.2.3 From 70d99cde5826893be4964d4673ff875320b7220f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 17 Mar 2023 23:44:28 +0200 Subject: SL-18629 Track request depth to be able to distinguish incomplete folder reliably --- indra/newview/llinventorymodelbackgroundfetch.cpp | 73 +++++++++++------------ 1 file changed, 36 insertions(+), 37 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 282d234cf3..6cae035fcf 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -478,10 +478,10 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc else { - if (!gInventory.isCategoryComplete(cat_id)) + const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); + if (cat) { - const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); - if (cat) + if (!gInventory.isCategoryComplete(cat_id)) { if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) { @@ -502,25 +502,24 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc } mFetchCount++; } - // else? - } - else - { - // Already fetched, check if anything inside needs fetching - if (fetch_info.mRecursive) + else { - LLInventoryModel::cat_array_t * categories(NULL); - LLInventoryModel::item_array_t * items(NULL); - gInventory.getDirectDescendentsOf(cat_id, categories, items); - for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); - it != categories->end(); - ++it) + // Already fetched, check if anything inside needs fetching + if (fetch_info.mRecursive) { - // not push_front to not cause an infinite loop - mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); + LLInventoryModel::cat_array_t * categories(NULL); + LLInventoryModel::item_array_t * items(NULL); + gInventory.getDirectDescendentsOf(cat_id, categories, items); + for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); + it != categories->end(); + ++it) + { + // not push_front to not cause an infinite loop + mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); + } } } - } + } // else? } } else @@ -613,10 +612,10 @@ void LLInventoryModelBackgroundFetch::bulkFetch() } else { - if (!gInventory.isCategoryComplete(cat_id)) + const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); + if (cat) { - const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); - if (cat) + if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion()) { LLSD folder_sd; folder_sd["folder_id"] = cat->getUUID(); @@ -635,23 +634,23 @@ void LLInventoryModelBackgroundFetch::bulkFetch() } folder_count++; } + else + { + // May already have this folder, but append child folders to list. + if (fetch_info.mRecursive) + { + LLInventoryModel::cat_array_t * categories(NULL); + LLInventoryModel::item_array_t * items(NULL); + gInventory.getDirectDescendentsOf(cat_id, categories, items); + for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); + it != categories->end(); + ++it) + { + mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); + } + } + } } - else - { - // May already have this folder, but append child folders to list. - if (fetch_info.mRecursive) - { - LLInventoryModel::cat_array_t * categories(NULL); - LLInventoryModel::item_array_t * items(NULL); - gInventory.getDirectDescendentsOf(cat_id, categories, items); - for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); - it != categories->end(); - ++it) - { - mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); - } - } - } } if (fetch_info.mRecursive) { -- cgit v1.2.3 From 72131418aa943b93f61508993d7006b02ebd9c35 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sun, 19 Mar 2023 16:11:21 +0200 Subject: SL-18629 Rebuild brocken link on fetch compeltion. --- indra/newview/llinventorymodelbackgroundfetch.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 6cae035fcf..ea721b3a40 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -347,12 +347,20 @@ void LLInventoryModelBackgroundFetch::setAllFoldersFetched() mAllFoldersFetched = true; //LL_INFOS(LOG_INV) << "All folders fetched, validating" << LL_ENDL; //gInventory.validate(); + + // For now only informs about initial fetch being done + mAllFoldersFetchedSignal(); } mFolderFetchActive = false; mBackgroundFetchActive = false; LL_INFOS(LOG_INV) << "Inventory background fetch completed" << LL_ENDL; } +boost::signals2::connection LLInventoryModelBackgroundFetch::setAllFoldersFetchedCallback(folders_fetched_callback_t cb) +{ + return mAllFoldersFetchedSignal.connect(cb); +} + void LLInventoryModelBackgroundFetch::backgroundFetchCB(void *) { LLInventoryModelBackgroundFetch::instance().backgroundFetch(); @@ -481,7 +489,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); if (cat) { - if (!gInventory.isCategoryComplete(cat_id)) + if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion()) { if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) { -- cgit v1.2.3 From c9d9f1c54e104dd0ac670fbac2f4e9e053eea25c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 24 Mar 2023 18:52:15 +0200 Subject: SL-18003 Make ais fetch faster --- indra/newview/llinventorymodelbackgroundfetch.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index ea721b3a40..023cc05ee7 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -33,6 +33,7 @@ #include "llcallbacklist.h" #include "llinventorypanel.h" #include "llinventorymodel.h" +#include "llstartup.h" #include "llviewercontrol.h" #include "llviewerinventory.h" #include "llviewermessage.h" @@ -447,7 +448,8 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() return; } - static const S32 max_concurrent_fetches(50); + static LLCachedControl ais_pool(gSavedSettings, "", 20); + const U32 max_concurrent_fetches = llmax(1, ais_pool - 1); if (mFetchCount >= max_concurrent_fetches) { @@ -456,7 +458,9 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() // Don't loop for too long (in case of large, fully loaded inventory) F64 curent_time = LLTimer::getTotalSeconds(); - const F64 max_time = 0.006f; // 6 ms + const F64 max_time = LLStartUp::getStartupState() > STATE_WEARABLES_WAIT + ? 0.006f // 6 ms + : 1.f; const F64 end_time = curent_time + max_time; while (!mFetchQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) @@ -480,8 +484,10 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc const LLUUID & cat_id(fetch_info.mUUID); if (cat_id.isNull()) // Lost and found { - AISAPI::FetchCategoryChildren(LLUUID::null, AISAPI::INVENTORY, false, ais_simple_callback); - mFetchCount++; + LL_WARNS() << "Lost and found not implemented yet" << LL_ENDL; + // todo: needs to be requested from ais in special manner? + /*AISAPI::FetchCategoryChildren(LLUUID::null, AISAPI::INVENTORY, false, ais_simple_callback); + mFetchCount++;*/ } else { -- cgit v1.2.3 From 6fd7427c576ec922b6c670b4ff9381c7cb738b5b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sun, 26 Mar 2023 13:44:50 +0300 Subject: SL-18003 Bulk fetch some items by fetching whole folder --- indra/newview/llinventorymodelbackgroundfetch.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 023cc05ee7..0d366e43f4 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -31,8 +31,9 @@ #include "llagent.h" #include "llappviewer.h" #include "llcallbacklist.h" -#include "llinventorypanel.h" #include "llinventorymodel.h" +#include "llinventoryobserver.h" +#include "llinventorypanel.h" #include "llstartup.h" #include "llviewercontrol.h" #include "llviewerinventory.h" @@ -349,6 +350,9 @@ void LLInventoryModelBackgroundFetch::setAllFoldersFetched() //LL_INFOS(LOG_INV) << "All folders fetched, validating" << LL_ENDL; //gInventory.validate(); + gInventory.addChangedMask(LLInventoryObserver::INTERNAL, gInventory.getRootFolderID()); + gInventory.addChangedMask(LLInventoryObserver::INTERNAL, gInventory.getLibraryRootFolderID()); + // For now only informs about initial fetch being done mAllFoldersFetchedSignal(); } -- cgit v1.2.3 From b00e2da9e23f4dad9c754ce479253ac07eeec154 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 27 Mar 2023 21:04:51 +0300 Subject: SL-18003 Faster cof fetching --- indra/newview/llinventorymodelbackgroundfetch.cpp | 151 ++++++++++++++-------- 1 file changed, 98 insertions(+), 53 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 0d366e43f4..4947c6bfe5 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -201,7 +201,7 @@ LLInventoryModelBackgroundFetch::~LLInventoryModelBackgroundFetch() bool LLInventoryModelBackgroundFetch::isBulkFetchProcessingComplete() const { - return mFetchQueue.empty() && mFetchCount <= 0; + return mFetchFolderQueue.empty() && mFetchItemQueue.empty() && mFetchCount <= 0; } bool LLInventoryModelBackgroundFetch::libraryFetchStarted() const @@ -247,13 +247,27 @@ BOOL LLInventoryModelBackgroundFetch::folderFetchActive() const void LLInventoryModelBackgroundFetch::addRequestAtFront(const LLUUID & id, bool recursive, bool is_category) { ERecursionType recursion_type = recursive ? RT_RECURSIVE : RT_NONE; - mFetchQueue.push_front(FetchQueueInfo(id, recursion_type, is_category)); + if (is_category) + { + mFetchFolderQueue.push_front(FetchQueueInfo(id, recursion_type, is_category)); + } + else + { + mFetchItemQueue.push_front(FetchQueueInfo(id, recursion_type, is_category)); + } } void LLInventoryModelBackgroundFetch::addRequestAtBack(const LLUUID & id, bool recursive, bool is_category) { ERecursionType recursion_type = recursive ? RT_RECURSIVE : RT_NONE; - mFetchQueue.push_back(FetchQueueInfo(id, recursion_type, is_category)); + if (is_category) + { + mFetchFolderQueue.push_back(FetchQueueInfo(id, recursion_type, is_category)); + } + else + { + mFetchItemQueue.push_back(FetchQueueInfo(id, recursion_type, is_category)); + } } void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) @@ -278,37 +292,38 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) // Not only root folder can be massive, but // most system folders will be requested independently // so request root folder and content separately - mFetchQueue.push_front(FetchQueueInfo(gInventory.getRootFolderID(), RT_CONTENT)); + mFetchFolderQueue.push_front(FetchQueueInfo(gInventory.getRootFolderID(), RT_CONTENT)); } else { - mFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursion_type)); + mFetchFolderQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursion_type)); } gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } if (! mRecursiveLibraryFetchStarted) { mRecursiveLibraryFetchStarted |= recursive; - mFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursion_type)); + mFetchFolderQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursion_type)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } else { - if (mFetchQueue.empty() || mFetchQueue.front().mUUID != id) + if (AISAPI::isAvailable()) { - if (AISAPI::isAvailable()) + if (mFetchFolderQueue.empty() || mFetchFolderQueue.back().mUUID != id) { // On AIS make sure root goes to the top and follow up recursive // fetches, not individual requests - mFetchQueue.push_back(FetchQueueInfo(id, recursion_type)); + mFetchFolderQueue.push_back(FetchQueueInfo(id, recursion_type)); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } - else - { + } + else if (mFetchFolderQueue.empty() || mFetchFolderQueue.front().mUUID != id) + { // Specific folder requests go to front of queue. - mFetchQueue.push_front(FetchQueueInfo(id, recursion_type)); - } - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + mFetchFolderQueue.push_front(FetchQueueInfo(id, recursion_type)); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } if (id == gInventory.getLibraryRootFolderID()) @@ -323,11 +338,11 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) } else if (LLViewerInventoryItem * itemp = gInventory.getItem(id)) { - if (! itemp->mIsComplete && (mFetchQueue.empty() || mFetchQueue.front().mUUID != id)) + if (! itemp->mIsComplete && (mFetchItemQueue.empty() || mFetchItemQueue.front().mUUID != id)) { mBackgroundFetchActive = true; - mFetchQueue.push_front(FetchQueueInfo(id, RT_NONE, false)); + mFetchItemQueue.push_front(FetchQueueInfo(id, RT_NONE, false)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } @@ -335,10 +350,17 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) void LLInventoryModelBackgroundFetch::findLostItems() { - mBackgroundFetchActive = true; - mFolderFetchActive = true; - mFetchQueue.push_back(FetchQueueInfo(LLUUID::null, RT_RECURSIVE)); - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + if (AISAPI::isAvailable()) + { + LL_WARNS() << "Not implemented yet" << LL_ENDL; + } + else + { + mBackgroundFetchActive = true; + mFolderFetchActive = true; + mFetchFolderQueue.push_back(FetchQueueInfo(LLUUID::null, RT_RECURSIVE)); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + } } void LLInventoryModelBackgroundFetch::setAllFoldersFetched() @@ -413,7 +435,7 @@ void LLInventoryModelBackgroundFetch::onAISCalback(const LLUUID &request_id, con // Try requesting folder and nested content separately mBackgroundFetchActive = true; mFolderFetchActive = true; - mFetchQueue.push_front(FetchQueueInfo(request_id, RT_CONTENT)); + mFetchFolderQueue.push_front(FetchQueueInfo(request_id, RT_CONTENT)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } @@ -429,9 +451,9 @@ void LLInventoryModelBackgroundFetch::onAISCalback(const LLUUID &request_id, con it != categories->end(); ++it) { - mFetchQueue.push_front(FetchQueueInfo((*it)->getUUID(), RT_RECURSIVE)); + mFetchFolderQueue.push_front(FetchQueueInfo((*it)->getUUID(), RT_RECURSIVE)); } - if (!mFetchQueue.empty()) + if (!mFetchFolderQueue.empty()) { mBackgroundFetchActive = true; mFolderFetchActive = true; @@ -467,11 +489,19 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() : 1.f; const F64 end_time = curent_time + max_time; - while (!mFetchQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) + while (!mFetchFolderQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) { - const FetchQueueInfo & fetch_info(mFetchQueue.front()); + const FetchQueueInfo & fetch_info(mFetchFolderQueue.front()); bulkFetchViaAis(fetch_info); - mFetchQueue.pop_front(); + mFetchFolderQueue.pop_front(); + curent_time = LLTimer::getTotalSeconds(); + } + + while (!mFetchFolderQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) + { + const FetchQueueInfo & fetch_info(mFetchFolderQueue.front()); + bulkFetchViaAis(fetch_info); + mFetchFolderQueue.pop_front(); curent_time = LLTimer::getTotalSeconds(); } @@ -533,7 +563,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc ++it) { // not push_front to not cause an infinite loop - mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); + mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); } } } @@ -610,10 +640,10 @@ void LLInventoryModelBackgroundFetch::bulkFetch() LLSD item_request_body; LLSD item_request_body_lib; - while (! mFetchQueue.empty() + while (! mFetchFolderQueue.empty() && (item_count + folder_count) < max_batch_size) { - const FetchQueueInfo & fetch_info(mFetchQueue.front()); + const FetchQueueInfo & fetch_info(mFetchFolderQueue.front()); if (fetch_info.mIsCategory) { const LLUUID & cat_id(fetch_info.mUUID); @@ -664,7 +694,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() it != categories->end(); ++it) { - mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); + mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); } } } @@ -675,29 +705,36 @@ void LLInventoryModelBackgroundFetch::bulkFetch() recursive_cats.push_back(cat_id); } } - else - { - LLViewerInventoryItem * itemp(gInventory.getItem(fetch_info.mUUID)); - if (itemp) - { - LLSD item_sd; - item_sd["owner_id"] = itemp->getPermissions().getOwner(); - item_sd["item_id"] = itemp->getUUID(); - if (itemp->getPermissions().getOwner() == gAgent.getID()) - { - item_request_body.append(item_sd); - } - else - { - item_request_body_lib.append(item_sd); - } - //itemp->fetchFromServer(); - item_count++; - } - } + mFetchFolderQueue.pop_front(); + } + + + while (!mFetchItemQueue.empty() + && (item_count + folder_count) < max_batch_size) + { + const FetchQueueInfo & fetch_info(mFetchItemQueue.front()); + + LLViewerInventoryItem * itemp(gInventory.getItem(fetch_info.mUUID)); - mFetchQueue.pop_front(); + if (itemp) + { + LLSD item_sd; + item_sd["owner_id"] = itemp->getPermissions().getOwner(); + item_sd["item_id"] = itemp->getUUID(); + if (itemp->getPermissions().getOwner() == gAgent.getID()) + { + item_request_body.append(item_sd); + } + else + { + item_request_body_lib.append(item_sd); + } + //itemp->fetchFromServer(); + item_count++; + } + + mFetchItemQueue.pop_front(); } // Issue HTTP POST requests to fetch folders and items @@ -768,14 +805,22 @@ void LLInventoryModelBackgroundFetch::bulkFetch() bool LLInventoryModelBackgroundFetch::fetchQueueContainsNoDescendentsOf(const LLUUID & cat_id) const { - for (fetch_queue_t::const_iterator it = mFetchQueue.begin(); - it != mFetchQueue.end(); + for (fetch_queue_t::const_iterator it = mFetchFolderQueue.begin(); + it != mFetchFolderQueue.end(); ++it) { const LLUUID & fetch_id = (*it).mUUID; if (gInventory.isObjectDescendentOf(fetch_id, cat_id)) return false; } + for (fetch_queue_t::const_iterator it = mFetchItemQueue.begin(); + it != mFetchItemQueue.end(); + ++it) + { + const LLUUID & fetch_id = (*it).mUUID; + if (gInventory.isObjectDescendentOf(fetch_id, cat_id)) + return false; + } return true; } -- cgit v1.2.3 From 0eff9756494a268f6aa68b66ce4d09cb5aa5460a Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 27 Mar 2023 21:24:21 +0300 Subject: SL-18003 Basic dupplicate prevention --- indra/newview/llinventorymodelbackgroundfetch.cpp | 35 ++++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 4947c6bfe5..21f7e3e059 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -419,12 +419,19 @@ void LLInventoryModelBackgroundFetch::incrFetchCount(S32 fetching) } } -void ais_simple_callback(const LLUUID& inv_id) +void ais_simple_folder_callback(const LLUUID& inv_id) { LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1); + LLViewerInventoryCategory * cat(gInventory.getCategory(inv_id)); + if (cat) cat->setFetching(false); } -void LLInventoryModelBackgroundFetch::onAISCalback(const LLUUID &request_id, const LLUUID &response_id, ERecursionType recursion) +void ais_simple_item_callback(const LLUUID& inv_id) +{ + LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1); +} + +void LLInventoryModelBackgroundFetch::onAISFodlerCalback(const LLUUID &request_id, const LLUUID &response_id, ERecursionType recursion) { incrFetchCount(-1); if (response_id.isNull()) // Failure @@ -460,6 +467,13 @@ void LLInventoryModelBackgroundFetch::onAISCalback(const LLUUID &request_id, con gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } + + // done + LLViewerInventoryCategory * cat(gInventory.getCategory(request_id)); + if (cat) + { + cat->setFetching(false); + } } } @@ -497,11 +511,11 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() curent_time = LLTimer::getTotalSeconds(); } - while (!mFetchFolderQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) + while (!mFetchItemQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) { - const FetchQueueInfo & fetch_info(mFetchFolderQueue.front()); + const FetchQueueInfo & fetch_info(mFetchItemQueue.front()); bulkFetchViaAis(fetch_info); - mFetchFolderQueue.pop_front(); + mFetchItemQueue.pop_front(); curent_time = LLTimer::getTotalSeconds(); } @@ -526,14 +540,14 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc else { - const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); + LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); if (cat) { if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion()) { if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) { - AISAPI::FetchCategoryChildren(cat->getUUID(), AISAPI::LIBRARY, fetch_info.mRecursive == RT_RECURSIVE, ais_simple_callback); + AISAPI::FetchCategoryChildren(cat->getUUID(), AISAPI::LIBRARY, fetch_info.mRecursive == RT_RECURSIVE, ais_simple_folder_callback); } else { @@ -545,10 +559,11 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc type == RT_RECURSIVE, [cat_id, type](const LLUUID &response_id) { - LLInventoryModelBackgroundFetch::instance().onAISCalback(cat_id, response_id, type); + LLInventoryModelBackgroundFetch::instance().onAISFodlerCalback(cat_id, response_id, type); }); } mFetchCount++; + cat->setFetching(true); } else { @@ -578,11 +593,11 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc { if (itemp->getPermissions().getOwner() == gAgent.getID()) { - AISAPI::FetchItem(itemp->getUUID(), AISAPI::INVENTORY, ais_simple_callback); + AISAPI::FetchItem(itemp->getUUID(), AISAPI::INVENTORY, ais_simple_item_callback); } else { - AISAPI::FetchItem(itemp->getUUID(), AISAPI::LIBRARY, ais_simple_callback); + AISAPI::FetchItem(itemp->getUUID(), AISAPI::LIBRARY, ais_simple_item_callback); } mFetchCount++; } -- cgit v1.2.3 From 110ed8f4d3152c91ddd7577234ad37b666be86c9 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 28 Mar 2023 00:53:35 +0300 Subject: SL-18003 Don't cause excessive full rebuild --- indra/newview/llinventorymodelbackgroundfetch.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 21f7e3e059..25e35915c3 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -372,9 +372,6 @@ void LLInventoryModelBackgroundFetch::setAllFoldersFetched() //LL_INFOS(LOG_INV) << "All folders fetched, validating" << LL_ENDL; //gInventory.validate(); - gInventory.addChangedMask(LLInventoryObserver::INTERNAL, gInventory.getRootFolderID()); - gInventory.addChangedMask(LLInventoryObserver::INTERNAL, gInventory.getLibraryRootFolderID()); - // For now only informs about initial fetch being done mAllFoldersFetchedSignal(); } -- cgit v1.2.3 From 89a8c96f36983738645a2116d9d432e3bd88f1df Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 28 Mar 2023 02:27:34 +0300 Subject: SL-18003 Bulk download items when possible And signal fodler fetch completion when folder of recursive fetch is done, do not hold it for individual items --- indra/newview/llinventorymodelbackgroundfetch.cpp | 89 ++++++++++++++++------- 1 file changed, 64 insertions(+), 25 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 25e35915c3..d58dd22ca1 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -190,6 +190,7 @@ LLInventoryModelBackgroundFetch::LLInventoryModelBackgroundFetch(): mBackgroundFetchActive(false), mFolderFetchActive(false), mFetchCount(0), + mFetchFolderCount(0), mAllFoldersFetched(false), mRecursiveInventoryFetchStarted(false), mRecursiveLibraryFetchStarted(false), @@ -204,6 +205,11 @@ bool LLInventoryModelBackgroundFetch::isBulkFetchProcessingComplete() const return mFetchFolderQueue.empty() && mFetchItemQueue.empty() && mFetchCount <= 0; } +bool LLInventoryModelBackgroundFetch::isFolderFetchProcessingComplete() const +{ + return mFetchFolderQueue.empty() && mFetchFolderCount <= 0; +} + bool LLInventoryModelBackgroundFetch::libraryFetchStarted() const { return mRecursiveLibraryFetchStarted; @@ -338,16 +344,24 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) } else if (LLViewerInventoryItem * itemp = gInventory.getItem(id)) { - if (! itemp->mIsComplete && (mFetchItemQueue.empty() || mFetchItemQueue.front().mUUID != id)) + if (! itemp->mIsComplete) { - mBackgroundFetchActive = true; - - mFetchItemQueue.push_front(FetchQueueInfo(id, RT_NONE, false)); - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + scheduleItemFetch(id); } } } +void LLInventoryModelBackgroundFetch::scheduleItemFetch(const LLUUID& item_id) +{ + if (mFetchItemQueue.empty() || mFetchItemQueue.front().mUUID != item_id) + { + mBackgroundFetchActive = true; + + mFetchItemQueue.push_front(FetchQueueInfo(item_id, RT_NONE, false)); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + } +} + void LLInventoryModelBackgroundFetch::findLostItems() { if (AISAPI::isAvailable()) @@ -371,18 +385,23 @@ void LLInventoryModelBackgroundFetch::setAllFoldersFetched() mAllFoldersFetched = true; //LL_INFOS(LOG_INV) << "All folders fetched, validating" << LL_ENDL; //gInventory.validate(); - - // For now only informs about initial fetch being done - mAllFoldersFetchedSignal(); } + mFolderFetchActive = false; - mBackgroundFetchActive = false; + if (isBulkFetchProcessingComplete()) + { + mBackgroundFetchActive = false; + } + + // For now only informs about initial fetch being done + mFoldersFetchedSignal(); + LL_INFOS(LOG_INV) << "Inventory background fetch completed" << LL_ENDL; } -boost::signals2::connection LLInventoryModelBackgroundFetch::setAllFoldersFetchedCallback(folders_fetched_callback_t cb) +boost::signals2::connection LLInventoryModelBackgroundFetch::setFetchCompletionCallback(folders_fetched_callback_t cb) { - return mAllFoldersFetchedSignal.connect(cb); + return mFoldersFetchedSignal.connect(cb); } void LLInventoryModelBackgroundFetch::backgroundFetchCB(void *) @@ -415,10 +434,20 @@ void LLInventoryModelBackgroundFetch::incrFetchCount(S32 fetching) mFetchCount = 0; } } +void LLInventoryModelBackgroundFetch::incrFetchFolderCount(S32 fetching) +{ + incrFetchCount(fetching); + mFetchFolderCount += fetching; + if (mFetchCount < 0) + { + LL_WARNS_ONCE(LOG_INV) << "Inventory fetch count fell below zero (0)." << LL_ENDL; + mFetchFolderCount = 0; + } +} void ais_simple_folder_callback(const LLUUID& inv_id) { - LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1); + LLInventoryModelBackgroundFetch::instance().incrFetchFolderCount(-1); LLViewerInventoryCategory * cat(gInventory.getCategory(inv_id)); if (cat) cat->setFetching(false); } @@ -430,7 +459,7 @@ void ais_simple_item_callback(const LLUUID& inv_id) void LLInventoryModelBackgroundFetch::onAISFodlerCalback(const LLUUID &request_id, const LLUUID &response_id, ERecursionType recursion) { - incrFetchCount(-1); + incrFetchFolderCount(-1); if (response_id.isNull()) // Failure { if (recursion == RT_RECURSIVE) @@ -464,13 +493,13 @@ void LLInventoryModelBackgroundFetch::onAISFodlerCalback(const LLUUID &request_i gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } + } - // done - LLViewerInventoryCategory * cat(gInventory.getCategory(request_id)); - if (cat) - { - cat->setFetching(false); - } + // done + LLViewerInventoryCategory * cat(gInventory.getCategory(request_id)); + if (cat) + { + cat->setFetching(false); } } @@ -516,10 +545,15 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() curent_time = LLTimer::getTotalSeconds(); } - if (isBulkFetchProcessingComplete()) + if (isFolderFetchProcessingComplete() && mFolderFetchActive) { setAllFoldersFetched(); } + + if (isBulkFetchProcessingComplete()) + { + mBackgroundFetchActive = false; + } } void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetch_info) @@ -532,7 +566,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc LL_WARNS() << "Lost and found not implemented yet" << LL_ENDL; // todo: needs to be requested from ais in special manner? /*AISAPI::FetchCategoryChildren(LLUUID::null, AISAPI::INVENTORY, false, ais_simple_callback); - mFetchCount++;*/ + incrFetchFolderCount(1);*/ } else { @@ -559,7 +593,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc LLInventoryModelBackgroundFetch::instance().onAISFodlerCalback(cat_id, response_id, type); }); } - mFetchCount++; + incrFetchFolderCount(1); cat->setFetching(true); } else @@ -590,14 +624,19 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc { if (itemp->getPermissions().getOwner() == gAgent.getID()) { - AISAPI::FetchItem(itemp->getUUID(), AISAPI::INVENTORY, ais_simple_item_callback); + AISAPI::FetchItem(fetch_info.mUUID, AISAPI::INVENTORY, ais_simple_item_callback); } else { - AISAPI::FetchItem(itemp->getUUID(), AISAPI::LIBRARY, ais_simple_item_callback); + AISAPI::FetchItem(fetch_info.mUUID, AISAPI::LIBRARY, ais_simple_item_callback); } - mFetchCount++; } + else + { + // Assume agent's inventory, library wouldn't have gotten here + AISAPI::FetchItem(fetch_info.mUUID, AISAPI::INVENTORY, ais_simple_item_callback); + } + mFetchCount++; } } -- cgit v1.2.3 From d21a1aace63967fe62b12b71b7f683f662dfcf4a Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 28 Mar 2023 03:41:51 +0300 Subject: SL-18003 Missed pool name --- indra/newview/llinventorymodelbackgroundfetch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index d58dd22ca1..4cb4b9ee9c 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -514,7 +514,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() return; } - static LLCachedControl ais_pool(gSavedSettings, "", 20); + static LLCachedControl ais_pool(gSavedSettings, "PoolSizeAIS", 20); const U32 max_concurrent_fetches = llmax(1, ais_pool - 1); if (mFetchCount >= max_concurrent_fetches) -- cgit v1.2.3 From 3bf9c78f564f0b6c4fd79163bd63c0a6c1fab7cb Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 28 Mar 2023 19:38:26 +0300 Subject: SL-18003 Improve dupplicate prevention Try getting lost and found --- indra/newview/llinventorymodelbackgroundfetch.cpp | 147 +++++++++++++--------- 1 file changed, 88 insertions(+), 59 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 4cb4b9ee9c..a9357bfdb3 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -252,7 +252,7 @@ BOOL LLInventoryModelBackgroundFetch::folderFetchActive() const void LLInventoryModelBackgroundFetch::addRequestAtFront(const LLUUID & id, bool recursive, bool is_category) { - ERecursionType recursion_type = recursive ? RT_RECURSIVE : RT_NONE; + EFetchType recursion_type = recursive ? FT_RECURSIVE : FT_DEFAULT; if (is_category) { mFetchFolderQueue.push_front(FetchQueueInfo(id, recursion_type, is_category)); @@ -265,7 +265,7 @@ void LLInventoryModelBackgroundFetch::addRequestAtFront(const LLUUID & id, bool void LLInventoryModelBackgroundFetch::addRequestAtBack(const LLUUID & id, bool recursive, bool is_category) { - ERecursionType recursion_type = recursive ? RT_RECURSIVE : RT_NONE; + EFetchType recursion_type = recursive ? FT_RECURSIVE : FT_DEFAULT; if (is_category) { mFetchFolderQueue.push_back(FetchQueueInfo(id, recursion_type, is_category)); @@ -287,7 +287,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) mBackgroundFetchActive = true; mFolderFetchActive = true; - ERecursionType recursion_type = recursive ? RT_RECURSIVE : RT_NONE; + EFetchType recursion_type = recursive ? FT_RECURSIVE : FT_DEFAULT; if (id.isNull()) { if (! mRecursiveInventoryFetchStarted) @@ -298,7 +298,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) // Not only root folder can be massive, but // most system folders will be requested independently // so request root folder and content separately - mFetchFolderQueue.push_front(FetchQueueInfo(gInventory.getRootFolderID(), RT_CONTENT)); + mFetchFolderQueue.push_front(FetchQueueInfo(gInventory.getRootFolderID(), FT_CONTENT_RECURSIVE)); } else { @@ -351,32 +351,45 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) } } -void LLInventoryModelBackgroundFetch::scheduleItemFetch(const LLUUID& item_id) +void LLInventoryModelBackgroundFetch::scheduleFolderFetch(const LLUUID& cat_id, bool forced) { - if (mFetchItemQueue.empty() || mFetchItemQueue.front().mUUID != item_id) + if (AISAPI::isAvailable()) { - mBackgroundFetchActive = true; - - mFetchItemQueue.push_front(FetchQueueInfo(item_id, RT_NONE, false)); + if (mFetchFolderQueue.empty() || mFetchFolderQueue.back().mUUID != cat_id) + { + // On AIS make sure root goes to the top and follow up recursive + // fetches, not individual requests + mFetchFolderQueue.push_back(FetchQueueInfo(cat_id, forced ? FT_FORCED : FT_DEFAULT)); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + } + } + else if (mFetchFolderQueue.empty() || mFetchFolderQueue.front().mUUID != cat_id) + { + // Specific folder requests go to front of queue. + mFetchFolderQueue.push_front(FetchQueueInfo(cat_id, forced ? FT_FORCED : FT_DEFAULT)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } -void LLInventoryModelBackgroundFetch::findLostItems() +void LLInventoryModelBackgroundFetch::scheduleItemFetch(const LLUUID& item_id, bool forced) { - if (AISAPI::isAvailable()) - { - LL_WARNS() << "Not implemented yet" << LL_ENDL; - } - else + if (mFetchItemQueue.empty() || mFetchItemQueue.front().mUUID != item_id) { mBackgroundFetchActive = true; - mFolderFetchActive = true; - mFetchFolderQueue.push_back(FetchQueueInfo(LLUUID::null, RT_RECURSIVE)); + + mFetchItemQueue.push_front(FetchQueueInfo(item_id, forced ? FT_FORCED : FT_DEFAULT, false)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } +void LLInventoryModelBackgroundFetch::findLostItems() +{ + mBackgroundFetchActive = true; + mFolderFetchActive = true; + mFetchFolderQueue.push_back(FetchQueueInfo(LLUUID::null, FT_RECURSIVE)); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); +} + void LLInventoryModelBackgroundFetch::setAllFoldersFetched() { if (mRecursiveInventoryFetchStarted && @@ -449,7 +462,10 @@ void ais_simple_folder_callback(const LLUUID& inv_id) { LLInventoryModelBackgroundFetch::instance().incrFetchFolderCount(-1); LLViewerInventoryCategory * cat(gInventory.getCategory(inv_id)); - if (cat) cat->setFetching(false); + if (cat) + { + cat->setFetching(LLViewerInventoryCategory::FETCH_NONE); + } } void ais_simple_item_callback(const LLUUID& inv_id) @@ -457,24 +473,24 @@ void ais_simple_item_callback(const LLUUID& inv_id) LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1); } -void LLInventoryModelBackgroundFetch::onAISFodlerCalback(const LLUUID &request_id, const LLUUID &response_id, ERecursionType recursion) +void LLInventoryModelBackgroundFetch::onAISFodlerCalback(const LLUUID &request_id, const LLUUID &response_id, EFetchType recursion) { incrFetchFolderCount(-1); if (response_id.isNull()) // Failure { - if (recursion == RT_RECURSIVE) + if (recursion == FT_RECURSIVE) { // A full recursive request failed. // Try requesting folder and nested content separately mBackgroundFetchActive = true; mFolderFetchActive = true; - mFetchFolderQueue.push_front(FetchQueueInfo(request_id, RT_CONTENT)); + mFetchFolderQueue.push_front(FetchQueueInfo(request_id, FT_CONTENT_RECURSIVE)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } } else { - if (recursion == RT_CONTENT) + if (recursion == FT_CONTENT_RECURSIVE) { // Got the folder, now recursively request content LLInventoryModel::cat_array_t * categories(NULL); @@ -484,7 +500,7 @@ void LLInventoryModelBackgroundFetch::onAISFodlerCalback(const LLUUID &request_i it != categories->end(); ++it) { - mFetchFolderQueue.push_front(FetchQueueInfo((*it)->getUUID(), RT_RECURSIVE)); + mFetchFolderQueue.push_front(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); } if (!mFetchFolderQueue.empty()) { @@ -499,7 +515,7 @@ void LLInventoryModelBackgroundFetch::onAISFodlerCalback(const LLUUID &request_i LLViewerInventoryCategory * cat(gInventory.getCategory(request_id)); if (cat) { - cat->setFetching(false); + cat->setFetching(LLViewerInventoryCategory::FETCH_NONE); } } @@ -561,12 +577,11 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc if (fetch_info.mIsCategory) { const LLUUID & cat_id(fetch_info.mUUID); - if (cat_id.isNull()) // Lost and found + if (cat_id.isNull()) { - LL_WARNS() << "Lost and found not implemented yet" << LL_ENDL; - // todo: needs to be requested from ais in special manner? - /*AISAPI::FetchCategoryChildren(LLUUID::null, AISAPI::INVENTORY, false, ais_simple_callback); - incrFetchFolderCount(1);*/ + // Lost and found + AISAPI::FetchCategoryChildren("lstndfnd", true, ais_simple_folder_callback); + incrFetchFolderCount(1); } else { @@ -574,32 +589,42 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); if (cat) { - if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion()) + if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion() || fetch_info.mFetchType == FT_FORCED) { - if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) - { - AISAPI::FetchCategoryChildren(cat->getUUID(), AISAPI::LIBRARY, fetch_info.mRecursive == RT_RECURSIVE, ais_simple_folder_callback); - } - else + LLViewerInventoryCategory::EFetchType target_state = + fetch_info.mFetchType >= FT_CONTENT_RECURSIVE + ? LLViewerInventoryCategory::FETCH_RECURSIVE + : LLViewerInventoryCategory::FETCH_NORMAL; + // start again if we did a non-recursive fetch before + if (cat->getFetching() < target_state) { - LLUUID cat_id = cat->getUUID(); - ERecursionType type = fetch_info.mRecursive; - AISAPI::FetchCategoryChildren( - cat_id, - AISAPI::INVENTORY, - type == RT_RECURSIVE, - [cat_id, type](const LLUUID &response_id) + + if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) { - LLInventoryModelBackgroundFetch::instance().onAISFodlerCalback(cat_id, response_id, type); - }); + AISAPI::FetchCategoryChildren(cat->getUUID(), AISAPI::LIBRARY, fetch_info.mFetchType == FT_RECURSIVE, ais_simple_folder_callback); + } + else + { + LLUUID cat_id = cat->getUUID(); + EFetchType type = fetch_info.mFetchType; + AISAPI::FetchCategoryChildren( + cat_id, + AISAPI::INVENTORY, + type == FT_RECURSIVE, + [cat_id, type](const LLUUID &response_id) + { + LLInventoryModelBackgroundFetch::instance().onAISFodlerCalback(cat_id, response_id, type); + }); + } + incrFetchFolderCount(1); + + cat->setFetching(target_state); } - incrFetchFolderCount(1); - cat->setFetching(true); } else { // Already fetched, check if anything inside needs fetching - if (fetch_info.mRecursive) + if (fetch_info.mFetchType >= FT_CONTENT_RECURSIVE) { LLInventoryModel::cat_array_t * categories(NULL); LLInventoryModel::item_array_t * items(NULL); @@ -609,7 +634,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc ++it) { // not push_front to not cause an infinite loop - mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); + mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mFetchType)); } } } @@ -622,21 +647,25 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc if (itemp) { - if (itemp->getPermissions().getOwner() == gAgent.getID()) - { - AISAPI::FetchItem(fetch_info.mUUID, AISAPI::INVENTORY, ais_simple_item_callback); - } - else + if (!itemp->isFinished() || fetch_info.mFetchType == FT_FORCED) { - AISAPI::FetchItem(fetch_info.mUUID, AISAPI::LIBRARY, ais_simple_item_callback); + if (itemp->getPermissions().getOwner() == gAgent.getID()) + { + AISAPI::FetchItem(fetch_info.mUUID, AISAPI::INVENTORY, ais_simple_item_callback); + } + else + { + AISAPI::FetchItem(fetch_info.mUUID, AISAPI::LIBRARY, ais_simple_item_callback); + } + mFetchCount++; } } - else + else // We don't know it, assume incomplete { // Assume agent's inventory, library wouldn't have gotten here AISAPI::FetchItem(fetch_info.mUUID, AISAPI::INVENTORY, ais_simple_item_callback); + mFetchCount++; } - mFetchCount++; } } @@ -736,7 +765,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() else { // May already have this folder, but append child folders to list. - if (fetch_info.mRecursive) + if (fetch_info.mFetchType >= FT_CONTENT_RECURSIVE) { LLInventoryModel::cat_array_t * categories(NULL); LLInventoryModel::item_array_t * items(NULL); @@ -745,13 +774,13 @@ void LLInventoryModelBackgroundFetch::bulkFetch() it != categories->end(); ++it) { - mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive)); + mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mFetchType)); } } } } } - if (fetch_info.mRecursive) + if (fetch_info.mFetchType >= FT_CONTENT_RECURSIVE) { recursive_cats.push_back(cat_id); } -- cgit v1.2.3 From 43ff8108f2d056b84ab2a7586951ad363c350f05 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 7 Apr 2023 20:12:09 +0300 Subject: SL-19534 Better fetch failure handling --- indra/newview/llinventorymodelbackgroundfetch.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index c8bf8f67ce..e988f949e2 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -487,6 +487,26 @@ void LLInventoryModelBackgroundFetch::onAISFodlerCalback(const LLUUID &request_i mFetchFolderQueue.push_front(FetchQueueInfo(request_id, FT_CONTENT_RECURSIVE)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } + else if (recursion == FT_CONTENT_RECURSIVE) + { + LL_WARNS() << "Failed to download folder: " << request_id << " Requesting known content separately" << LL_ENDL; + LLInventoryModel::cat_array_t *categories(NULL); + LLInventoryModel::item_array_t *items(NULL); + gInventory.getDirectDescendentsOf(request_id, categories, items); + if (categories) + { + for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); it != categories->end(); ++it) + { + mFetchFolderQueue.push_front(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); + } + if (!mFetchFolderQueue.empty()) + { + mBackgroundFetchActive = true; + mFolderFetchActive = true; + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + } + } + } } else { -- cgit v1.2.3 From 69e3b5fb4014ef900b129ebde49325f1b074e773 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 11 Apr 2023 01:33:24 +0300 Subject: SL-19533 Orphans plus additional logging --- indra/newview/llinventorymodelbackgroundfetch.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index e988f949e2..35b9442966 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -461,10 +461,13 @@ void LLInventoryModelBackgroundFetch::incrFetchFolderCount(S32 fetching) void ais_simple_folder_callback(const LLUUID& inv_id) { LLInventoryModelBackgroundFetch::instance().incrFetchFolderCount(-1); - LLViewerInventoryCategory * cat(gInventory.getCategory(inv_id)); - if (cat) + if (inv_id.notNull()) // null normally means a failure, but is an expected response for orphans { - cat->setFetching(LLViewerInventoryCategory::FETCH_NONE); + LLViewerInventoryCategory* cat(gInventory.getCategory(inv_id)); + if (cat) + { + cat->setFetching(LLViewerInventoryCategory::FETCH_NONE); + } } } @@ -580,6 +583,11 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() mFetchItemQueue.pop_front(); curent_time = LLTimer::getTotalSeconds(); } + + LL_DEBUGS(LOG_INV , "AIS3") << "Total active fetches: " << mFetchCount + << ", scheduled fodler fetches: " << (S32)mFetchFolderQueue.size() + << ", scheduled item fetches: " << (S32)mFetchItemQueue.size() + << LL_ENDL; if (isFolderFetchProcessingComplete() && mFolderFetchActive) { @@ -600,7 +608,8 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc if (cat_id.isNull()) { // Lost and found - AISAPI::FetchCategoryChildren("lstndfnd", true, ais_simple_folder_callback); + // Should it actually be recursive? + AISAPI::FetchOrphans(ais_simple_folder_callback); incrFetchFolderCount(1); } else -- cgit v1.2.3 From 8171224a6510ac8b984dace5f10a6f92cb1e2942 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 11 Apr 2023 19:26:21 +0300 Subject: SL-19533 Don't fetch items if recursive fetch isn't done --- indra/newview/llinventorymodelbackgroundfetch.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 35b9442966..0099e81b8f 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -191,7 +191,7 @@ LLInventoryModelBackgroundFetch::LLInventoryModelBackgroundFetch(): mFolderFetchActive(false), mFetchCount(0), mFetchFolderCount(0), - mAllFoldersFetched(false), + mAllRecursiveFoldersFetched(false), mRecursiveInventoryFetchStarted(false), mRecursiveLibraryFetchStarted(false), mMinTimeBetweenFetches(0.3f) @@ -242,7 +242,7 @@ bool LLInventoryModelBackgroundFetch::inventoryFetchInProgress() const bool LLInventoryModelBackgroundFetch::isEverythingFetched() const { - return mAllFoldersFetched; + return mAllRecursiveFoldersFetched; } BOOL LLInventoryModelBackgroundFetch::folderFetchActive() const @@ -395,7 +395,7 @@ void LLInventoryModelBackgroundFetch::setAllFoldersFetched() if (mRecursiveInventoryFetchStarted && mRecursiveLibraryFetchStarted) { - mAllFoldersFetched = true; + mAllRecursiveFoldersFetched = true; //LL_INFOS(LOG_INV) << "All folders fetched, validating" << LL_ENDL; //gInventory.validate(); } @@ -576,12 +576,17 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() curent_time = LLTimer::getTotalSeconds(); } - while (!mFetchItemQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) + if (mRecursiveInventoryFetchStarted && mAllRecursiveFoldersFetched) { - const FetchQueueInfo & fetch_info(mFetchItemQueue.front()); - bulkFetchViaAis(fetch_info); - mFetchItemQueue.pop_front(); - curent_time = LLTimer::getTotalSeconds(); + // Don't fetch items if recursive fetch isn't done, + // it gets both items and folders and should get the items in question faster + while (!mFetchItemQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) + { + const FetchQueueInfo& fetch_info(mFetchItemQueue.front()); + bulkFetchViaAis(fetch_info); + mFetchItemQueue.pop_front(); + curent_time = LLTimer::getTotalSeconds(); + } } LL_DEBUGS(LOG_INV , "AIS3") << "Total active fetches: " << mFetchCount -- cgit v1.2.3 From 5e59ab0ab77d91f9d855bd5a3fc0e5c691220f01 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 11 Apr 2023 23:12:32 +0300 Subject: SL-19533 Further logging improvements --- indra/newview/llinventorymodelbackgroundfetch.cpp | 26 ++++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 0099e81b8f..955f152195 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -190,6 +190,7 @@ LLInventoryModelBackgroundFetch::LLInventoryModelBackgroundFetch(): mBackgroundFetchActive(false), mFolderFetchActive(false), mFetchCount(0), + mLastFetchCount(0), mFetchFolderCount(0), mAllRecursiveFoldersFetched(false), mRecursiveInventoryFetchStarted(false), @@ -424,13 +425,13 @@ void LLInventoryModelBackgroundFetch::backgroundFetchCB(void *) void LLInventoryModelBackgroundFetch::backgroundFetch() { - if (mBackgroundFetchActive && gAgent.getRegion() && gAgent.getRegion()->capabilitiesReceived()) + if (mBackgroundFetchActive) { if (AISAPI::isAvailable()) { bulkFetchViaAis(); } - else + else if (gAgent.getRegion() && gAgent.getRegion()->capabilitiesReceived()) { // If we'll be using the capability, we'll be sending batches and the background thing isn't as important. bulkFetch(); @@ -460,6 +461,7 @@ void LLInventoryModelBackgroundFetch::incrFetchFolderCount(S32 fetching) void ais_simple_folder_callback(const LLUUID& inv_id) { + LL_DEBUGS("AIS3") << "Response for folder " << inv_id << LL_ENDL; LLInventoryModelBackgroundFetch::instance().incrFetchFolderCount(-1); if (inv_id.notNull()) // null normally means a failure, but is an expected response for orphans { @@ -473,6 +475,7 @@ void ais_simple_folder_callback(const LLUUID& inv_id) void ais_simple_item_callback(const LLUUID& inv_id) { + LL_DEBUGS("AIS3") << "Response for " << inv_id << LL_ENDL; LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1); } @@ -481,6 +484,7 @@ void LLInventoryModelBackgroundFetch::onAISFodlerCalback(const LLUUID &request_i incrFetchFolderCount(-1); if (response_id.isNull()) // Failure { + LL_DEBUGS("AIS3") << "Failure response for folder " << request_id << LL_ENDL; if (recursion == FT_RECURSIVE) { // A full recursive request failed. @@ -513,6 +517,7 @@ void LLInventoryModelBackgroundFetch::onAISFodlerCalback(const LLUUID &request_i } else { + LL_DEBUGS("AIS3") << "Got folder " << request_id << LL_ENDL; if (recursion == FT_CONTENT_RECURSIVE) { // Got the folder, now recursively request content @@ -567,6 +572,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() ? 0.006f // 6 ms : 1.f; const F64 end_time = curent_time + max_time; + S32 last_fetch_count = mFetchCount; while (!mFetchFolderQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) { @@ -589,10 +595,15 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() } } - LL_DEBUGS(LOG_INV , "AIS3") << "Total active fetches: " << mFetchCount - << ", scheduled fodler fetches: " << (S32)mFetchFolderQueue.size() - << ", scheduled item fetches: " << (S32)mFetchItemQueue.size() - << LL_ENDL; + if (last_fetch_count != mFetchCount // if anything was added + || mLastFetchCount != mFetchCount) // if anything was substracted + { + mLastFetchCount = mFetchCount; + LL_DEBUGS(LOG_INV , "AIS3") << "Total active fetches: " << last_fetch_count << "->" << mFetchCount + << ", scheduled fodler fetches: " << (S32)mFetchFolderQueue.size() + << ", scheduled item fetches: " << (S32)mFetchItemQueue.size() + << LL_ENDL; + } if (isFolderFetchProcessingComplete() && mFolderFetchActive) { @@ -619,7 +630,6 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc } else { - LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); if (cat) { @@ -630,9 +640,9 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc ? LLViewerInventoryCategory::FETCH_RECURSIVE : LLViewerInventoryCategory::FETCH_NORMAL; // start again if we did a non-recursive fetch before + // to get all children in a single request if (cat->getFetching() < target_state) { - if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) { AISAPI::FetchCategoryChildren(cat->getUUID(), AISAPI::LIBRARY, fetch_info.mFetchType == FT_RECURSIVE, ais_simple_folder_callback); -- cgit v1.2.3 From 627c4e45baec177dd8e0a07b0c3137492819c0ca Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 12 Apr 2023 00:25:34 +0300 Subject: SL-19533 Track folder fetch requests in bulk fetch --- indra/newview/llinventorymodelbackgroundfetch.cpp | 108 ++++++++++++++-------- 1 file changed, 71 insertions(+), 37 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 955f152195..cab3010cf1 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -459,29 +459,33 @@ void LLInventoryModelBackgroundFetch::incrFetchFolderCount(S32 fetching) } } -void ais_simple_folder_callback(const LLUUID& inv_id) -{ - LL_DEBUGS("AIS3") << "Response for folder " << inv_id << LL_ENDL; - LLInventoryModelBackgroundFetch::instance().incrFetchFolderCount(-1); - if (inv_id.notNull()) // null normally means a failure, but is an expected response for orphans - { - LLViewerInventoryCategory* cat(gInventory.getCategory(inv_id)); - if (cat) - { - cat->setFetching(LLViewerInventoryCategory::FETCH_NONE); - } - } -} - void ais_simple_item_callback(const LLUUID& inv_id) { LL_DEBUGS("AIS3") << "Response for " << inv_id << LL_ENDL; LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1); } -void LLInventoryModelBackgroundFetch::onAISFodlerCalback(const LLUUID &request_id, const LLUUID &response_id, EFetchType recursion) +void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_id, const LLUUID &response_id, EFetchType recursion) { incrFetchFolderCount(-1); + std::list::const_iterator found = std::find(mExpectedFolderIds.begin() , mExpectedFolderIds.end(), request_id); + if (found != mExpectedFolderIds.end()) + { + mExpectedFolderIds.erase(found); + } + else + { + // ais shouldn't respond twice + llassert(false); + LL_WARNS() << "Unexpected folder response for " << request_id << LL_ENDL; + } + + if (request_id.isNull()) + { + // orhans, no other actions needed + return; + } + if (response_id.isNull()) // Failure { LL_DEBUGS("AIS3") << "Failure response for folder " << request_id << LL_ENDL; @@ -598,11 +602,36 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() if (last_fetch_count != mFetchCount // if anything was added || mLastFetchCount != mFetchCount) // if anything was substracted { - mLastFetchCount = mFetchCount; - LL_DEBUGS(LOG_INV , "AIS3") << "Total active fetches: " << last_fetch_count << "->" << mFetchCount + LL_DEBUGS(LOG_INV , "AIS3") << "Total active fetches: " << mLastFetchCount << "->" << last_fetch_count << "->" << mFetchCount << ", scheduled fodler fetches: " << (S32)mFetchFolderQueue.size() << ", scheduled item fetches: " << (S32)mFetchItemQueue.size() << LL_ENDL; + mLastFetchCount = mFetchCount; + + if (!mExpectedFolderIds.empty()) + { + // A folder seem to be stack fetching on QA account, print oldest folder out + LL_DEBUGS("AIS3") << "Oldest expected folder: "; + std::list::const_iterator iter = mExpectedFolderIds.begin(); + LL_CONT << *iter; + if ((*iter).notNull()) + { + LLViewerInventoryCategory* cat(gInventory.getCategory(*iter)); + if (cat) + { + LL_CONT << " Folder name: " << cat->getName() << " Parent: " << cat->getParentUUID(); + } + else + { + LL_CONT << " This folder doesn't exist"; + } + } + else + { + LL_CONT << " Orphans request"; + } + LL_CONT << LL_ENDL; + } } if (isFolderFetchProcessingComplete() && mFolderFetchActive) @@ -623,10 +652,16 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc const LLUUID & cat_id(fetch_info.mUUID); if (cat_id.isNull()) { + incrFetchFolderCount(1); + mExpectedFolderIds.push_back(cat_id); // Lost and found // Should it actually be recursive? - AISAPI::FetchOrphans(ais_simple_folder_callback); - incrFetchFolderCount(1); + AISAPI::FetchOrphans([](const LLUUID& response_id) + { + LLInventoryModelBackgroundFetch::instance().onAISFolderCalback(LLUUID::null, + response_id, + FT_DEFAULT); + }); } else { @@ -643,26 +678,25 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc // to get all children in a single request if (cat->getFetching() < target_state) { - if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) + // increment before call in case of immediate callback + incrFetchFolderCount(1); + cat->setFetching(target_state); + mExpectedFolderIds.push_back(cat_id); + + EFetchType type = fetch_info.mFetchType; + LLUUID cat_id = cat->getUUID(); + AISAPI::completion_t cb = [cat_id , type](const LLUUID& response_id) { - AISAPI::FetchCategoryChildren(cat->getUUID(), AISAPI::LIBRARY, fetch_info.mFetchType == FT_RECURSIVE, ais_simple_folder_callback); - } - else + LLInventoryModelBackgroundFetch::instance().onAISFolderCalback(cat_id , response_id , type); + }; + + AISAPI::ITEM_TYPE item_type = AISAPI::INVENTORY; + if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) { - LLUUID cat_id = cat->getUUID(); - EFetchType type = fetch_info.mFetchType; - AISAPI::FetchCategoryChildren( - cat_id, - AISAPI::INVENTORY, - type == FT_RECURSIVE, - [cat_id, type](const LLUUID &response_id) - { - LLInventoryModelBackgroundFetch::instance().onAISFodlerCalback(cat_id, response_id, type); - }); + item_type = AISAPI::LIBRARY; } - incrFetchFolderCount(1); - cat->setFetching(target_state); + AISAPI::FetchCategoryChildren(cat_id , item_type , type == FT_RECURSIVE , cb); } } else @@ -693,6 +727,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc { if (!itemp->isFinished() || fetch_info.mFetchType == FT_FORCED) { + mFetchCount++; if (itemp->getPermissions().getOwner() == gAgent.getID()) { AISAPI::FetchItem(fetch_info.mUUID, AISAPI::INVENTORY, ais_simple_item_callback); @@ -701,14 +736,13 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc { AISAPI::FetchItem(fetch_info.mUUID, AISAPI::LIBRARY, ais_simple_item_callback); } - mFetchCount++; } } else // We don't know it, assume incomplete { // Assume agent's inventory, library wouldn't have gotten here - AISAPI::FetchItem(fetch_info.mUUID, AISAPI::INVENTORY, ais_simple_item_callback); mFetchCount++; + AISAPI::FetchItem(fetch_info.mUUID, AISAPI::INVENTORY, ais_simple_item_callback); } } } -- cgit v1.2.3 From 1f2cbfdbe227bda2f3bd2b17b5ac1b125cb28b2d Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 12 Apr 2023 00:53:48 +0300 Subject: SL-19533 Content should be recursive only --- indra/newview/llinventorymodelbackgroundfetch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index cab3010cf1..69f688d51e 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -712,7 +712,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc ++it) { // not push_front to not cause an infinite loop - mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mFetchType)); + mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); } } } -- cgit v1.2.3 From 8b1a7085be07704a58e169d1133fc356a1745c74 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 12 Apr 2023 19:13:32 +0300 Subject: SL-19533 Logging tag change --- indra/newview/llinventorymodelbackgroundfetch.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 69f688d51e..f650cc383f 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -461,7 +461,7 @@ void LLInventoryModelBackgroundFetch::incrFetchFolderCount(S32 fetching) void ais_simple_item_callback(const LLUUID& inv_id) { - LL_DEBUGS("AIS3") << "Response for " << inv_id << LL_ENDL; + LL_DEBUGS(LOG_INV , "AIS3") << "Response for " << inv_id << LL_ENDL; LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1); } @@ -488,7 +488,7 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i if (response_id.isNull()) // Failure { - LL_DEBUGS("AIS3") << "Failure response for folder " << request_id << LL_ENDL; + LL_DEBUGS(LOG_INV , "AIS3") << "Failure response for folder " << request_id << LL_ENDL; if (recursion == FT_RECURSIVE) { // A full recursive request failed. @@ -521,7 +521,7 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i } else { - LL_DEBUGS("AIS3") << "Got folder " << request_id << LL_ENDL; + LL_DEBUGS(LOG_INV , "AIS3") << "Got folder " << request_id << LL_ENDL; if (recursion == FT_CONTENT_RECURSIVE) { // Got the folder, now recursively request content @@ -611,7 +611,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() if (!mExpectedFolderIds.empty()) { // A folder seem to be stack fetching on QA account, print oldest folder out - LL_DEBUGS("AIS3") << "Oldest expected folder: "; + LL_DEBUGS(LOG_INV , "AIS3") << "Oldest expected folder: "; std::list::const_iterator iter = mExpectedFolderIds.begin(); LL_CONT << *iter; if ((*iter).notNull()) -- cgit v1.2.3 From 53f2e1710aab77361085fe2c2a41fea87ede0fb8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 13 Apr 2023 02:20:33 +0300 Subject: SL-19533 Faster declouding --- indra/newview/llinventorymodelbackgroundfetch.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index f650cc383f..56646830a2 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -586,17 +586,15 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() curent_time = LLTimer::getTotalSeconds(); } - if (mRecursiveInventoryFetchStarted && mAllRecursiveFoldersFetched) + // Ideally we shouldn't fetch items if recursive fetch isn't done, + // but there is a chance some request will start timeouting and recursive + // fetch will get stuck on a signle folder, don't block item fetch in such case + while (!mFetchItemQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) { - // Don't fetch items if recursive fetch isn't done, - // it gets both items and folders and should get the items in question faster - while (!mFetchItemQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) - { - const FetchQueueInfo& fetch_info(mFetchItemQueue.front()); - bulkFetchViaAis(fetch_info); - mFetchItemQueue.pop_front(); - curent_time = LLTimer::getTotalSeconds(); - } + const FetchQueueInfo& fetch_info(mFetchItemQueue.front()); + bulkFetchViaAis(fetch_info); + mFetchItemQueue.pop_front(); + curent_time = LLTimer::getTotalSeconds(); } if (last_fetch_count != mFetchCount // if anything was added @@ -696,7 +694,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc item_type = AISAPI::LIBRARY; } - AISAPI::FetchCategoryChildren(cat_id , item_type , type == FT_RECURSIVE , cb); + AISAPI::FetchCategoryChildren(cat_id , item_type , type == FT_RECURSIVE , cb, 0); } } else -- cgit v1.2.3 From 97b0f637dfbd4ab2b3fe79442e9f847cf7a6efca Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 19 Apr 2023 00:20:09 +0300 Subject: SL-19533 Check descendants even for a recursive fetch --- indra/newview/llinventorymodelbackgroundfetch.cpp | 48 ++++++++++++----------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 56646830a2..bfb5ad9d12 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -486,6 +486,7 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i return; } + bool request_descendants = false; if (response_id.isNull()) // Failure { LL_DEBUGS(LOG_INV , "AIS3") << "Failure response for folder " << request_id << LL_ENDL; @@ -501,36 +502,37 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i else if (recursion == FT_CONTENT_RECURSIVE) { LL_WARNS() << "Failed to download folder: " << request_id << " Requesting known content separately" << LL_ENDL; - LLInventoryModel::cat_array_t *categories(NULL); - LLInventoryModel::item_array_t *items(NULL); - gInventory.getDirectDescendentsOf(request_id, categories, items); - if (categories) - { - for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); it != categories->end(); ++it) - { - mFetchFolderQueue.push_front(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); - } - if (!mFetchFolderQueue.empty()) - { - mBackgroundFetchActive = true; - mFolderFetchActive = true; - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); - } - } + request_descendants = true; } } else { - LL_DEBUGS(LOG_INV , "AIS3") << "Got folder " << request_id << LL_ENDL; - if (recursion == FT_CONTENT_RECURSIVE) + if (recursion == FT_CONTENT_RECURSIVE || recursion == FT_RECURSIVE) { // Got the folder, now recursively request content - LLInventoryModel::cat_array_t * categories(NULL); - LLInventoryModel::item_array_t * items(NULL); - gInventory.getDirectDescendentsOf(request_id, categories, items); + // Request content even for FT_RECURSIVE in case of changes, failures + // or if depth limit gets imlemented. + // This shouldn't redownload folders if they already have version + request_descendants = true; + LL_DEBUGS(LOG_INV, "AIS3") << "Got folder " << request_id << ". Requesting content" << LL_ENDL; + } + else + { + LL_DEBUGS(LOG_INV, "AIS3") << "Got folder " << request_id << "." << LL_ENDL; + } + + } + + if (request_descendants) + { + LLInventoryModel::cat_array_t* categories(NULL); + LLInventoryModel::item_array_t* items(NULL); + gInventory.getDirectDescendentsOf(request_id, categories, items); + if (categories) + { for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); - it != categories->end(); - ++it) + it != categories->end(); + ++it) { mFetchFolderQueue.push_front(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); } -- cgit v1.2.3 From 9c2b0c709b3d1cf1a9243853a8df7089e2494057 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 25 Apr 2023 01:34:35 +0300 Subject: SL-19533 Special COF handling --- indra/newview/llinventorymodelbackgroundfetch.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index bfb5ad9d12..f56532ff8c 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -391,6 +391,12 @@ void LLInventoryModelBackgroundFetch::findLostItems() gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } +void LLInventoryModelBackgroundFetch::fetchCOF() +{ + // Will get COF folder, links in it and items those links point to + AISAPI::FetchCOF(); +} + void LLInventoryModelBackgroundFetch::setAllFoldersFetched() { if (mRecursiveInventoryFetchStarted && -- cgit v1.2.3 From 154ab03bf8a5dacc3128718d1f15160f0cbe2b33 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 25 Apr 2023 03:38:26 +0300 Subject: SL-19533 Special COF handling #2 --- indra/newview/llinventorymodelbackgroundfetch.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index f56532ff8c..277ddb16ba 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -354,17 +354,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) void LLInventoryModelBackgroundFetch::scheduleFolderFetch(const LLUUID& cat_id, bool forced) { - if (AISAPI::isAvailable()) - { - if (mFetchFolderQueue.empty() || mFetchFolderQueue.back().mUUID != cat_id) - { - // On AIS make sure root goes to the top and follow up recursive - // fetches, not individual requests - mFetchFolderQueue.push_back(FetchQueueInfo(cat_id, forced ? FT_FORCED : FT_DEFAULT)); - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); - } - } - else if (mFetchFolderQueue.empty() || mFetchFolderQueue.front().mUUID != cat_id) + if (mFetchFolderQueue.empty() || mFetchFolderQueue.front().mUUID != cat_id) { // Specific folder requests go to front of queue. mFetchFolderQueue.push_front(FetchQueueInfo(cat_id, forced ? FT_FORCED : FT_DEFAULT)); @@ -391,12 +381,6 @@ void LLInventoryModelBackgroundFetch::findLostItems() gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); } -void LLInventoryModelBackgroundFetch::fetchCOF() -{ - // Will get COF folder, links in it and items those links point to - AISAPI::FetchCOF(); -} - void LLInventoryModelBackgroundFetch::setAllFoldersFetched() { if (mRecursiveInventoryFetchStarted && -- cgit v1.2.3 From c008d3e030ca4019e24de9a4831dc36727555fd2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 25 Apr 2023 12:25:15 +0300 Subject: SL-19533 Reduce inventory fetch stalls --- indra/newview/llinventorymodelbackgroundfetch.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 277ddb16ba..c5fb40409f 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -555,6 +555,8 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() } static LLCachedControl ais_pool(gSavedSettings, "PoolSizeAIS", 20); + // Don't have too many requests at once + // Reserve one request for actions outside of fetch (like renames) const U32 max_concurrent_fetches = llmax(1, ais_pool - 1); if (mFetchCount >= max_concurrent_fetches) @@ -562,6 +564,9 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() return; } + // Don't fire all requests at once + const U32 max_requests_this_run = llmin(mFetchCount + 5, max_concurrent_fetches); + // Don't loop for too long (in case of large, fully loaded inventory) F64 curent_time = LLTimer::getTotalSeconds(); const F64 max_time = LLStartUp::getStartupState() > STATE_WEARABLES_WAIT @@ -570,7 +575,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() const F64 end_time = curent_time + max_time; S32 last_fetch_count = mFetchCount; - while (!mFetchFolderQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) + while (!mFetchFolderQueue.empty() && mFetchCount < max_requests_this_run && curent_time < end_time) { const FetchQueueInfo & fetch_info(mFetchFolderQueue.front()); bulkFetchViaAis(fetch_info); @@ -581,7 +586,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() // Ideally we shouldn't fetch items if recursive fetch isn't done, // but there is a chance some request will start timeouting and recursive // fetch will get stuck on a signle folder, don't block item fetch in such case - while (!mFetchItemQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) + while (!mFetchItemQueue.empty() && mFetchCount < max_requests_this_run && curent_time < end_time) { const FetchQueueInfo& fetch_info(mFetchItemQueue.front()); bulkFetchViaAis(fetch_info); -- cgit v1.2.3 From 697d3be3c9906a6d578a961710fc43816b6adeae Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 27 Apr 2023 01:30:57 +0300 Subject: SL-19533 Implement subset variant of children request --- indra/newview/llinventorymodelbackgroundfetch.cpp | 195 +++++++++++++++++++--- 1 file changed, 171 insertions(+), 24 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index c5fb40409f..b8fdfab98a 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -299,7 +299,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) // Not only root folder can be massive, but // most system folders will be requested independently // so request root folder and content separately - mFetchFolderQueue.push_front(FetchQueueInfo(gInventory.getRootFolderID(), FT_CONTENT_RECURSIVE)); + mFetchFolderQueue.push_front(FetchQueueInfo(gInventory.getRootFolderID(), FT_FOLDER_AND_CONTENT)); } else { @@ -455,10 +455,67 @@ void ais_simple_item_callback(const LLUUID& inv_id) LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1); } -void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_id, const LLUUID &response_id, EFetchType recursion) +void LLInventoryModelBackgroundFetch::onAISContentCalback( + const LLUUID& request_id, + const uuid_vec_t& content_ids, + const LLUUID& response_id, + EFetchType fetch_type) { + // Don't push_front on failure - there is a chance it was fired from inside bulkFetchViaAis incrFetchFolderCount(-1); - std::list::const_iterator found = std::find(mExpectedFolderIds.begin() , mExpectedFolderIds.end(), request_id); + + uuid_vec_t::const_iterator folder_iter = content_ids.begin(); + uuid_vec_t::const_iterator folder_end = content_ids.end(); + while (folder_iter != folder_end) + { + std::list::const_iterator found = std::find(mExpectedFolderIds.begin(), mExpectedFolderIds.end(), *folder_iter); + if (found != mExpectedFolderIds.end()) + { + mExpectedFolderIds.erase(found); + } + + LLViewerInventoryCategory* cat(gInventory.getCategory(*folder_iter)); + if (cat) + { + cat->setFetching(LLViewerInventoryCategory::FETCH_NONE); + } + if (response_id.isNull()) + { + // Failed to fetch, get it individually + mFetchFolderQueue.push_back(FetchQueueInfo(*folder_iter, FT_RECURSIVE)); + } + else + { + // push descendant back to verify they are fetched fully (ex: didn't encounter depth limit) + LLInventoryModel::cat_array_t* categories(NULL); + LLInventoryModel::item_array_t* items(NULL); + gInventory.getDirectDescendentsOf(*folder_iter, categories, items); + if (categories) + { + for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); + it != categories->end(); + ++it) + { + mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); + } + } + } + + folder_iter++; + } + + if (!mFetchFolderQueue.empty()) + { + mBackgroundFetchActive = true; + mFolderFetchActive = true; + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + } +} +void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_id, const LLUUID &response_id, EFetchType fetch_type) +{ + // Don't push_front on failure - there is a chance it was fired from inside bulkFetchViaAis + incrFetchFolderCount(-1); + std::list::const_iterator found = std::find(mExpectedFolderIds.begin(), mExpectedFolderIds.end(), request_id); if (found != mExpectedFolderIds.end()) { mExpectedFolderIds.erase(found); @@ -480,32 +537,34 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i if (response_id.isNull()) // Failure { LL_DEBUGS(LOG_INV , "AIS3") << "Failure response for folder " << request_id << LL_ENDL; - if (recursion == FT_RECURSIVE) + if (fetch_type == FT_RECURSIVE) { // A full recursive request failed. // Try requesting folder and nested content separately - mBackgroundFetchActive = true; - mFolderFetchActive = true; - mFetchFolderQueue.push_front(FetchQueueInfo(request_id, FT_CONTENT_RECURSIVE)); - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + mFetchFolderQueue.push_back(FetchQueueInfo(request_id, FT_FOLDER_AND_CONTENT)); } - else if (recursion == FT_CONTENT_RECURSIVE) + else if (fetch_type == FT_FOLDER_AND_CONTENT) { LL_WARNS() << "Failed to download folder: " << request_id << " Requesting known content separately" << LL_ENDL; - request_descendants = true; + mFetchFolderQueue.push_back(FetchQueueInfo(request_id, FT_CONTENT_RECURSIVE)); } } else { - if (recursion == FT_CONTENT_RECURSIVE || recursion == FT_RECURSIVE) + if (fetch_type == FT_RECURSIVE) { - // Got the folder, now recursively request content + // Got the folder and content, now verify content // Request content even for FT_RECURSIVE in case of changes, failures // or if depth limit gets imlemented. // This shouldn't redownload folders if they already have version request_descendants = true; LL_DEBUGS(LOG_INV, "AIS3") << "Got folder " << request_id << ". Requesting content" << LL_ENDL; } + else if (fetch_type == FT_FOLDER_AND_CONTENT) + { + // readd folder for content request + mFetchFolderQueue.push_front(FetchQueueInfo(request_id, FT_CONTENT_RECURSIVE)); + } else { LL_DEBUGS(LOG_INV, "AIS3") << "Got folder " << request_id << "." << LL_ENDL; @@ -524,17 +583,18 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i it != categories->end(); ++it) { - mFetchFolderQueue.push_front(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); - } - if (!mFetchFolderQueue.empty()) - { - mBackgroundFetchActive = true; - mFolderFetchActive = true; - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); } } } + if (!mFetchFolderQueue.empty()) + { + mBackgroundFetchActive = true; + mFolderFetchActive = true; + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + } + // done LLViewerInventoryCategory * cat(gInventory.getCategory(request_id)); if (cat) @@ -555,9 +615,9 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() } static LLCachedControl ais_pool(gSavedSettings, "PoolSizeAIS", 20); - // Don't have too many requests at once + // Don't have too many requests at once, AIS throttles // Reserve one request for actions outside of fetch (like renames) - const U32 max_concurrent_fetches = llmax(1, ais_pool - 1); + const U32 max_concurrent_fetches = llclamp(ais_pool - 1, 1, 50); if (mFetchCount >= max_concurrent_fetches) { @@ -663,10 +723,97 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); if (cat) { - if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion() || fetch_info.mFetchType == FT_FORCED) + if (fetch_info.mFetchType == FT_CONTENT_RECURSIVE) + { + // fetch content only, ignore cat itself + uuid_vec_t children; + LLInventoryModel::cat_array_t* categories(NULL); + LLInventoryModel::item_array_t* items(NULL); + gInventory.getDirectDescendentsOf(cat_id, categories, items); + + LLViewerInventoryCategory::EFetchType target_state = + fetch_info.mFetchType > FT_CONTENT_RECURSIVE + ? LLViewerInventoryCategory::FETCH_RECURSIVE + : LLViewerInventoryCategory::FETCH_NORMAL; + // technically limit is 'as many as you can put into url', but for now stop at 10 + const S32 batch_limit = 10; + bool content_done = true; + + for (LLInventoryModel::cat_array_t::iterator it = categories->begin(); + it != categories->end(); + ++it) + { + LLViewerInventoryCategory* child_cat = (*it); + if (LLViewerInventoryCategory::VERSION_UNKNOWN != child_cat->getVersion() + || child_cat->getFetching() >= target_state) + { + // push it back to verify everything inside is fetched + mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); + continue; + } + + if (child_cat->getPreferredType() == LLFolderType::FT_MARKETPLACE_LISTINGS) + { + // special case + content_done = false; + if (children.empty()) + { + // fetch marketplace alone + children.push_back(child_cat->getUUID()); + mExpectedFolderIds.push_back(child_cat->getUUID()); + child_cat->setFetching(target_state); + break; + } + else + { + // fetch marketplace alone next run + continue; + } + } + + children.push_back(child_cat->getUUID()); + mExpectedFolderIds.push_back(child_cat->getUUID()); + child_cat->setFetching(target_state); + + if (children.size() >= batch_limit) + { + content_done = false; + break; + } + } + + if (!children.empty()) + { + // increment before call in case of immediate callback + incrFetchFolderCount(1); + + EFetchType type = fetch_info.mFetchType; + LLUUID cat_id = cat->getUUID(); // need a copy for lambda + AISAPI::completion_t cb = [cat_id, children, type](const LLUUID& response_id) + { + LLInventoryModelBackgroundFetch::instance().onAISContentCalback(cat_id, children, response_id, type); + }; + + AISAPI::ITEM_TYPE item_type = AISAPI::INVENTORY; + if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) + { + item_type = AISAPI::LIBRARY; + } + + AISAPI::FetchCategorySubset(cat_id, children, item_type, true, cb, 0); + } + + if (!content_done) + { + // send it back to get the rest + mFetchFolderQueue.push_back(FetchQueueInfo(cat_id, FT_CONTENT_RECURSIVE)); + } + } + else if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion() + || fetch_info.mFetchType == FT_FORCED) { LLViewerInventoryCategory::EFetchType target_state = - fetch_info.mFetchType >= FT_CONTENT_RECURSIVE + fetch_info.mFetchType > FT_CONTENT_RECURSIVE ? LLViewerInventoryCategory::FETCH_RECURSIVE : LLViewerInventoryCategory::FETCH_NORMAL; // start again if we did a non-recursive fetch before @@ -711,7 +858,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc } } } - } // else? + } // else try to fetch folder either way? } } else -- cgit v1.2.3 From 7bb564496997e26a4c9770cb509955d0a22d1617 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 27 Apr 2023 20:23:13 +0300 Subject: SL-19533 Subset fetch fixes --- indra/newview/llinventorymodelbackgroundfetch.cpp | 28 ++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index b8fdfab98a..3a2120750b 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -731,10 +731,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc LLInventoryModel::item_array_t* items(NULL); gInventory.getDirectDescendentsOf(cat_id, categories, items); - LLViewerInventoryCategory::EFetchType target_state = - fetch_info.mFetchType > FT_CONTENT_RECURSIVE - ? LLViewerInventoryCategory::FETCH_RECURSIVE - : LLViewerInventoryCategory::FETCH_NORMAL; + LLViewerInventoryCategory::EFetchType target_state = LLViewerInventoryCategory::FETCH_RECURSIVE; // technically limit is 'as many as you can put into url', but for now stop at 10 const S32 batch_limit = 10; bool content_done = true; @@ -747,8 +744,6 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc if (LLViewerInventoryCategory::VERSION_UNKNOWN != child_cat->getVersion() || child_cat->getFetching() >= target_state) { - // push it back to verify everything inside is fetched - mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); continue; } @@ -759,6 +754,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc if (children.empty()) { // fetch marketplace alone + // Should it actually be fetched as FT_FOLDER_AND_CONTENT? children.push_back(child_cat->getUUID()); mExpectedFolderIds.push_back(child_cat->getUUID()); child_cat->setFetching(target_state); @@ -803,7 +799,23 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc AISAPI::FetchCategorySubset(cat_id, children, item_type, true, cb, 0); } - if (!content_done) + if (content_done) + { + // This will have a bit of overlap with onAISContentCalback, + // but something else might have dowloaded folders, so verify + // every child that is complete has it's children done as well + for (LLInventoryModel::cat_array_t::iterator it = categories->begin(); + it != categories->end(); + ++it) + { + LLViewerInventoryCategory* child_cat = (*it); + if (LLViewerInventoryCategory::VERSION_UNKNOWN != child_cat->getVersion()) + { + mFetchFolderQueue.push_back(FetchQueueInfo(child_cat->getUUID(), FT_RECURSIVE)); + } + } + } + else { // send it back to get the rest mFetchFolderQueue.push_back(FetchQueueInfo(cat_id, FT_CONTENT_RECURSIVE)); @@ -844,7 +856,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc else { // Already fetched, check if anything inside needs fetching - if (fetch_info.mFetchType >= FT_CONTENT_RECURSIVE) + if (fetch_info.mFetchType == FT_RECURSIVE) { LLInventoryModel::cat_array_t * categories(NULL); LLInventoryModel::item_array_t * items(NULL); -- cgit v1.2.3 From 377f177a8667702eee12414fb5534fd6732da1d2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 27 Apr 2023 21:32:17 +0300 Subject: SL-19533 Removed per-run limit Doesn't seem to work like expected and I never get more than 7-9 requests running total --- indra/newview/llinventorymodelbackgroundfetch.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 3a2120750b..5b8ee6e244 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -624,9 +624,6 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() return; } - // Don't fire all requests at once - const U32 max_requests_this_run = llmin(mFetchCount + 5, max_concurrent_fetches); - // Don't loop for too long (in case of large, fully loaded inventory) F64 curent_time = LLTimer::getTotalSeconds(); const F64 max_time = LLStartUp::getStartupState() > STATE_WEARABLES_WAIT @@ -635,7 +632,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() const F64 end_time = curent_time + max_time; S32 last_fetch_count = mFetchCount; - while (!mFetchFolderQueue.empty() && mFetchCount < max_requests_this_run && curent_time < end_time) + while (!mFetchFolderQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) { const FetchQueueInfo & fetch_info(mFetchFolderQueue.front()); bulkFetchViaAis(fetch_info); @@ -646,7 +643,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() // Ideally we shouldn't fetch items if recursive fetch isn't done, // but there is a chance some request will start timeouting and recursive // fetch will get stuck on a signle folder, don't block item fetch in such case - while (!mFetchItemQueue.empty() && mFetchCount < max_requests_this_run && curent_time < end_time) + while (!mFetchItemQueue.empty() && mFetchCount < max_concurrent_fetches && curent_time < end_time) { const FetchQueueInfo& fetch_info(mFetchItemQueue.front()); bulkFetchViaAis(fetch_info); -- cgit v1.2.3 From 9349a9b5d4ccb21f195e5c156d897836399fd11b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 28 Apr 2023 00:18:46 +0300 Subject: SL-19533 More children per subset fetch request --- indra/newview/llinventorymodelbackgroundfetch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 5b8ee6e244..5f7950df08 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -730,7 +730,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc LLViewerInventoryCategory::EFetchType target_state = LLViewerInventoryCategory::FETCH_RECURSIVE; // technically limit is 'as many as you can put into url', but for now stop at 10 - const S32 batch_limit = 10; + const S32 batch_limit = 20; bool content_done = true; for (LLInventoryModel::cat_array_t::iterator it = categories->begin(); -- cgit v1.2.3 From 03c263a1cdd88ec5967e751cba8640edf9896e51 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 28 Apr 2023 23:37:34 +0300 Subject: SL-19533 Fix 'fetching' state timeout --- indra/newview/llinventorymodelbackgroundfetch.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 5f7950df08..8f1012868f 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -729,10 +729,12 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc gInventory.getDirectDescendentsOf(cat_id, categories, items); LLViewerInventoryCategory::EFetchType target_state = LLViewerInventoryCategory::FETCH_RECURSIVE; - // technically limit is 'as many as you can put into url', but for now stop at 10 - const S32 batch_limit = 20; bool content_done = true; + // Top limit is 'as many as you can put into url' + static LLCachedControl ais_batch(gSavedSettings, "BatchSizeAIS3", 20); + S32 batch_limit = llclamp(ais_batch(), 1, 40); + for (LLInventoryModel::cat_array_t::iterator it = categories->begin(); it != categories->end(); ++it) -- cgit v1.2.3 From 352ca2f881b02bd455d0f191d93737d3dc3dd52d Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 25 Apr 2023 22:47:31 +0300 Subject: SL-19652 Folder fetch dupplicate protection and over limit handling --- indra/newview/llinventorymodelbackgroundfetch.cpp | 73 ++++++++++++++++++----- 1 file changed, 59 insertions(+), 14 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 8f1012868f..b0ebe83f57 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -945,6 +945,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() // *TODO: Think I'd like to get a shared pointer to this and share it // among all the folder requests. uuid_vec_t recursive_cats; + uuid_vec_t all_cats; // dupplicate avoidance LLSD folder_request_body; LLSD folder_request_body_lib; @@ -976,22 +977,25 @@ void LLInventoryModelBackgroundFetch::bulkFetch() { if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion()) { - LLSD folder_sd; - folder_sd["folder_id"] = cat->getUUID(); - folder_sd["owner_id"] = cat->getOwnerID(); - folder_sd["sort_order"] = LLSD::Integer(sort_order); - folder_sd["fetch_folders"] = LLSD::Boolean(true); //(LLSD::Boolean)sFullFetchStarted; - folder_sd["fetch_items"] = LLSD::Boolean(true); - - if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) - { - folder_request_body_lib["folders"].append(folder_sd); - } - else + if (std::find(all_cats.begin(), all_cats.end(), cat_id) == all_cats.end()) { - folder_request_body["folders"].append(folder_sd); + LLSD folder_sd; + folder_sd["folder_id"] = cat->getUUID(); + folder_sd["owner_id"] = cat->getOwnerID(); + folder_sd["sort_order"] = LLSD::Integer(sort_order); + folder_sd["fetch_folders"] = LLSD::Boolean(TRUE); //(LLSD::Boolean)sFullFetchStarted; + folder_sd["fetch_items"] = LLSD::Boolean(TRUE); + + if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID()) + { + folder_request_body_lib["folders"].append(folder_sd); + } + else + { + folder_request_body["folders"].append(folder_sd); + } + folder_count++; } - folder_count++; } else { @@ -1015,6 +1019,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() { recursive_cats.push_back(cat_id); } + all_cats.push_back(cat_id); } mFetchFolderQueue.pop_front(); @@ -1349,6 +1354,46 @@ void BGFolderHttpHandler::processFailure(LLCore::HttpStatus status, LLCore::Http << LLCoreHttpUtil::responseToString(response) << "]" << LL_ENDL; // Could use a 404 test here to try to detect revoked caps... + + if(status == LLCore::HttpStatus(HTTP_FORBIDDEN)) + { + // too large, split into two, assume that this isn't the library + const std::string url(gAgent.getRegionCapability("FetchInventoryDescendents2")); + S32 size = mRequestSD["folders"].size(); + + if (!gDisconnected && !LLApp::isExiting() && !url.empty() && size > 1) + { + LLSD folders; + uuid_vec_t recursive_cats; + LLSD::array_iterator iter = mRequestSD["folders"].beginArray(); + LLSD::array_iterator end = mRequestSD["folders"].endArray(); + while (iter != end) + { + folders.append(*iter); + LLUUID fodler_id = iter->get("folder_id").asUUID(); + if (std::find(mRecursiveCatUUIDs.begin(), mRecursiveCatUUIDs.end(), fodler_id) != mRecursiveCatUUIDs.end()) + { + recursive_cats.push_back(fodler_id); + } + if (folders.size() == (S32)(size / 2)) + { + LLSD request_body; + request_body["folders"] = folders; + LLCore::HttpHandler::ptr_t handler(new BGFolderHttpHandler(request_body, recursive_cats)); + gInventory.requestPost(false, url, request_body, handler, "Inventory Folder"); + recursive_cats.clear(); + folders.clear(); + } + iter++; + } + + LLSD request_body; + request_body["folders"] = folders; + LLCore::HttpHandler::ptr_t handler(new BGFolderHttpHandler(request_body, recursive_cats)); + gInventory.requestPost(false, url, request_body, handler, "Inventory Folder"); + return; + } + } // This was originally the request retry logic for the inventory // request which tested on HTTP_INTERNAL_ERROR status. This -- cgit v1.2.3 From b9fad316a356fd223dcf29ed000de1b86e6a93d3 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 29 May 2023 23:37:58 +0300 Subject: SL-17429 Message user when their inventory hits AIS2 limits --- indra/newview/llinventorymodelbackgroundfetch.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index b0ebe83f57..0eb07523ae 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -34,6 +34,7 @@ #include "llinventorymodel.h" #include "llinventoryobserver.h" #include "llinventorypanel.h" +#include "llnotificationsutil.h" #include "llstartup.h" #include "llviewercontrol.h" #include "llviewerinventory.h" @@ -1357,12 +1358,24 @@ void BGFolderHttpHandler::processFailure(LLCore::HttpStatus status, LLCore::Http if(status == LLCore::HttpStatus(HTTP_FORBIDDEN)) { - // too large, split into two, assume that this isn't the library + // Too large, split into two if possible + if (gDisconnected || LLApp::isExiting()) + { + return; + } + const std::string url(gAgent.getRegionCapability("FetchInventoryDescendents2")); + if (url.empty()) + { + LL_WARNS(LOG_INV) << "Failed to get AIS2 cap" << LL_ENDL; + return; + } + S32 size = mRequestSD["folders"].size(); - if (!gDisconnected && !LLApp::isExiting() && !url.empty() && size > 1) + if (size > 1) { + // Can split, assume that this isn't the library LLSD folders; uuid_vec_t recursive_cats; LLSD::array_iterator iter = mRequestSD["folders"].beginArray(); @@ -1393,6 +1406,11 @@ void BGFolderHttpHandler::processFailure(LLCore::HttpStatus status, LLCore::Http gInventory.requestPost(false, url, request_body, handler, "Inventory Folder"); return; } + else + { + // Can't split + LLNotificationsUtil::add("InventoryLimitReachedAIS"); + } } // This was originally the request retry logic for the inventory -- cgit v1.2.3 From 7e0dceca68e4b9d9d94b9e530954cba9366dc97e Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Wed, 21 Jun 2023 18:38:10 +0300 Subject: SL-19898 FIXED Contents purchased from items do not show in Recent Items until selecting folder --- indra/newview/llinventorymodelbackgroundfetch.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 0eb07523ae..26288e6b0a 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -357,6 +357,8 @@ void LLInventoryModelBackgroundFetch::scheduleFolderFetch(const LLUUID& cat_id, { if (mFetchFolderQueue.empty() || mFetchFolderQueue.front().mUUID != cat_id) { + mBackgroundFetchActive = true; + // Specific folder requests go to front of queue. mFetchFolderQueue.push_front(FetchQueueInfo(cat_id, forced ? FT_FORCED : FT_DEFAULT)); gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); -- cgit v1.2.3 From 74a1d2582c457aff738bf73c21e137015acfe6cb Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 17 Aug 2023 19:49:37 +0300 Subject: SL-20162 Better cof version logging And fixed some typos --- indra/newview/llinventorymodelbackgroundfetch.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 03205cfbda..44eccd955e 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -657,7 +657,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() || mLastFetchCount != mFetchCount) // if anything was substracted { LL_DEBUGS(LOG_INV , "AIS3") << "Total active fetches: " << mLastFetchCount << "->" << last_fetch_count << "->" << mFetchCount - << ", scheduled fodler fetches: " << (S32)mFetchFolderQueue.size() + << ", scheduled folder fetches: " << (S32)mFetchFolderQueue.size() << ", scheduled item fetches: " << (S32)mFetchItemQueue.size() << LL_ENDL; mLastFetchCount = mFetchCount; @@ -1384,10 +1384,10 @@ void BGFolderHttpHandler::processFailure(LLCore::HttpStatus status, LLCore::Http while (iter != end) { folders.append(*iter); - LLUUID fodler_id = iter->get("folder_id").asUUID(); - if (std::find(mRecursiveCatUUIDs.begin(), mRecursiveCatUUIDs.end(), fodler_id) != mRecursiveCatUUIDs.end()) + LLUUID folder_id = iter->get("folder_id").asUUID(); + if (std::find(mRecursiveCatUUIDs.begin(), mRecursiveCatUUIDs.end(), folder_id) != mRecursiveCatUUIDs.end()) { - recursive_cats.push_back(fodler_id); + recursive_cats.push_back(folder_id); } if (folders.size() == (S32)(size / 2)) { -- cgit v1.2.3 From f107d8431ccbd85bbe6f2ac0fd47cd409b8c0cfc Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 11 Sep 2023 17:31:08 +0300 Subject: SL-20199 Fix invalid or oversized folder being refetched indefinetely --- indra/newview/llinventorymodelbackgroundfetch.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 44eccd955e..07d5713fc8 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -549,6 +549,13 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i { LL_WARNS() << "Failed to download folder: " << request_id << " Requesting known content separately" << LL_ENDL; mFetchFolderQueue.push_back(FetchQueueInfo(request_id, FT_CONTENT_RECURSIVE)); + + // set folder's version to prevent viewer from trying to request folder indefinetely + LLViewerInventoryCategory* cat(gInventory.getCategory(request_id)); + if (cat->getVersion() == LLViewerInventoryCategory::VERSION_UNKNOWN) + { + cat->setVersion(0); + } } } else -- cgit v1.2.3 From 81752116e1243d68ae67c4771f267c4170dd9028 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 20 Sep 2023 18:48:13 +0300 Subject: SL-20298 Fix recursive fetch not working properly. --- indra/newview/llinventorymodelbackgroundfetch.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp') diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 07d5713fc8..91adef8047 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -864,7 +864,8 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc else { // Already fetched, check if anything inside needs fetching - if (fetch_info.mFetchType == FT_RECURSIVE) + if (fetch_info.mFetchType == FT_RECURSIVE + || fetch_info.mFetchType == FT_FOLDER_AND_CONTENT) { LLInventoryModel::cat_array_t * categories(NULL); LLInventoryModel::item_array_t * items(NULL); -- cgit v1.2.3