Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: vote state view #4834

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jstarry
Copy link

@jstarry jstarry commented Feb 6, 2025

Problem

The stakes cache stores copies of vote account data so that things like consensus, inflation rewards, and vote timestamp calculation can access the vote account state for all staked validators. Every time when a vote is processed, the vote account entry in the stakes cache is updated and the account data is deserialized and ~1KB is allocated to store the new state. This is all unnecessary because the vote state data the protocol needs can be read on demand directly from the account data byte vector.

Summary of Changes

  • Introduce new VoteStateView type which stores a copy of the vote account's Arc<Vec<u8>> and field offset data to speed up vote state field lookups.

Fixes #

Copy link

mergify bot commented Feb 6, 2025

If this PR represents a change to the public RPC API:

  1. Make sure it includes a complementary update to rpc-client/ (example)
  2. Open a follow-up PR to update the JavaScript client @solana/web3.js (example)

Thank you for keeping the RPC clients in sync with the server API @jstarry.

Copy link

mergify bot commented Feb 6, 2025

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

@jstarry jstarry force-pushed the refactor/vote-state-view branch 4 times, most recently from 387de2a to d276a8c Compare February 6, 2025 19:44
@jstarry
Copy link
Author

jstarry commented Feb 6, 2025

Before

test bench_vote_account_try_from ... bench:         321.63 ns/iter (+/- 5.15)

After

test bench_vote_account_try_from ... bench:          59.46 ns/iter (+/- 0.18)

@jstarry jstarry force-pushed the refactor/vote-state-view branch from 2480abe to 87ec58d Compare February 13, 2025 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant