Scale down threads for collection at power on
In case where BMC reboots and VPD-Manager re-triggers the collection
process for the FRUs, number of threads has been restricted to 2 for
now (Just a lower value).
The thread count is configurable and can be updated as required.
This is required to scale down CPU utilization at power on.
Change-Id: I7dee6dabf073bc1f17ab4f9f672aa183b00e116a
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/src/manager.cpp b/vpd-manager/src/manager.cpp
index 51eb4af..dd00d92 100644
--- a/vpd-manager/src/manager.cpp
+++ b/vpd-manager/src/manager.cpp
@@ -29,7 +29,18 @@
try
{
#ifdef IBM_SYSTEM
- m_worker = std::make_shared<Worker>(INVENTORY_JSON_DEFAULT);
+ if (dbusUtility::isChassisPowerOn())
+ {
+ // At power on, less number of FRU(s) needs collection. we can scale
+ // down the threads to reduce CPU utilization.
+ m_worker = std::make_shared<Worker>(INVENTORY_JSON_DEFAULT,
+ constants::VALUE_1);
+ }
+ else
+ {
+ // Initialize with default configuration
+ m_worker = std::make_shared<Worker>(INVENTORY_JSON_DEFAULT);
+ }
// Set up minimal things that is needed before bus name is claimed.
m_worker->performInitialSetup();
diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp
index a0b8a24..ff92264 100644
--- a/vpd-manager/src/worker.cpp
+++ b/vpd-manager/src/worker.cpp
@@ -25,8 +25,8 @@
namespace vpd
{
-Worker::Worker(std::string pathToConfigJson) :
- m_configJsonPath(pathToConfigJson)
+Worker::Worker(std::string pathToConfigJson, uint8_t i_maxThreadCount) :
+ m_configJsonPath(pathToConfigJson), m_semaphore(i_maxThreadCount)
{
// Implies the processing is based on some config JSON
if (!m_configJsonPath.empty())