pub(crate) struct SnapshotStorageRebuilder {
    file_receiver: Receiver<PathBuf>,
    num_threads: usize,
    snapshot_storage_lengths: HashMap<Slot, HashMap<usize, usize>>,
    storage_paths: DashMap<Slot, Mutex<Vec<PathBuf>>>,
    storage: AccountStorageMap,
    next_append_vec_id: Arc<AtomicAppendVecId>,
    processed_slot_count: AtomicUsize,
    num_collisions: AtomicUsize,
    snapshot_from: SnapshotFrom,
}
Expand description

Stores state for rebuilding snapshot storages

Fields§

§file_receiver: Receiver<PathBuf>

Receiver for unpacked snapshot storage files

§num_threads: usize

Number of threads to rebuild with

§snapshot_storage_lengths: HashMap<Slot, HashMap<usize, usize>>

Snapshot storage lengths - from the snapshot file

§storage_paths: DashMap<Slot, Mutex<Vec<PathBuf>>>

Container for storing snapshot file paths

§storage: AccountStorageMap

Container for storing rebuilt snapshot storages

§next_append_vec_id: Arc<AtomicAppendVecId>

Tracks next append_vec_id

§processed_slot_count: AtomicUsize

Tracker for number of processed slots

§num_collisions: AtomicUsize

Tracks the number of collisions in AppendVecId

§snapshot_from: SnapshotFrom

Rebuild from the snapshot files or archives

Implementations§

source§

impl SnapshotStorageRebuilder

source

pub(crate) fn rebuild_storage( file_receiver: Receiver<PathBuf>, num_threads: usize, next_append_vec_id: Arc<AtomicAppendVecId>, snapshot_from: SnapshotFrom ) -> Result<RebuiltSnapshotStorage, SnapshotError>

Synchronously spawns threads to rebuild snapshot storages

source

fn new( file_receiver: Receiver<PathBuf>, num_threads: usize, next_append_vec_id: Arc<AtomicAppendVecId>, snapshot_storage_lengths: HashMap<Slot, HashMap<usize, usize>>, snapshot_from: SnapshotFrom ) -> Self

Create the SnapshotStorageRebuilder for storing state during rebuilding - pre-allocates data for storage paths

source

fn get_version_and_snapshot_files( file_receiver: &Receiver<PathBuf> ) -> (PathBuf, PathBuf, Vec<PathBuf>)

Waits for snapshot file Due to parallel unpacking, we may receive some append_vec files before the snapshot file This function will push append_vec files into a buffer until we receive the snapshot file

source

fn process_snapshot_file( snapshot_version: SnapshotVersion, snapshot_file_path: PathBuf ) -> Result<HashMap<Slot, HashMap<usize, usize>>, Error>

Process the snapshot file to get the size of each snapshot storage file

source

fn spawn_rebuilder_threads( file_receiver: Receiver<PathBuf>, num_threads: usize, next_append_vec_id: Arc<AtomicAppendVecId>, snapshot_storage_lengths: HashMap<Slot, HashMap<usize, usize>>, append_vec_files: Vec<PathBuf>, snapshot_from: SnapshotFrom ) -> Result<AccountStorageMap, Error>

Spawn threads for processing buffered append_vec_files, and then received files

source

fn process_buffered_files( &self, append_vec_files: Vec<PathBuf> ) -> Result<(), Error>

Processes buffered append_vec_files

source

fn spawn_receiver_thread( thread_pool: &ThreadPool, exit_sender: Sender<Result<(), Error>>, rebuilder: Arc<SnapshotStorageRebuilder> )

Spawn a single thread to process received append_vec_files

source

fn process_append_vec_file(&self, path: PathBuf) -> Result<(), Error>

Process an append_vec_file

source

fn insert_storage_file(&self, slot: &Slot, path: PathBuf) -> usize

Insert storage path into slot and return the number of storage files for the slot

source

fn process_complete_slot(&self, slot: Slot) -> Result<(), Error>

Process a slot that has received all storage entries

source

fn get_unique_append_vec_id( next_append_vec_id: &Arc<AtomicAppendVecId>, parent_folder: &Path, slot: Slot ) -> AppendVecId

increment next_append_vec_id until there is no file in parent_folder with this id and slot return the id

source

fn wait_for_completion( &self, exit_receiver: Receiver<Result<(), Error>> ) -> Result<(), Error>

Wait for the completion of the rebuilding threads

source

fn build_thread_pool(&self) -> ThreadPool

Builds thread pool to rebuild with

Trait Implementations§

source§

impl Debug for SnapshotStorageRebuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> AbiExample for T

source§

default fn example() -> T

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more