!5257huginn-rsi/perf-20261020 → develop804230d5b3

Keeper txout and vault-security reads, node account slabs, price feed batch

AI-generatedEverything on this page was written by an AI agent from the diff: the summaries, the narration, the diagrams, the flags and the glossary. It can be wrong or incomplete, so check it against the code before you rely on it.

16commits
19files
1.6klines changed
623lines to read
0store reads changed
−23%best step (TxOut/native)

Where the diff is

5-minute explainer

What changed

Height keys + getters

Same key bytes without a digit string; wrappers decode themselves.

txout//1234567== GetKey bytes

digits and '-' have no upper case · error text names the type as a literal

Price feed batch

Exact pow10 divisors, in-place Abs, addresses encoded once.

  • BigFloat ÷ precomputed 10^d (prec 64, same rounding)
  • MAD: Abs in place · SortStableFunc
  • node addresses encoded once per node
  • bech32 cache keyed by raw key bytes, prefix checked

One price, many maps

Bond-address fallback shares the reported big.Float, no copy.

by node A by bond addr by node B one *big.Float nothing may write it

Node account slabs

Listed accounts' addresses, members and Bond words: one allocation each.

before: 3 allocations × ~100 nodes … after: one slab, clipped [a:b:b] pieces nil stays nil · empty stays empty · own big.Int per Bond

Vault security sort

Window keys once, status and bond from memo, one store open.

txout window keys ×1node account memopool key per asset ×1kvStore(ctx) ×1

every Has/Get still made, same order → same gas

Pending outbound walk

One store open and pooled keys; absent heights return nil.

hh+1h+2…now+delayHas → Get?

nil ≡ old empty TxOut: early break and append both handle it

Memo clones carve words

Pool and vault clones take their Uint words from one slab.

BalanceRuneBalanceAssetLPUnitsSynthUnitsPending×2→ 1 []big.Word

Accepted regressions

Two microbenchmarks +4–6%, read as code layout; operator override.

  • PerfParseMemo/trade+ +6.25% (allocs unchanged)
  • PerfCommonHelpers/NewAddress +4.10%
  • no commit touches that code

Line by line · every changed logic line, narrated

13:12runtime
17code chapters
100%logic lines narrated (538/538)
14flagged spots
speed

Chapters

What to check

Ask an AI about this change

Chat assistantClaude, ChatGPT, … (reads a link)

Coding agentClaude Code, Cursor, … (reads the repo)

The context file is context.md. Use Copy with context for an AI that can't open links; it pastes the whole file in.

Glossary

Bech32
The address encoding with a human-readable prefix (thor, thorpub). The attestation cache stores each key's encoding with that prefix. BIP-173 ↗
big.Float
Go's arbitrary-precision float. Its precision and rounding mode decide the exact bits of a quotient. math/big Float ↗
cachekv
The Cosmos SDK's write-back cache store. Its Get keeps the caller's key bytes as a map key, so a key must not be modified after use. cosmossdk.io/store/cachekv ↗
Decode memo
Process-wide caches of decoded node accounts, pools and vaults, keyed by store key and checked against the exact stored bytes. Callers get clones. decode_memo.go ↗
Gas metering
Every Has and Get through the context's store charges gas, and gas_used is consensus-visible, so these commits keep every read, key and order.
MAD
Median absolute deviation: the median of each price's distance from the median price. It sets the outlier bounds. common/math.go ↗
Price feed quorum batch
The message carrying each active node's signed price feed; the handler takes a per-symbol median and stores it as the oracle price. handler_price_feed_quorum_batch.go ↗
RSI loop
The automated benchmark-and-judge loop that produced these commits; each body records its benchmarks and a regtest guard comparing state, events and gas.
Slab
One allocation sized for a whole list, carved into per-record pieces. Each piece is clipped ([a:b:b]) so appending to it reallocates. active_validators_cache.go ↗
TxOut
The outbound transactions scheduled at one block height, stored under a key built from the height. Most heights in a pending window have none. keeper_txout.go ↗
TxOutCache
A per-query cache of each height's stored TxOut bytes (or their absence), shared between reads; it disables itself on any TxOut write. txout_cache.go ↗
Vault security sort
getSortedVaultSecurity ranks vaults by total active bond against held value plus pending outbounds, to pick which vault signs. keeper_vault.go ↗