mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-22 06:40:53 +00:00
Signals that separate a sync that is merely slow from one that will never
finish:
- sync_acquire{missing_state_nodes_max, missing_tx_nodes_max, in_flight,
received_data_depth}: how many SHAMap nodes each in-flight acquire is
still waiting for. getMissingNodes already computed this and the callers
discarded it after a trace log. A count that stays flat means the
acquire is wedged; a shrinking count means it is progressing. Recorded
once per sweep, never inside the per-node walk, and reset when a tree
completes so a finished acquire does not read as stuck forever.
- shamap_cache_hit_rate{treenode}: hit rate of the in-memory tree-node
cache, which sits above the node store, so it is distinct from the
existing NuDB ratio. A cold cache on a fresh node sends every traversal
step to disk.
- sync_acquire_no_progress_total: timer ticks where an acquire made no
progress, previously only logged.
- sync_addnode_total{good,duplicate,invalid}: whether arriving nodes are
useful, duplicated or rejected, so wasted fetch work is visible.
- sync_acquire_source_total{local,network}: whether a ledger was served
from the local store or had to be fetched.
Adds getBad()/getDuplicate() to SHAMapAddNode and an acquireProgress()
accessor on InboundLedgers so the xrpld gauge can read these without
libxrpl depending on telemetry.
ledger_seq is deliberately not a metric label: it is unbounded. Per-ledger
identity stays on the ledger.acquire span; the metrics expose bounded
aggregates instead.
The full-below cache hit rate is not exported: KeyCache updates different
counters than getHitRate() reads, so it would always report zero. That
libxrpl bug is documented rather than papered over.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
198 lines
3.4 KiB
C++
198 lines
3.4 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
|
|
namespace xrpl {
|
|
|
|
// results of adding nodes
|
|
class SHAMapAddNode
|
|
{
|
|
private:
|
|
int good_;
|
|
int bad_;
|
|
int duplicate_;
|
|
|
|
public:
|
|
SHAMapAddNode();
|
|
void
|
|
incInvalid();
|
|
void
|
|
incUseful();
|
|
void
|
|
incDuplicate();
|
|
void
|
|
reset();
|
|
[[nodiscard]] int
|
|
getGood() const;
|
|
/**
|
|
* Nodes rejected as invalid in this tally.
|
|
*
|
|
* Complements getGood(): isInvalid() only answers "was there at least one",
|
|
* which cannot distinguish one bad node from a peer sending nothing but bad
|
|
* data. Exposed for the acquire telemetry counters, which need the count.
|
|
*
|
|
* @return Number of invalid nodes; 0 if none.
|
|
*/
|
|
[[nodiscard]] int
|
|
getBad() const;
|
|
/**
|
|
* Nodes already held, so re-receiving them was wasted work.
|
|
*
|
|
* A high duplicate share against a low good share means peers are re-sending
|
|
* data the node already has, which looks like healthy traffic but makes no
|
|
* acquire progress.
|
|
*
|
|
* @return Number of duplicate nodes; 0 if none.
|
|
*/
|
|
[[nodiscard]] int
|
|
getDuplicate() const;
|
|
[[nodiscard]] bool
|
|
isGood() const;
|
|
[[nodiscard]] bool
|
|
isInvalid() const;
|
|
[[nodiscard]] bool
|
|
isUseful() const;
|
|
[[nodiscard]] std::string
|
|
get() const;
|
|
|
|
SHAMapAddNode&
|
|
operator+=(SHAMapAddNode const& n);
|
|
|
|
static SHAMapAddNode
|
|
duplicate();
|
|
static SHAMapAddNode
|
|
useful();
|
|
static SHAMapAddNode
|
|
invalid();
|
|
|
|
private:
|
|
SHAMapAddNode(int good, int bad, int duplicate);
|
|
};
|
|
|
|
inline SHAMapAddNode::SHAMapAddNode() : good_(0), bad_(0), duplicate_(0)
|
|
{
|
|
}
|
|
|
|
inline SHAMapAddNode::SHAMapAddNode(int good, int bad, int duplicate)
|
|
: good_(good), bad_(bad), duplicate_(duplicate)
|
|
{
|
|
}
|
|
|
|
inline void
|
|
SHAMapAddNode::incInvalid()
|
|
{
|
|
++bad_;
|
|
}
|
|
|
|
inline void
|
|
SHAMapAddNode::incUseful()
|
|
{
|
|
++good_;
|
|
}
|
|
|
|
inline void
|
|
SHAMapAddNode::incDuplicate()
|
|
{
|
|
++duplicate_;
|
|
}
|
|
|
|
inline void
|
|
SHAMapAddNode::reset()
|
|
{
|
|
good_ = bad_ = duplicate_ = 0;
|
|
}
|
|
|
|
inline int
|
|
SHAMapAddNode::getGood() const
|
|
{
|
|
return good_;
|
|
}
|
|
|
|
inline int
|
|
SHAMapAddNode::getBad() const
|
|
{
|
|
return bad_;
|
|
}
|
|
|
|
inline int
|
|
SHAMapAddNode::getDuplicate() const
|
|
{
|
|
return duplicate_;
|
|
}
|
|
|
|
inline bool
|
|
SHAMapAddNode::isInvalid() const
|
|
{
|
|
return bad_ > 0;
|
|
}
|
|
|
|
inline bool
|
|
SHAMapAddNode::isUseful() const
|
|
{
|
|
return good_ > 0;
|
|
}
|
|
|
|
inline SHAMapAddNode&
|
|
SHAMapAddNode::operator+=(SHAMapAddNode const& n)
|
|
{
|
|
good_ += n.good_;
|
|
bad_ += n.bad_;
|
|
duplicate_ += n.duplicate_;
|
|
|
|
return *this;
|
|
}
|
|
|
|
inline bool
|
|
SHAMapAddNode::isGood() const
|
|
{
|
|
return (good_ + duplicate_) > bad_;
|
|
}
|
|
|
|
inline SHAMapAddNode
|
|
SHAMapAddNode::duplicate()
|
|
{
|
|
return SHAMapAddNode(0, 0, 1);
|
|
}
|
|
|
|
inline SHAMapAddNode
|
|
SHAMapAddNode::useful()
|
|
{
|
|
return SHAMapAddNode(1, 0, 0);
|
|
}
|
|
|
|
inline SHAMapAddNode
|
|
SHAMapAddNode::invalid()
|
|
{
|
|
return SHAMapAddNode(0, 1, 0);
|
|
}
|
|
|
|
inline std::string
|
|
SHAMapAddNode::get() const
|
|
{
|
|
std::string ret;
|
|
if (good_ > 0)
|
|
{
|
|
ret.append("good:");
|
|
ret.append(std::to_string(good_));
|
|
}
|
|
if (bad_ > 0)
|
|
{
|
|
if (!ret.empty())
|
|
ret.append(" ");
|
|
ret.append("bad:");
|
|
ret.append(std::to_string(bad_));
|
|
}
|
|
if (duplicate_ > 0)
|
|
{
|
|
if (!ret.empty())
|
|
ret.append(" ");
|
|
ret.append("dupe:");
|
|
ret.append(std::to_string(duplicate_));
|
|
}
|
|
if (ret.empty())
|
|
ret = "no nodes processed";
|
|
return ret;
|
|
}
|
|
|
|
} // namespace xrpl
|