perf: keeper txout and vault-security reads, node account slabs, price feed batch
🔎 Visual review of804230d5: explainer, review flags and prompts to ask an AI about the change
Fifteen behavior-preserving speedups from the RSI loop, mostly in the keeper's node-account, vault-security and txout reads and in the price-feed quorum handler. Store access, keys and their order are unchanged in every commit, so gas_used, state and events are identical (regtest guard PASS; tx gas/op unchanged on every benchmark).
Human override, read this first. The batch judge confirmed two small regressions on the benchmark host: PerfParseMemo/trade+ +6.25% and PerfCommonHelpers/NewAddress +4.10% sec/op, allocations unchanged (224 and 51 per op). No commit here touches memo parsing or address code. Bisecting the batch puts the step at L1-0085, which changes only the attestation bech32 cache in the quorum handlers. The identical prefix-4 test binary runs trade+ 3.6% faster than prefix 3 on a different CPU (1403 vs 1455 ns/op). We read this as code layout (alignment), not a slower path, and the operator accepted the regressions (RSI_LAND_OVERRIDE).
Commits
- perf(keeper): build height store keys without the digit string (L1-0064):
getKeyInt64appends the digits straight into the key, giving byte-identical keys. TxOut allocs −9 to −11%. - perf(keeper): keep typed getters' records and wrappers on the stack (L1-0074): the wrappers decode through their own
Unmarshal, which is what the codec does after a reset. DepositStreamingSwap allocs −5.4%. - perf(common): OraclePrice.BigFloat divides by precomputed powers of ten (L1-0080): exact 10^d divisors, with the same 64-bit precision and rounding mode. PriceFeedQuorumBatch −6.9%.
- perf(thorchain): attestation bech32 cache lookups do not allocate (L1-0085): the cache is keyed by raw key bytes, and an entry made under another prefix is never served. PriceFeedQuorumBatch allocs −2.7%.
- perf(thorchain): price feed bond-address fallback shares the reported price (L1-0090): nothing after the copy modifies a price (median and bounds are fresh values). PriceFeedQuorumBatch −4.7%, allocs −22.6%.
- perf(common): MedianAbsoluteDeviation takes Abs in place, sorts without reflection (L1-0091):
Absreuses a value made fresh in the same loop, and the stable sort uses the same comparator. PriceFeedQuorumBatch −2.5%, allocs −11.9%. - perf(thorchain): price feed handler encodes active node addresses once (L1-0092): the same strings, encoded once per node instead of once per symbol. PriceFeedQuorumBatch −6.0%.
- perf(keeper): copy listed node accounts into exact-size shared slabs (L1-0095): copies equal to
CloneNodeAccount(nil and empty preserved, slices clipped so growth reallocates). ObservedTxQuorumIn −7.7 to −8.1%. - perf(keeper): GetNodeAccount builds its default record only when absent (L1-0096): a stored record replaces the whole default anyway. TssKeysignFail allocs −7.2%.
- perf(keeper): vault security sort reads its txout window through keys built once (L1-0099): every Has/Get is still made, through the same gas-metered store and TxOutCache. TxOut/native −23.0%, l1 −11.7%.
- perf(keeper): pending-outbound scan reads txouts through one store open and pooled keys (L1-0100): the same reads in the same order. TxOut/l1 −9.2%, QuoteSwap/l1-to-l1 −4.0%.
- perf(keeper): carve listed node accounts' Bond words out of one slab (L1-0102): each Bond still gets its own big.Int, with clipped words. ObservedTxQuorumIn allocs −15.9 to −23.4%.
- perf(keeper): vault security sort reads member status and bond from the node account memo (L1-0107): the same Has/Get. The decoding is shared under the exact stored bytes, and memo entries are never mutated. TxOut/native −8.0%, l1 −4.1%.
- perf(keeper): vault security sort opens the store once and builds each pool key once (L1-0109): the same keys and reads. TxOut/native −7.7%, l1 −3.4%.
- perf(keeper): memo pool and vault clones carve Uint words out of one slab (L1-0112): clones equal to
cloneUint, with clipped words. TssKeysignFail allocs −8.4%, DepositStreamingSwap allocs −5.0%.
Batch verdict (hedwig, two independent passes, n=10 each; confirm pass shown)
| benchmark | sec/op | allocs/op |
|---|---|---|
| PerfTxOut/native | 1550.7µ → 994.1µ −35.89% | −40.60% |
| PerfTxOut/l1 | −27.82% | −35.74% |
| PerfQuoteSwap/l1-to-l1 | 5.827m → 4.681m −19.66% | −27.85% |
| PerfQuoteSwap/l1-to-rune | −21.95% | −28.82% |
| PerfQuoteSwap/wasm/l1-to-rune | −26.55% | −33.76% |
| PerfPriceFeedQuorumBatch | 3.718m → 2.975m −19.99% | −52.09% |
| PerfObservedTxQuorumIn/fresh-1 | 342.2µ → 312.5µ −8.67% | −48.85% |
| PerfEndBlock/idle | 2.908m → 2.797m −3.81% | −13.83% |
| PerfParseMemo/trade+ | 1.145µ → 1.216µ +6.25% (override) | ~ |
| PerfCommonHelpers/NewAddress | 1.183µ → 1.231µ +4.10% (override) | ~ |
tx gas/op unchanged on every benchmark. Guard: PASS (regtest state, events and gas_used identical). Consensus-safety review of the batch diff found no issues: no map iteration, floats beyond the existing big.Float oracle math, wall clock or goroutines; memo entries are immutable; every carved slice is clipped.
RSI ideas: L1-0064, L1-0074, L1-0080, L1-0085, L1-0090, L1-0091, L1-0092, L1-0095, L1-0096, L1-0099, L1-0100, L1-0102, L1-0107, L1-0109, L1-0112
Published by huginn from the RSI loop (lane L1, ideas: L1-0064, L1-0074, L1-0080, L1-0085, L1-0090, L1-0091, L1-0092, L1-0095, L1-0096, L1-0099, L1-0100, L1-0102, L1-0107, L1-0109, L1-0112). The batch was judged as a whole by the loop's frozen judges, so huginn makes no code changes to it; it only rebases it (without AI) and merges it.