entity-manager: debug logs for loadConfigurations
Enable these logs to keep track of json load and parsing delay.
Tested: on Tyan S8030:
simulate fw update or developer changes:
```
rm /var/configuration/system.json
systemctl restart xyz.openbmc_project.EntityManager
```
journal output for one EM start
```
Jun 13 12:23:46 s8030-bmc-30303035c0c1 systemd[1]: Started Entity Manager.
Jun 13 12:23:54 s8030-bmc-30303035c0c1 entity-manager[19814]: finished loading json configuration in 7668ms
Jun 13 12:24:01 s8030-bmc-30303035c0c1 entity-manager[19814]: finished loading json configuration in 6533ms
...
Jun 13 12:24:16 s8030-bmc-30303035c0c1 entity-manager[19814]: finished loading json configuration in 6838ms
...
```
Repeating the benchmark a few times:
7668ms
6533ms
6838ms
3581ms
3601ms
3443ms
3638ms
3343ms
3381ms
The debug log shows how long the json parsing takes and helps with
future optimizations.
Change-Id: I3a776cabcb09a171f8929ad9052383d20e59a422
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/configuration.cpp b/src/entity_manager/configuration.cpp
index 8646f57..bd78f1b 100644
--- a/src/entity_manager/configuration.cpp
+++ b/src/entity_manager/configuration.cpp
@@ -1,6 +1,7 @@
#include "configuration.hpp"
#include "perform_probe.hpp"
+#include "phosphor-logging/lg2.hpp"
#include "utils.hpp"
#include <nlohmann/json.hpp>
@@ -35,6 +36,8 @@
// reads json files out of the filesystem
bool loadConfigurations(std::list<nlohmann::json>& configurations)
{
+ const auto start = std::chrono::steady_clock::now();
+
// find configuration files
std::vector<std::filesystem::path> jsonPaths;
if (!findFiles(
@@ -102,6 +105,14 @@
configurations.emplace_back(data);
}
}
+
+ const auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::steady_clock::now() - start)
+ .count();
+
+ lg2::debug("Finished loading json configuration in {MILLIS}ms", "MILLIS",
+ duration);
+
return true;
}