From 59a3bd493e9fd48a19ccf269ba71872a2f177509 Mon Sep 17 00:00:00 2001 From: kartnema Date: Fri, 20 Feb 2026 16:16:59 +0530 Subject: [PATCH 1/2] Add counter to delay untuning resources with pass-through support --- modula/Components/DLManager.cpp | 1 + modula/Components/Include/DLManager.h | 1 + resource-tuner/core/CocoTable.cpp | 35 ++++++++++++------------- resource-tuner/core/Include/CocoTable.h | 1 - 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/modula/Components/DLManager.cpp b/modula/Components/DLManager.cpp index af5424450..2f9a65d2b 100644 --- a/modula/Components/DLManager.cpp +++ b/modula/Components/DLManager.cpp @@ -7,6 +7,7 @@ DLManager::DLManager(int32_t linkerInUse) { this->mLinkerInUse = linkerInUse; this->mHead = this->mTail = nullptr; this->mSize = 0; + this->mRank = 0; } // Insert at end diff --git a/modula/Components/Include/DLManager.h b/modula/Components/Include/DLManager.h index 9f0ee6faa..276d3e9e0 100644 --- a/modula/Components/Include/DLManager.h +++ b/modula/Components/Include/DLManager.h @@ -138,6 +138,7 @@ class DLManager { int32_t mTotalLinkers; int32_t mLinkerInUse; // must be a value b/w 0 to mTotalLinkers - 1 int32_t mSize; + int32_t mRank; // Declared as public so that the cb's can be selectively set at DLManager creation time. PolicyRepo mSavedPolicies; diff --git a/resource-tuner/core/CocoTable.cpp b/resource-tuner/core/CocoTable.cpp index 5dddcebc6..a49376cc9 100644 --- a/resource-tuner/core/CocoTable.cpp +++ b/resource-tuner/core/CocoTable.cpp @@ -47,11 +47,6 @@ static int8_t comparLBetter(DLRootNode* newNode, DLRootNode* targetNode) { return newValue < targetValue; } -int8_t CocoTable::needsAllocation(Resource* res) { - ResConfInfo* rConf = this->mResourceRegistry->getResConf(res->getResCode()); - return (rConf->mPolicy != Policy::PASS_THROUGH); -} - std::shared_ptr CocoTable::mCocoTableInstance = nullptr; std::mutex CocoTable::instanceProtectionLock {}; @@ -237,13 +232,6 @@ int8_t CocoTable::insertInCocoTable(ResIterable* newNode, int8_t priority) { Resource* resource = (Resource*) newNode->mData; ResConfInfo* rConf = this->mResourceRegistry->getResConf(resource->getResCode()); - // Special handling for resources with policy: "pass_through" - if(rConf->mPolicy == Policy::PASS_THROUGH) { - // straightaway apply the action - this->fastPathApply(resource); - return true; - } - int32_t primaryIndex = this->getCocoTablePrimaryIndex(resource->getResCode()); int32_t secondaryIndex = this->getCocoTableSecondaryIndex(resource, priority); @@ -257,6 +245,14 @@ int8_t CocoTable::insertInCocoTable(ResIterable* newNode, int8_t priority) { enum Policy policy = this->mResourceRegistry->getResConf(resource->getResCode())->mPolicy; DLManager* dlm = this->mCocoTable[primaryIndex][secondaryIndex]; + // Special handling for resources with policy: "pass_through" + if(rConf->mPolicy == Policy::PASS_THROUGH) { + // straightaway apply the action + dlm->mRank++; + this->fastPathApply(resource); + return true; + } + // Unlikely if(dlm == nullptr) { return false; @@ -425,12 +421,6 @@ int8_t CocoTable::removeRequest(Request* request) { Resource* resource = (Resource*) resIter->mData; - ResConfInfo* resourceConfig = this->mResourceRegistry->getResConf(resource->getResCode()); - if(resourceConfig->mPolicy == Policy::PASS_THROUGH) { - this->fastPathReset(resource); - continue; - } - int8_t priority = request->getPriority(); int32_t primaryIndex = this->getCocoTablePrimaryIndex(resource->getResCode()); int32_t secondaryIndex = this->getCocoTableSecondaryIndex(resource, priority); @@ -443,6 +433,15 @@ int8_t CocoTable::removeRequest(Request* request) { DLManager* dlm = this->mCocoTable[primaryIndex][secondaryIndex]; if(dlm == nullptr) continue; + + ResConfInfo* resourceConfig = this->mResourceRegistry->getResConf(resource->getResCode()); + if(resourceConfig->mPolicy == Policy::PASS_THROUGH) { + if(--dlm->mRank == 0) { + this->fastPathReset(resource); + } + continue; + } + int8_t nodeIsHead = dlm->isNodeNth(0, iter); // Proceed with removal of the node from CocoTable diff --git a/resource-tuner/core/Include/CocoTable.h b/resource-tuner/core/Include/CocoTable.h index b9a01f86d..61c6ee694 100644 --- a/resource-tuner/core/Include/CocoTable.h +++ b/resource-tuner/core/Include/CocoTable.h @@ -126,7 +126,6 @@ class CocoTable { void fastPathApply(Resource* resource); void fastPathReset(Resource* resource); - int8_t needsAllocation(Resource* res); public: ~CocoTable(); From db2beb32ac2406d9c95ea5c935467b87e265008e Mon Sep 17 00:00:00 2001 From: kartnema Date: Fri, 20 Feb 2026 16:18:19 +0530 Subject: [PATCH 2/2] Minor Change --- resource-tuner/core/CocoTable.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resource-tuner/core/CocoTable.cpp b/resource-tuner/core/CocoTable.cpp index a49376cc9..8ea47bdbc 100644 --- a/resource-tuner/core/CocoTable.cpp +++ b/resource-tuner/core/CocoTable.cpp @@ -245,6 +245,11 @@ int8_t CocoTable::insertInCocoTable(ResIterable* newNode, int8_t priority) { enum Policy policy = this->mResourceRegistry->getResConf(resource->getResCode())->mPolicy; DLManager* dlm = this->mCocoTable[primaryIndex][secondaryIndex]; + // Unlikely + if(dlm == nullptr) { + return false; + } + // Special handling for resources with policy: "pass_through" if(rConf->mPolicy == Policy::PASS_THROUGH) { // straightaway apply the action @@ -253,11 +258,6 @@ int8_t CocoTable::insertInCocoTable(ResIterable* newNode, int8_t priority) { return true; } - // Unlikely - if(dlm == nullptr) { - return false; - } - switch(policy) { case INSTANT_APPLY: { // Insert this Request at the head of the linked list and apply it.