mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-27 23:38:08 +00:00
perf(telemetry): increment the copy-forward total only when it is read
copyForwardTotal_ is a second atomic increment beside copyForwardCount_ on the same event, kept only so a metric never goes backwards: rotate() zeroes the per-rotation tally for its log line, which leaves that counter unusable as a rate. Its only reader is MetricsRegistry.cpp:1153, through copyForwardTotal(). Guard the increment. During a rotation window every archive-served non-duplicate read pays for it, and with telemetry compiled out there is nothing to read it back. copyForwardCount_ is untouched: rotate() exchanges it for the "copied forward N archive-served reads" warning, which is real logging, not instrumentation. The virtual and the member stay declared unconditionally, so the nodestore interface has the same shape in every configuration.
This commit is contained in:
@@ -227,8 +227,13 @@ DatabaseRotatingImp::fetchNodeObject(
|
||||
// Two counters, one event: the per-rotation tally that
|
||||
// rotate() resets for its log line, and the monotonic total
|
||||
// the metrics gauge reads, which must never go backwards.
|
||||
// Only the first is needed for the log line, so the second
|
||||
// costs an extra atomic increment per copy-forward and is
|
||||
// compiled out with its only reader.
|
||||
copyForwardCount_.fetch_add(1, std::memory_order_relaxed);
|
||||
#ifdef XRPL_ENABLE_TELEMETRY
|
||||
copyForwardTotal_.fetch_add(1, std::memory_order_relaxed);
|
||||
#endif
|
||||
}
|
||||
writable->store(nodeObject);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user