From 16e3c87dcc400f21281030ae824cb29d2cd1ac5a Mon Sep 17 00:00:00 2001 From: CJ Cobb Date: Wed, 16 Mar 2022 10:40:47 -0400 Subject: [PATCH] don't create strands for cache download. output cache info in server_info --- src/backend/SimpleCache.cpp | 6 +++--- src/backend/SimpleCache.h | 6 +++--- src/etl/ReportingETL.cpp | 5 ++--- src/etl/ReportingETL.h | 2 -- src/rpc/handlers/ServerInfo.cpp | 5 +++++ 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/backend/SimpleCache.cpp b/src/backend/SimpleCache.cpp index 37ff266e..6defa5bc 100644 --- a/src/backend/SimpleCache.cpp +++ b/src/backend/SimpleCache.cpp @@ -1,7 +1,7 @@ #include namespace Backend { uint32_t -SimpleCache::latestLedgerSequence() +SimpleCache::latestLedgerSequence() const { std::shared_lock lck{mtx_}; return latestSeq_; @@ -91,12 +91,12 @@ SimpleCache::setFull() } bool -SimpleCache::isFull() +SimpleCache::isFull() const { return full_; } size_t -SimpleCache::size() +SimpleCache::size() const { std::shared_lock lck{mtx_}; return map_.size(); diff --git a/src/backend/SimpleCache.h b/src/backend/SimpleCache.h index ca0f64f6..4cabd0e7 100644 --- a/src/backend/SimpleCache.h +++ b/src/backend/SimpleCache.h @@ -49,14 +49,14 @@ public: setFull(); uint32_t - latestLedgerSequence(); + latestLedgerSequence() const; // whether the cache has all data for the most recent ledger bool - isFull(); + isFull() const; size_t - size(); + size() const; }; } // namespace Backend diff --git a/src/etl/ReportingETL.cpp b/src/etl/ReportingETL.cpp index 5a740811..a528db81 100644 --- a/src/etl/ReportingETL.cpp +++ b/src/etl/ReportingETL.cpp @@ -937,9 +937,8 @@ ReportingETL::loadCache(uint32_t seq) { std::optional start = cursors[i]; std::optional end = cursors[i + 1]; - cacheDownloadStrands_.emplace_back(ioContext_); boost::asio::spawn( - cacheDownloadStrands_.back(), + ioContext_, [this, seq, start, end, numRemaining]( boost::asio::yield_context yield) { std::optional cursor = start; @@ -948,7 +947,7 @@ ReportingETL::loadCache(uint32_t seq) auto res = Backend::retryOnTimeout([this, seq, &cursor, &yield]() { return backend_->fetchLedgerPage( - cursor, seq, 256, yield); + cursor, seq, 256, false, yield); }); backend_->cache().update(res.objects, seq, true); if (!res.cursor || (end && *(res.cursor) > *end)) diff --git a/src/etl/ReportingETL.h b/src/etl/ReportingETL.h index 52252fb4..69063900 100644 --- a/src/etl/ReportingETL.h +++ b/src/etl/ReportingETL.h @@ -67,8 +67,6 @@ private: /// ledgers are published in order boost::asio::io_context::strand publishStrand_; - std::vector cacheDownloadStrands_; - /// Mechanism for communicating with ETL sources. ETLLoadBalancer wraps an /// arbitrary number of ETL sources and load balances ETL requests across /// those sources. diff --git a/src/rpc/handlers/ServerInfo.cpp b/src/rpc/handlers/ServerInfo.cpp index 84e6e5fc..a39d3fae 100644 --- a/src/rpc/handlers/ServerInfo.cpp +++ b/src/rpc/handlers/ServerInfo.cpp @@ -29,6 +29,11 @@ doServerInfo(Context const& context) info["counters"] = boost::json::object{}; info["counters"].as_object()["rpc"] = context.counters.report(); } + auto& cache = (response["cache"] = boost::json::object{}).as_object(); + cache["size"] = context.backend->cache().size(); + cache["is_full"] = context.backend->cache().isFull(); + cache["latest_ledger_seq"] = + context.backend->cache().latestLedgerSequence(); auto serverInfoRippled = context.balancer->forwardToRippled( context.params, context.clientIp, context.yield);