Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

[TieredStorage] Make HotStorageReader use AccountOffset type #33964

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions accounts-db/src/tiered_storage/hot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
footer::{
AccountBlockFormat, AccountMetaFormat, OwnersBlockFormat, TieredStorageFooter,
},
index::IndexBlockFormat,
index::{AccountOffset, IndexBlockFormat},
meta::{AccountMetaFlags, AccountMetaOptionalFields, TieredAccountMeta},
mmap_utils::get_type,
TieredStorageFormat, TieredStorageResult,
Expand Down Expand Up @@ -223,8 +223,11 @@ impl HotStorageReader {
}

/// Returns the account meta located at the specified offset.
fn get_account_meta_from_offset(&self, offset: usize) -> TieredStorageResult<&HotAccountMeta> {
let (meta, _) = get_type::<HotAccountMeta>(&self.mmap, offset)?;
fn get_account_meta_from_offset(
&self,
account_offset: AccountOffset,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these offset types should belong to Hot (and Cold), instead of the layer above (Index).

I think this is fine for now, but this is/will prevent adding more tiers/changing tiers later.

Copy link
Contributor Author

@yhchiang-sol yhchiang-sol Nov 9, 2023

Choose a reason for hiding this comment

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

I think this is fine for now, but this is/will prevent adding more tiers/changing tiers later.

I think having it inside the index format should give us more flexibility.

The tiered-storage format is determined by account meta format, account block format, index block format, and owners-block format. Hot and Cold are conceptual formats formed by these building blocks.

So one can change some of the formats to make it a warm tier.

) -> TieredStorageResult<&HotAccountMeta> {
let (meta, _) = get_type::<HotAccountMeta>(&self.mmap, account_offset.block)?;
Ok(meta)
}
}
Expand All @@ -241,7 +244,7 @@ pub mod tests {
FOOTER_SIZE,
},
hot::{HotAccountMeta, HotStorageReader},
index::IndexBlockFormat,
index::{AccountOffset, IndexBlockFormat},
meta::{AccountMetaFlags, AccountMetaOptionalFields, TieredAccountMeta},
},
memoffset::offset_of,
Expand Down Expand Up @@ -444,7 +447,7 @@ pub mod tests {
.map(|meta| {
let prev_offset = current_offset;
current_offset += file.write_type(meta).unwrap();
prev_offset
AccountOffset { block: prev_offset }
})
.collect();
// while the test only focuses on account metas, writing a footer
Expand Down