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

Commit

Permalink
Helper function for creating ShredStorageType::RocksFifo (#25569)
Browse files Browse the repository at this point in the history
#### Problem
Currently, the creation of ShredStorageType::RocksFifo is hard coded in validator/src/main.rs.
But this common code will also need to be used in other places like ledger-tool.

#### Summary of Changes
This PR creates a helper functionShredStorageType::rocks_fifo that takes a total shred_storage_size
and equally allocates to data-shred and coding-shred storage.
  • Loading branch information
yhchiang-sol authored Jun 7, 2022
1 parent 5f04512 commit 591986e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
21 changes: 17 additions & 4 deletions ledger/src/blockstore_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ impl Default for ShredStorageType {
}
}

impl ShredStorageType {
/// Returns ShredStorageType::RocksFifo where the specified
/// `shred_storage_size` is equally allocated to shred_data_cf_size
/// and shred_code_cf_size.
pub fn rocks_fifo(shred_storage_size: u64) -> ShredStorageType {
ShredStorageType::RocksFifo(BlockstoreRocksFifoOptions::new(shred_storage_size))
}
}

#[derive(Debug, Clone)]
pub struct BlockstoreRocksFifoOptions {
// The maximum storage size for storing data shreds in column family
Expand Down Expand Up @@ -162,11 +171,15 @@ pub const DEFAULT_ROCKS_FIFO_SHRED_STORAGE_SIZE_BYTES: u64 = 250 * 1024 * 1024 *

impl Default for BlockstoreRocksFifoOptions {
fn default() -> Self {
BlockstoreRocksFifoOptions::new(DEFAULT_ROCKS_FIFO_SHRED_STORAGE_SIZE_BYTES)
}
}

impl BlockstoreRocksFifoOptions {
fn new(shred_storage_size: u64) -> Self {
Self {
// Maximum size of cf::ShredData.
shred_data_cf_size: DEFAULT_ROCKS_FIFO_SHRED_STORAGE_SIZE_BYTES / 2,
// Maximum size of cf::ShredCode.
shred_code_cf_size: DEFAULT_ROCKS_FIFO_SHRED_STORAGE_SIZE_BYTES / 2,
shred_data_cf_size: shred_storage_size / 2,
shred_code_cf_size: shred_storage_size / 2,
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ use {
},
solana_gossip::{cluster_info::Node, contact_info::ContactInfo},
solana_ledger::blockstore_options::{
BlockstoreCompressionType, BlockstoreRecoveryMode, BlockstoreRocksFifoOptions,
LedgerColumnOptions, ShredStorageType, DEFAULT_ROCKS_FIFO_SHRED_STORAGE_SIZE_BYTES,
BlockstoreCompressionType, BlockstoreRecoveryMode, LedgerColumnOptions, ShredStorageType,
DEFAULT_ROCKS_FIFO_SHRED_STORAGE_SIZE_BYTES,
},
solana_net_utils::VALIDATOR_PORT_RANGE,
solana_perf::recycler::enable_recycler_warming,
Expand Down Expand Up @@ -2771,10 +2771,7 @@ pub fn main() {
"fifo" => {
let shred_storage_size =
value_t_or_exit!(matches, "rocksdb_fifo_shred_storage_size", u64);
ShredStorageType::RocksFifo(BlockstoreRocksFifoOptions {
shred_data_cf_size: shred_storage_size / 2,
shred_code_cf_size: shred_storage_size / 2,
})
ShredStorageType::rocks_fifo(shred_storage_size)
}
_ => panic!(
"Unrecognized rocksdb-shred-compaction: {}",
Expand Down

0 comments on commit 591986e

Please sign in to comment.