mirror of
https://github.com/Xahau/xahaud.git
synced 2026-09-26 23:29:04 +00:00
test(harness): small fixes from the outside review
forkCheckedSeqs counts the sequences validatedForkFree walks. The pinned 2000 is a max consumed beat, Kind weights profiled cost, eventCost rejects overflow, and fingerprints require a nanosecond clock. Pinned rows unchanged.
This commit is contained in:
@@ -50,6 +50,8 @@ class SteppingCsf_test : public beast::unit_test::suite
|
||||
std::uint64_t clampHits = 0;
|
||||
std::int64_t requestedMs = 0;
|
||||
std::int64_t consumedMs = 0;
|
||||
// Highest virtual time one beat consumed. A pinned 2000 is that
|
||||
// observed maximum, not a fixed per-beat budget.
|
||||
std::int64_t maxConsumedBeatMs = 0;
|
||||
std::int64_t schedulerMs = 0;
|
||||
std::uint64_t heartbeatEvents = 0;
|
||||
@@ -553,7 +555,7 @@ class SteppingCsf_test : public beast::unit_test::suite
|
||||
out.minValidated = net.minValidatedSeq();
|
||||
for (std::uint32_t i = 0; i < 5; ++i)
|
||||
out.maxValidated = std::max(out.maxValidated, net.validSeq(i));
|
||||
out.forkCheckedSeqs = out.maxValidated >= 2 ? out.maxValidated - 1 : 0;
|
||||
out.forkCheckedSeqs = net.forkCheckedSeqs();
|
||||
out.clampHits = stats.clampHits;
|
||||
out.requestedMs = asMs(stats.requestedVirtualAdvance);
|
||||
out.consumedMs = asMs(stats.consumedVirtualAdvance);
|
||||
|
||||
@@ -225,7 +225,7 @@ class SteppingDeterminism_test : public beast::unit_test::suite
|
||||
out.minValidated = net.minValidatedSeq();
|
||||
for (std::uint32_t i = 0; i < 3; ++i)
|
||||
out.maxValidated = std::max(out.maxValidated, net.validSeq(i));
|
||||
out.forkCheckedSeqs = out.maxValidated >= 2 ? out.maxValidated - 1 : 0;
|
||||
out.forkCheckedSeqs = net.forkCheckedSeqs();
|
||||
out.clampHits = stats.clampHits;
|
||||
out.requestedMs = asMs(stats.requestedVirtualAdvance);
|
||||
out.consumedMs = asMs(stats.consumedVirtualAdvance);
|
||||
|
||||
@@ -562,7 +562,7 @@ class SteppingTrust_test : public beast::unit_test::suite
|
||||
out.minValidated = net.minValidatedSeq();
|
||||
for (std::uint32_t i = 0; i < kForkPeers; ++i)
|
||||
out.maxValidated = std::max(out.maxValidated, net.validSeq(i));
|
||||
out.forkCheckedSeqs = out.maxValidated >= 2 ? out.maxValidated - 1 : 0;
|
||||
out.forkCheckedSeqs = net.forkCheckedSeqs();
|
||||
out.clampHits = stats.clampHits;
|
||||
out.requestedMs = asMs(stats.requestedVirtualAdvance);
|
||||
out.consumedMs = asMs(stats.consumedVirtualAdvance);
|
||||
|
||||
@@ -59,6 +59,11 @@ public:
|
||||
// advances time in the same units it will later drive.
|
||||
using time_point = std::chrono::steady_clock::time_point;
|
||||
using duration = std::chrono::steady_clock::duration;
|
||||
// Fingerprints fold duration::count() as-is. This clock is nanoseconds;
|
||||
// a coarser period would move every pinned fingerprint.
|
||||
static_assert(
|
||||
std::ratio_equal_v<duration::period, std::nano>,
|
||||
"trace fingerprints assume a nanosecond steady_clock");
|
||||
|
||||
// Priority class among events at the SAME virtual instant (lower runs
|
||||
// first). Spaced by 10 so intermediate tiers can be slotted in without
|
||||
@@ -93,8 +98,9 @@ public:
|
||||
};
|
||||
|
||||
// PROVENANCE, not ordering: what CREATED an event. Orthogonal to Tier (its
|
||||
// same-instant priority). Used in fence-violation diagnostics today and in
|
||||
// beat traces later; never consulted for scheduling decisions.
|
||||
// same-instant priority). The queue orders by (when, tier, nodeId, seq),
|
||||
// so Kind is not a sort key. Profiled pacing does consult it: event cost
|
||||
// scales by the kind weight.
|
||||
enum class Kind {
|
||||
other = 0,
|
||||
heartbeat, // a driver's per-node heartbeat trigger
|
||||
@@ -231,8 +237,19 @@ public:
|
||||
[[nodiscard]] duration
|
||||
eventCost(std::uint32_t nodeId, Kind kind) const
|
||||
{
|
||||
return unitCost * static_cast<std::int64_t>(k) *
|
||||
static_cast<std::int64_t>(eventWeight(nodeId, kind));
|
||||
auto const scale = static_cast<std::uint64_t>(k) *
|
||||
static_cast<std::uint64_t>(eventWeight(nodeId, kind));
|
||||
if (unitCost.count() < 0)
|
||||
Throw<std::overflow_error>(
|
||||
"HarnessScheduler::ProfiledPacer event cost overflow");
|
||||
auto const unit = static_cast<std::uint64_t>(unitCost.count());
|
||||
if (unit != 0 &&
|
||||
scale > static_cast<std::uint64_t>(
|
||||
std::numeric_limits<duration::rep>::max()) /
|
||||
unit)
|
||||
Throw<std::overflow_error>(
|
||||
"HarnessScheduler::ProfiledPacer event cost overflow");
|
||||
return unitCost * static_cast<duration::rep>(scale);
|
||||
}
|
||||
|
||||
[[nodiscard]] duration
|
||||
|
||||
@@ -1567,6 +1567,19 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// How many sequences validatedForkFree walks: 2 through the highest live
|
||||
// validated sequence, inclusive. That is max-1 when max >= 2. Not a count
|
||||
// of pairwise hash comparisons.
|
||||
[[nodiscard]] std::uint32_t
|
||||
forkCheckedSeqs()
|
||||
{
|
||||
std::uint32_t hi = 0;
|
||||
for (std::uint32_t i = 0; i < net_.size(); ++i)
|
||||
if (net_.isLive(i))
|
||||
hi = std::max(hi, validSeq(i));
|
||||
return hi >= 2 ? hi - 1 : 0;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::shared_ptr<Ledger const>
|
||||
ledger(std::uint32_t node, std::uint32_t seq)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user