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

Refine the condition for 'should shrink' decision #3252

Merged
merged 4 commits into from
Oct 23, 2024

Conversation

dmakarov
Copy link

@dmakarov dmakarov commented Oct 21, 2024

Problem

When the ancient packing algorithm was designed, the intention was for 'shrinking' to occur as part of packing. This was observed to cause cold and warm accounts to be continually mixed, resulting in lots of disk i/o churn. In the newer strategy, we don't combine previously packed ancient storages with newly ancient storages. We do, however, rely on shrinking to shrink ancient storages. An important concept is that older ancient storages are very cold. Thus, the accounts in them are not expected to change frequently. if we require a threshold, like < 90% accounts are alive, some of these storages will never fail the threshold and be eligible for shrinking. When shrinking is idle, it finds the ancient storage with the highest # dead bytes and shrinks it.

Summary of Changes

Ancient packing adds ALL storages with dead bytes to the list that shrink uses to determine which ancient storages to shrink when shrink is otherwise idle.

@dmakarov dmakarov marked this pull request as ready for review October 23, 2024 16:21
jeffwashington
jeffwashington previously approved these changes Oct 23, 2024
Copy link

@jeffwashington jeffwashington left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

I'm failing to see how, by calling is_candidate_for_shrink() instead of manually calculating the 90% of the alive bytes, we're adding all the ancient storages to AncientSlotInfos.

@brooksprumo
Copy link

brooksprumo commented Oct 23, 2024

I'm failing to see how, by calling is_candidate_for_shrink() instead of manually calculating the 90% of the alive bytes, we're adding all the ancient storages to AncientSlotInfos.

Ah ok, I looked at the code and now see: by default the shrink threshold is with TotalSpace, not IndividualStore.

Copy link

@HaoranYi HaoranYi left a comment

Choose a reason for hiding this comment

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

lgtm!

I assume this PR is included in the most recent run on jw12. Right?

@@ -7518,7 +7518,7 @@ impl AccountsDb {
true
}

fn is_candidate_for_shrink(&self, store: &AccountStorageEntry) -> bool {
pub(crate) fn is_candidate_for_shrink(&self, store: &AccountStorageEntry) -> bool {

Choose a reason for hiding this comment

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

Can we document this fn?

Suggested change
pub(crate) fn is_candidate_for_shrink(&self, store: &AccountStorageEntry) -> bool {
/// Determines whether a given AccountStorageEntry instance is a candidate for shrinking.
pub(crate) fn is_candidate_for_shrink(&self, store: &AccountStorageEntry) -> bool {

Copy link
Author

Choose a reason for hiding this comment

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

I'll make a follow up pr with the documentation. Good point, though. Thanks!

Copy link

@jeffwashington jeffwashington left a comment

Choose a reason for hiding this comment

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

lgtm

@dmakarov dmakarov merged commit 5167e0e into anza-xyz:master Oct 23, 2024
40 checks passed
@dmakarov dmakarov deleted the shrink branch October 23, 2024 19:48
ray-kast pushed a commit to abklabs/agave that referenced this pull request Nov 27, 2024
* Refine the condition for 'should shrink' decision

* Fix tests

* Fix clippy

* Brooks
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.

4 participants