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

Enable IndexV2 #4583

Merged
merged 6 commits into from
Jan 24, 2025
Merged

Enable IndexV2 #4583

merged 6 commits into from
Jan 24, 2025

Conversation

cpubot
Copy link

@cpubot cpubot commented Jan 22, 2025

Problem

The current blockstore index type, backed by a BTreeSet, suffers from performance issues in serialization / deserialization due to its dynamically allocated and balanced nature. See #3570 and #3900 for context.

Summary of Changes

A follow up of #3900, this enables IndexV2 as the primary read/write target for the blockstore's Index type.

Other notes

In a follow up PR, I'll introduce a test case that exercises the fallback deserialization logic, where data in the blockstore is written as IndexFallback, deserialized as such, and recovered as Index.

@cpubot cpubot requested review from steviez and bw-solana January 22, 2025 21:39
@cpubot
Copy link
Author

cpubot commented Jan 22, 2025

2025-01-22-135308_hyprshot

This branch running on my dev node against another on mnb (no nuking of ledger necessary)

my node before/after
2025-01-22-135602_hyprshot

Copy link

@steviez steviez left a comment

Choose a reason for hiding this comment

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

In a follow up PR, I'll introduce a test case that exercises the fallback deserialization logic, where data in the blockstore is written as IndexFallback, deserialized as such, and recovered as Index.

I'm inclined to say that we should include the test in this PR. Since this PR is now writing the new format (and should land in v2.2), the test you described sounds similar to what we'd encounter in the v2.1 to v2.2 upgrade scenario if I'm not mistaken:

  • Node is running with v2.1 and writing BTreeSet
  • Node is stopped and upgraded to v2.2
  • Node is restarted with v2.2 and reads the BTreeSet index type for a slot that was written when it was running v2.1

Copy link

@bw-solana bw-solana left a comment

Choose a reason for hiding this comment

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

I would typically recommend staging multiple small PRs to:

  1. change the name from Index --> IndexV1 and setup the pub type Index = IndexV1;
  2. Switch the mapping so pub type Index = IndexV2;

However, this is small enough I'm not going to gate on it.

Regarding naming, IndexLegacy makes it more clear that this type is being phased out, which is good. But then compared to ShredIndexV2 it feels like we're mixing 1/b/iii. Especially if we ever add a ShredIndexV3.

I also agree with @steviez that we should make sure we have the unit tests for the conversions/fallbacks in place as part of this PR (or before it)

ledger/src/blockstore_meta.rs Outdated Show resolved Hide resolved
@cpubot cpubot force-pushed the shred-index-v2-enable branch from 0ce665a to 199ec83 Compare January 23, 2025 18:21
@cpubot
Copy link
Author

cpubot commented Jan 23, 2025

Regarding naming, IndexLegacy makes it more clear that this type is being phased out, which is good. But then compared to ShredIndexV2 it feels like we're mixing 1/b/iii. Especially if we ever add a ShredIndexV3.

Good call, this is definitely a better naming scheme.

@cpubot cpubot requested review from steviez and bw-solana January 23, 2025 18:29
bw-solana
bw-solana previously approved these changes Jan 24, 2025
Copy link

@bw-solana bw-solana 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

@steviez steviez left a comment

Choose a reason for hiding this comment

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

Code looks good. One additional thing that I think would be nice to add is an entry to the CHANGELOG. Namely, something similar to what is being added in #4600 like this:

  • Blockstore Index column format change
    • The Blockstore Index column format has been updated. A Blockstore written to with v2.2 is compatible with v2.1 and incompatible with v2.0 and older

I think under the "Breaking" section (which that PR introduces) is the right place. That other PR should land very shortly, so the hope is maybe you could rebase on top of it + add the extra line to the changelog then

ledger/src/blockstore.rs Show resolved Hide resolved
@cpubot cpubot force-pushed the shred-index-v2-enable branch from e462086 to b9eb826 Compare January 24, 2025 16:49
Copy link

@steviez steviez left a comment

Choose a reason for hiding this comment

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

LGTM

@cpubot cpubot merged commit d99ecfb into anza-xyz:master Jan 24, 2025
45 of 47 checks passed
@cpubot cpubot deleted the shred-index-v2-enable branch January 24, 2025 17:58
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.

3 participants