This repository was archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Datapoints overwhelm the metrics queue and blow up ram usage. (bp #8272) #8282
Merged
Conversation
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
Contributor
|
😱 New commits were pushed while the automerge label was present. |
Codecov Report
@@ Coverage Diff @@
## v0.22 #8282 +/- ##
========================================
+ Coverage 59% 80.5% +21.5%
========================================
Files 244 254 +10
Lines 71618 55359 -16259
========================================
+ Hits 42282 44607 +2325
+ Misses 29336 10752 -18584 |
automerge (cherry picked from commit 17fb825)
c54eda3 to
599958c
Compare
huitseeker
pushed a commit
to huitseeker/solana
that referenced
this pull request
Nov 7, 2025
…olana-labs#8065) Processing new epoch (`Bank::process_new_epoch`) involves collecting stake delegations twice: 1) In `Bank::compute_new_epoch_caches_and_rewards`, to create a stake history entry and refresh vote accounts. 2) In `Bank::get_epoch_reward_calculate_param_info`, which is then used in `Bank::calculate_stake_vote_rewards` to calculate rewards for stakers and voters. The overall time of crossing the epoch boundary is ~519ms: ``` update_epoch_us=519953i ``` Where the two heaviest operations are `collect()`` calls on stake delegations, each of them taking ~200-220ms. Reduce that to just one collect by passing the vector 1) with freshly computed stake history and vote accounts to `Bank::begin_partitioned_rewards`. This way, we can avoid calling `Bank::get_epoch_reward_calculate_param_info`. The new time of crossing the epoch boundary is ~337ms: ``` update_epoch_us=337371i ``` Making that change possible required several refactors: * Tale `&PointValue` in `Bank::create_epoch_rewards_sysvar`. That makes it easier to operate on references of `PartitionedRewardsCalculation`. Copying integers from `PointValue` is cheap and has no visible performance impact. * Split `Stakes::activate_epoch`, that was performing calculations and mutating the cache at the same time. The calculations got split to `Stakes::calculate_activated_stake` that takes `&self`. * Add `Stakes::stake_delegations_ves` method. Stake delegations are stored as hash array mapped trie (HAMT)[0], which means that inserts, deletions and lookups are average-case O(1) and worst-case O(log n). However, the performance of iterations is poor due to depth-first traversal and jumps. Currently it's also impossible to iterate over it with rayon. That issue is known and handled by converting the HAMT to a vector with `stakes.stake_delegations.iter().collect()`. Move that trick to a dedicated method that describes the performance consequences. * Add `FilteredStakeDelegation` wrapper type, that wraps a vector of stake delegations and acts as a lazy iterator that filters out ones with insufficient stake. * Split the code dealing with rewards calculation and vote rewards distribution into separate methods: * `Bank::calculate_rewards` that takes `&self` and does not acquire any locks. * `Bank::begin_partitioned_rewards` that takes `&mut self`, sets calculation status and creates a sysvar. * `Bank::distribute_vote_rewards` that stores partitioned rewards and increases capitalization. [0] https://en.wikipedia.org/wiki/Hash_array_mapped_trie Fixes: solana-labs#8282
wen-coding
pushed a commit
to wen-coding/solana
that referenced
this pull request
Nov 17, 2025
…olana-labs#8065) Processing new epoch (`Bank::process_new_epoch`) involves collecting stake delegations twice: 1) In `Bank::compute_new_epoch_caches_and_rewards`, to create a stake history entry and refresh vote accounts. 2) In `Bank::get_epoch_reward_calculate_param_info`, which is then used in `Bank::calculate_stake_vote_rewards` to calculate rewards for stakers and voters. The overall time of crossing the epoch boundary is ~519ms: ``` update_epoch_us=519953i ``` Where the two heaviest operations are `collect()`` calls on stake delegations, each of them taking ~200-220ms. Reduce that to just one collect by passing the vector 1) with freshly computed stake history and vote accounts to `Bank::begin_partitioned_rewards`. This way, we can avoid calling `Bank::get_epoch_reward_calculate_param_info`. The new time of crossing the epoch boundary is ~337ms: ``` update_epoch_us=337371i ``` Making that change possible required several refactors: * Tale `&PointValue` in `Bank::create_epoch_rewards_sysvar`. That makes it easier to operate on references of `PartitionedRewardsCalculation`. Copying integers from `PointValue` is cheap and has no visible performance impact. * Split `Stakes::activate_epoch`, that was performing calculations and mutating the cache at the same time. The calculations got split to `Stakes::calculate_activated_stake` that takes `&self`. * Add `Stakes::stake_delegations_ves` method. Stake delegations are stored as hash array mapped trie (HAMT)[0], which means that inserts, deletions and lookups are average-case O(1) and worst-case O(log n). However, the performance of iterations is poor due to depth-first traversal and jumps. Currently it's also impossible to iterate over it with rayon. That issue is known and handled by converting the HAMT to a vector with `stakes.stake_delegations.iter().collect()`. Move that trick to a dedicated method that describes the performance consequences. * Add `FilteredStakeDelegation` wrapper type, that wraps a vector of stake delegations and acts as a lazy iterator that filters out ones with insufficient stake. * Split the code dealing with rewards calculation and vote rewards distribution into separate methods: * `Bank::calculate_rewards` that takes `&self` and does not acquire any locks. * `Bank::begin_partitioned_rewards` that takes `&mut self`, sets calculation status and creates a sysvar. * `Bank::distribute_vote_rewards` that stores partitioned rewards and increases capitalization. [0] https://en.wikipedia.org/wiki/Hash_array_mapped_trie Fixes: solana-labs#8282
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This is an automated backport of pull request #8272 done by Mergify.io
Cherry-pick of 17fb825 has failed:
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/
Mergify commands and options
More conditions and actions can be found in the [documention](https://doc.mergify.io/).
You can also trigger Mergify actions by commenting on this pull request:
@Mergifyio refreshwill re-evaluate the rules@Mergifyio rebasewill rebase this PR@Mergifyio backports <destination>will backport this PR on<destination>branchAdditionally, on Mergify dashboard you can:
Finally, you can contact us on https://mergify.io/