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.
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
[TieredStorage] Write owners block for HotAccountStorage #34927
[TieredStorage] Write owners block for HotAccountStorage #34927
Changes from 1 commit
8d02f02
6b585a8
20110b7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Ah ha! I was wondering about this the other day and how we wanted to handle it. This basically guarantees every hot storage file will have one additional owner that represents "no owner". We could also optimize this away by storing some flag, or known owner's offset to indicate this account has no owner, or always using the first owner offset, since the value itself does not matter.
For this PR, I think this impl is fine.
Please make this a constant though. (And maybe renamed? Up to you.)
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.
I actually tried this first, but Rust complains that I cannot do this:
Let me try the lazy_init again (I think I might have tried that before as well, forgot what was complained).
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.
I think one way to achieve this is to have one special value of OwnerOffset indicating no owner (probably OwnerOffset(u32::MAX) I think). This is probably a better way to handle it. Let me try to handle it.
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.
Damn. I need to pick some value other than u32::MAX because hot-storage stores owners offset using only 29 bits.
In addition, a MAX value like this also becomes a special case in the boundary check. Will probably do it in a separate PR.
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.
Fixed. Use const OWNER_NO_OWNER defined in owners.rs while keeping the OwnerOffset logic the same. We can continue the discussion and I will create a separate PR for how to avoid saving extra owner per file.
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.
Ah right, duh, my bad.
We can steal another bit from this struct. The owner offset doesn't need 29 bits, because that would exceed the file size limits. Is that the best use of this bit? I dunno! But it's an option, and we could change later if needed.
e.g.
16 GiB file size limit
if an account is only pubkey + owner + lamports, that's 32 + 32 + 8 = 72 bytes
16 GiB / 72 bytes per account = 238,609,294 accounts
and 2^28 = 268,435,456
So 28 bits can hold all the owners in the worst possible case (which practically cannot happen)
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.
My thought on this is that: I am not sure whether we might change the bits later when we already decided a const limit (for instance, 28 should be more than enough, but I am not sure whether we will squeeze it further for other purpose and change the limit to 27 bits).
If we want a const to represent the owner offset for no owner that we will never change, then 0 could be a good one? But as a downside, we also need to properly do
-1
when reading any entry.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.
I think the current impl with the default Pubkey representing 'no owner' is fine. Note that the system program's address is the default pubkey, so we'll likely never be storing an unnecessary owner in the owners block.
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.
FYI: This function isn't used, but is required by the CI check as we have a
len()
function: