diff --git a/src/ripple/app/misc/DatagramMonitor.h b/src/ripple/app/misc/DatagramMonitor.h index fd02217b4..d2a38af7f 100644 --- a/src/ripple/app/misc/DatagramMonitor.h +++ b/src/ripple/app/misc/DatagramMonitor.h @@ -1,10 +1,23 @@ // #ifndef RIPPLE_APP_MAIN_DATAGRAMMONITOR_H_INCLUDED #define RIPPLE_APP_MAIN_DATAGRAMMONITOR_H_INCLUDED +#include +#include +#include +#include #include #include #include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include #include #include @@ -21,20 +34,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include namespace ripple { @@ -76,7 +75,8 @@ struct [[gnu::packed]] LgrRange // shouldn't be included in network structures using ObjectCountMap = std::vector, int>>; -struct [[gnu::packed]] DebugCounters { +struct [[gnu::packed]] DebugCounters +{ // Database metrics std::uint64_t dbKBTotal{0}; std::uint64_t dbKBLedger{0}; @@ -88,10 +88,11 @@ struct [[gnu::packed]] DebugCounters { std::int32_t historicalPerMinute{0}; // Cache metrics - std::uint32_t sleHitRate{0}; // Stored as fixed point, multiplied by 1000 - std::uint32_t ledgerHitRate{0}; // Stored as fixed point, multiplied by 1000 + std::uint32_t sleHitRate{0}; // Stored as fixed point, multiplied by 1000 + std::uint32_t ledgerHitRate{ + 0}; // Stored as fixed point, multiplied by 1000 std::uint32_t alSize{0}; - std::uint32_t alHitRate{0}; // Stored as fixed point, multiplied by 1000 + std::uint32_t alHitRate{0}; // Stored as fixed point, multiplied by 1000 std::int32_t fullbelowSize{0}; std::uint32_t treenodeCacheSize{0}; std::uint32_t treenodeTrackSize{0}; @@ -115,7 +116,6 @@ struct [[gnu::packed]] DebugCounters { std::uint64_t nodeFetchSize{0}; }; - // Core server metrics in the fixed header struct [[gnu::packed]] ServerInfoHeader { @@ -409,15 +409,17 @@ private: getDebugCounters() { DebugCounters counters; - ObjectCountMap objectCounts = CountedObjects::getInstance().getCounts(1); - + ObjectCountMap objectCounts = + CountedObjects::getInstance().getCounts(1); + // Database metrics if app_licable if (!app_.config().reporting() && app_.config().useTxTables()) { - auto const db = dynamic_cast(&app_.getRelationalDatabase()); + auto const db = + dynamic_cast(&app_.getRelationalDatabase()); if (!db) Throw("Failed to get relational database"); - + if (auto dbKB = db->getKBUsedAll()) counters.dbKBTotal = dbKB; if (auto dbKB = db->getKBUsedLedger()) @@ -430,23 +432,31 @@ private: // Basic metrics counters.writeLoad = app_.getNodeStore().getWriteLoad(); - counters.historicalPerMinute = static_cast(app_.getInboundLedgers().fetchRate()); + counters.historicalPerMinute = + static_cast(app_.getInboundLedgers().fetchRate()); // Cache metrics - convert floating point rates to fixed point - counters.sleHitRate = static_cast(app_.cachedSLEs().rate() * 1000); - counters.ledgerHitRate = static_cast(app_.getLedgerMaster().getCacheHitRate() * 1000); + counters.sleHitRate = + static_cast(app_.cachedSLEs().rate() * 1000); + counters.ledgerHitRate = static_cast( + app_.getLedgerMaster().getCacheHitRate() * 1000); counters.alSize = app_.getAcceptedLedgerCache().size(); - counters.alHitRate = static_cast(app_.getAcceptedLedgerCache().getHitRate() * 1000); - counters.fullbelowSize = static_cast(app_.getNodeFamily().getFullBelowCache(0)->size()); - counters.treenodeCacheSize = app_.getNodeFamily().getTreeNodeCache(0)->getCacheSize(); - counters.treenodeTrackSize = app_.getNodeFamily().getTreeNodeCache(0)->getTrackSize(); + counters.alHitRate = static_cast( + app_.getAcceptedLedgerCache().getHitRate() * 1000); + counters.fullbelowSize = static_cast( + app_.getNodeFamily().getFullBelowCache(0)->size()); + counters.treenodeCacheSize = + app_.getNodeFamily().getTreeNodeCache(0)->getCacheSize(); + counters.treenodeTrackSize = + app_.getNodeFamily().getTreeNodeCache(0)->getTrackSize(); // Handle shard metrics if available if (auto shardStore = app_.getShardStore()) { - auto shardFamily = dynamic_cast(app_.getShardFamily()); + auto shardFamily = + dynamic_cast(app_.getShardFamily()); auto const [cacheSz, trackSz] = shardFamily->getTreeNodeCacheSize(); - + counters.shardFullbelowSize = shardFamily->getFullBelowCacheSize(); counters.shardTreenodeCacheSize = cacheSz; counters.shardTreenodeTrackSize = trackSz; @@ -645,8 +655,8 @@ private: } } - size_t totalSize = - sizeof(ServerInfoHeader) + (validRangeCount * sizeof(LgrRange)) + (64 * obj_count_map.size()); + size_t totalSize = sizeof(ServerInfoHeader) + + (validRangeCount * sizeof(LgrRange)) + (64 * obj_count_map.size()); // Allocate buffer and initialize header std::vector buffer(totalSize); @@ -809,8 +819,12 @@ private: // Pack version string memset(&header->version_string, 0, 32); - memcpy(&header->version_string, BuildInfo::getVersionString().c_str(), - BuildInfo::getVersionString().size() > 32 ? 32 : BuildInfo::getVersionString().size()); + memcpy( + &header->version_string, + BuildInfo::getVersionString().c_str(), + BuildInfo::getVersionString().size() > 32 + ? 32 + : BuildInfo::getVersionString().size()); header->dbg_counters = dbg_counters; @@ -832,7 +846,7 @@ private: } } - uint8_t* end_of_ranges = reinterpret_cast(buffer.data()) + + uint8_t* end_of_ranges = reinterpret_cast(buffer.data()) + sizeof(ServerInfoHeader) + (validRangeCount * sizeof(LgrRange)); memset(end_of_ranges, 0, 64 * obj_count_map.size());