-
Notifications
You must be signed in to change notification settings - Fork 291
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
v2.1: Blockstore: Migrate ShredIndex type to more efficient data structure (backport of #3900) #4428
base: v2.1
Are you sure you want to change the base?
Conversation
Cherry-pick of f8e5b16 has failed:
To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
|
what's the motivation for backporting here? we'll very likely be beginning voluntary mb adoption of 2.1 this week, so the bar for backport with little/no bake time is exceptionally high |
Oh, yeah, you're right. Didn't realize that file doesn't exist in |
The motivation here is that this PR just sets up a rollback strategy for the new
In short, this PR just enables deserialization of the new blockstore index type ( |
To reiterate, the PR doesn't change any behavior. It makes 2.1 capable of reading 2.2 ledgers which is when we'll change format. |
let index: bincode::Result<blockstore_meta::Index> = config.deserialize(data); | ||
match index { | ||
Ok(index) => Ok(index), | ||
Err(_) => { | ||
let index: blockstore_meta::IndexV2 = config.deserialize(data)?; | ||
Ok(index.into()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building on top of what Zach and Alessandro mentioned, this is where there is "new behavior" in production.
- We read from Blockstore and try to deserialize into
Index
(the pre-existing type). If deserialize fails ...- Existing v2.1 and older code will panic if deserialize into
Index
fails (the caller unwraps this):
agave/ledger/src/blockstore_db.rs
Lines 1730 to 1733 in 33ab693
if let Some(pinnable_slice) = self.backend.get_pinned_cf(self.handle(), key)? { let value = deserialize(pinnable_slice.as_ref())?; result = Ok(Some(value)) } - This PR will instead try to deserialize into
IndexV2
ONLY if initial deserialize fails. But, seeing as we aren't writing the new format, that deserialize will fail too
- Existing v2.1 and older code will panic if deserialize into
c9b7c61
to
25895cf
Compare
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 for context.Summary of Changes
Fixes #3570
This PR implements the
ShredIndex
behavior behind a bit vec (Vec<u8>
).Migration strategy
The general goal is to avoid the overhead of writing two separate columns while still supporting the downgrade path. While this can be accomplished with two distinct columns, for this proposal, rather than writing to a new column, I am proposing we add support for both formats in the same column. This will avoid an additional read to rocksdb, as we can attempt deserialization of both formats on the same rocksdb slice. In order to support the downgrade path, this initial PR will solely add support for reading the new format.
See release steps
The idea here is to split the column migration across three releases such that:
This is an automatic backport of pull request #3900 done by [Mergify](https://mergify.com).