Skip to content

runtime: narrow check_and_store() to AccountSharedData - #15398

Merged
2501babe merged 1 commit into
anza-xyz:masterfrom
2501babe:20260919_stakescache_asd
Sep 20, 2026
Merged

2501babe merged 1 commit into
anza-xyz:masterfrom
2501babe:20260919_stakescache_asd

Conversation

@2501babe

@2501babe 2501babe commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Problem

the stakes cache store flow is generic over ReadableAccount, which requires us to deep copy account data, but the existing bank caller has AccountSharedData

Summary of Changes

just make it AccountSharedData. this makes stakes case stores ~30% faster and vote case stores ~60% faster

@2501babe 2501babe self-assigned this Sep 19, 2026
Comment thread runtime/src/bank.rs
Comment on lines +4943 to +4945
accounts.account_for_geyser(i, |pubkey, account| {
self.stakes_cache
.check_and_store(pubkey, account, new_warmup_cooldown_rate_epoch)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obviously i would want to rename this

@codecov-commenter

codecov-commenter commented Sep 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.3%. Comparing base (4a1b4e4) to head (b59ad2d).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #15398   +/-   ##
=======================================
  Coverage    82.2%    82.3%           
=======================================
  Files         930      930           
  Lines      369589   369587    -2     
=======================================
+ Hits       304133   304174   +41     
+ Misses      65456    65413   -43     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

brooksprumo
brooksprumo previously approved these changes Sep 19, 2026

@brooksprumo brooksprumo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Looks good to me. Can merge as-is, or add a comment first.

Comment thread runtime/src/bank.rs
Comment on lines +4943 to +4945
accounts.account_for_geyser(i, |pubkey, account| {
self.stakes_cache
.check_and_store(pubkey, account, new_warmup_cooldown_rate_epoch)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea!

I have a long-standing TODO to remove the StorableAccounts stuff from everything outside the accounts-db crate. But I don't want to block this PR on that work. (I also intend to remove account_for_geyser() once the geyser crates are removed from the monorepo.)

An alternative could be to do this:

            let pubkey = accounts.pubkey(i);
            accounts.account(i, |account| {
                self.stakes_cache.check_and_store(
                    pubkey,
                    &account.take_account(),
                    new_warmup_cooldown_rate_epoch,
                );
            });

All callers are creating the StorableAccounts from AccountSharedDatas already, so we can leverage that here without needing to (re/ab)use the account_from_geyer() fn.

However, the .take_account() will end up doing the AccountSharedData::clone(). That's not the worst, but I don't want to unconditionally clone if we can avoid it.

So I say let's go with your impl as-is, and then once I cleanup the StorableAccounts stuff, I'll also be responsible for cleaning this up.

It may be helpful to add a comment on the account_for_gyser() call indicating why we are using it. E.g.:

            // We're not using this for geyser, but it is the only api that
            // let's us get a ref to the underlying AccountSharedData *without*
            // cloning/allocating first. 
            accounts.account_for_geyser(i, |pubkey, account| {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i added a comment and will open an issue to assign to you, i just want something linked to this pr to show this is AccountsDB Approved(tm) and not laziness/negligence on my part 😅

@2501babe
2501babe marked this pull request as ready for review September 20, 2026 05:41
@2501babe
2501babe added this pull request to the merge queue Sep 20, 2026
Merged via the queue into anza-xyz:master with commit cda12b7 Sep 20, 2026
46 checks passed
@2501babe
2501babe deleted the 20260919_stakescache_asd branch September 20, 2026 15:36
@alessandrod alessandrod added the v4.3 Backport to v4.3 branch label Oct 14, 2026
@mergify

mergify Bot commented Oct 14, 2026

Copy link
Copy Markdown

Backports to release branches are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis.

alessandrod pushed a commit that referenced this pull request Oct 15, 2026
…t of #15398) (#16043)

runtime: narrow check_and_store() to AccountSharedData (#15398)

Co-authored-by: hana <81144685+2501babe@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4.3 Backport to v4.3 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants