From d2899da82cb004acbcba439673dc1dfb02ae6fb6 Mon Sep 17 00:00:00 2001 From: Matthew Raybuck Date: Tue, 26 Feb 2019 14:24:31 -0600 Subject: Improve performance of Partial Good logic The function PARTIAL_GOOD::findRulesForTarget() would call masterProcChipTargetHandle() to figure out if a rule applied to a specific target based on the ATTR_MODEL of a system. Since finding the master proc that way is an expensive operation, findRulesForTarget() will now use an instance variable initialized once instead of querying for it repeatedly thereby increasing performance substantially. Change-Id: I6e9c01daf356fe21d76d920f5d3210717f5094c1 CQ:SW450113 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/72620 Tested-by: Jenkins Server Reviewed-by: Nicholas E. Bofferding Tested-by: FSP CI Jenkins Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Reviewed-by: Ilya Smirnov Reviewed-by: Daniel M. Crowell --- src/include/usr/hwas/common/pgLogic.H | 4 ++++ src/usr/hwas/common/pgLogic.C | 27 +++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/include/usr/hwas/common/pgLogic.H b/src/include/usr/hwas/common/pgLogic.H index cfe5d599f..1adf5509f 100644 --- a/src/include/usr/hwas/common/pgLogic.H +++ b/src/include/usr/hwas/common/pgLogic.H @@ -420,6 +420,7 @@ namespace PARTIAL_GOOD struct PartialGoodRulesTable { + PartialGoodRulesTable(); ~PartialGoodRulesTable(); /** @@ -444,6 +445,9 @@ namespace PARTIAL_GOOD pgLogic_t &o_pgLogic) const; private: + + mutable TARGETING::TargetHandle_t iv_pMasterProc; + // A map that will hold all of the PG rules for all targets. If a target // doesn't have a pg checking logic or special rules it will still be // represented in this map because the generic algorithm will consider diff --git a/src/usr/hwas/common/pgLogic.C b/src/usr/hwas/common/pgLogic.C index 307527fc3..b8f32f714 100644 --- a/src/usr/hwas/common/pgLogic.C +++ b/src/usr/hwas/common/pgLogic.C @@ -213,6 +213,9 @@ namespace PARTIAL_GOOD const PartialGoodRulesTable pgTable; + PartialGoodRulesTable::PartialGoodRulesTable() : iv_pMasterProc(nullptr) + {} + PartialGoodRulesTable::~PartialGoodRulesTable() { for (auto const& type : pgRules_map) @@ -231,6 +234,21 @@ namespace PARTIAL_GOOD { errlHndl_t l_errl = nullptr; + if (iv_pMasterProc == nullptr) + { + // Since many targets don't have ATTR_MODEL filled in, lookup the + // master proc so that we can use to verify if a PG rule is + // applicable for this chip type. + // NOTE: This is done only once since querying for the master proc + // is an expensive operation. + TARGETING::targetService() + .masterProcChipTargetHandle(iv_pMasterProc); + + HWAS_ASSERT(iv_pMasterProc, "findRulesForTarget: couldn't get " + "master proc."); + + } + // Lookup the Target in the PG Rules Table auto rulesIterator = pgRules_map.find(i_target->getAttr()); @@ -245,13 +263,6 @@ namespace PARTIAL_GOOD pgRules_t l_allRules = rulesIterator->second; - // Since many targets don't have ATTR_MODEL filled in, lookup - // the master proc and use that to verify if this chip type is - // applicable for the target. - TARGETING::TargetService& ts = TARGETING::targetService(); - TARGETING::TargetHandle_t masterProc; - ts.masterProcChipTargetHandle(masterProc); - // Iterate through all of the pg rules and compose a list of // applicable rules based on chip unit and chip type. for (pgRules_t::const_iterator pgRule = l_allRules.begin(); @@ -262,7 +273,7 @@ namespace PARTIAL_GOOD // Compare the pgRule's chip type to the target. Encode the // target's chip unit and see if it is a match for this rule. - if ((*pgRule)->iv_applicableChipTypes(masterProc) + if ((*pgRule)->iv_applicableChipTypes(iv_pMasterProc) && (*pgRule)->isApplicableToChipUnit(targetCU)) { // Current PG Rule is applicable to this target so create -- cgit v1.2.3