perf(vm): avoid duplicate LockedCoins read in GetAccount#1203
Open
0u-Y wants to merge 1 commit into
Open
Conversation
Signed-off-by: 0u-Y <yyw1000@naver.com>
Contributor
|
PR author is not in the allowed authors list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
GetAccountcomputed spendable and locked via separateSpendableCoinandlockedCoincalls, each readingLockedCoinsfrom the bank store — so everyGetAccountreadLockedCoinstwice. This reads balance andLockedCoinsonce in a new
spendableAndLockedCoinhelper and derives both; the now-unusedlockedCoinis removed.Equivalence
LockedCoins(addr).AmountOf(evmDenom)— unchanged.balance.SubAmount(locked)on thesdk.CoinfrombankWrapper.GetBalance, identical to whatbankWrapper.SpendableCoincomputes (same
sdk.Coin.SubAmount, same panic-on-negative).validateCoinInfoenforcesDenom == ExtendedDenom+ 18 decimals, soAmountOf(evmDenom) == AmountOf(extendedDenom); the values and the #1187locked-snapshot semantics are preserved.
Benchmarks
Transfer-saturated block, local harness (not in-tree, happy to share),
2000 txs/block,
-benchtime=10x -count=6, Ryzen 9 7900 (n=6):p=0.002 unless noted. Allocations drop significantly on both paths; serial
wall-time −2.3%; Block-STM wall-time is within noise. Workload-dependent —
smaller for contract-heavy blocks.
Tests
TestKeeperTestSuite(StateDB balance suite) and the staking-precompile suite(#1187 locked-via-precompile guard) pass unchanged.
The merged helper no longer opens the
SpendableCoin/LockedCointracingsub-spans (the parent
GetAccountspan is unchanged).Closes: #1202
Author Checklist
I have...
mainbranch