Skip to content
Merged
Show file tree
Hide file tree
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
32 changes: 16 additions & 16 deletions cache2/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ use crate::memory::MemoryStore;
use crate::recovery::DataGeometry;

mod runtime;
mod storage;

pub use runtime::IoEngine;
pub use runtime::IoMode;
pub(crate) use runtime::IoPoolTopology;
pub use runtime::IoUringConfig;
pub use runtime::IoUringPoolConfig;
pub use runtime::IoUringSqPollConfig;
pub use runtime::L1EvictionPolicy;
pub use self::runtime::IoEngine;
pub use self::runtime::IoMode;
pub(crate) use self::runtime::IoPoolTopology;
pub use self::runtime::IoUringConfig;
pub use self::runtime::IoUringPoolConfig;
pub use self::runtime::IoUringSqPollConfig;
pub use self::runtime::L1EvictionPolicy;
#[cfg(test)]
pub(crate) use runtime::MAX_WRITE_FLUSH_THRESHOLD_BYTES;
pub use runtime::PosixIoConfig;
pub use runtime::ReadAdmission;
pub use runtime::RuntimeOptions;
pub(crate) use storage::KEY_HASH_SEED;
pub use storage::StorageLayout;
pub use storage::StorageOptions;
pub(crate) use self::runtime::MAX_WRITE_FLUSH_THRESHOLD_BYTES;
pub use self::runtime::PosixIoConfig;
pub use self::runtime::ReadAdmission;
pub use self::runtime::RuntimeOptions;

mod storage;
pub(crate) use self::storage::KEY_HASH_SEED;
pub use self::storage::StorageLayout;
pub use self::storage::StorageOptions;

/// Complete, immutable configuration for opening a [`crate::Cache`].
///
Expand Down
17 changes: 8 additions & 9 deletions cache2/src/index_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ use std::sync::TryLockError;
use std::sync::atomic::AtomicU8;
use std::sync::atomic::Ordering;

use self::page_format::PAGE_CHECKSUM_OFFSET;
use self::page_format::encode_page_header;
use self::page_format::page_checksum;
use self::page_format::put_u32;
#[cfg(test)]
use self::page_format::put_u64;
use self::page_format::read_u64;
use self::page_format::validate_page_header;
use crate::index::INDEX_CANDIDATES;
use crate::index::IndexEntry;
use crate::index::MAX_INDEX_PARTITIONS;
Expand All @@ -45,19 +53,10 @@ use crate::index::index_partition_for;
use crate::index::record_size_class_upper_bound;

mod page_format;

pub(crate) use self::page_format::INDEX_IMAGE_PAGE_HEADER_SIZE;
pub(crate) use self::page_format::INDEX_IMAGE_PAGE_SIZE;
pub(crate) use self::page_format::INDEX_IMAGE_SLOT_SIZE;
pub(crate) use self::page_format::INDEX_IMAGE_SLOTS_PER_PAGE;
use self::page_format::PAGE_CHECKSUM_OFFSET;
use self::page_format::encode_page_header;
use self::page_format::page_checksum;
use self::page_format::put_u32;
#[cfg(test)]
use self::page_format::put_u64;
use self::page_format::read_u64;
use self::page_format::validate_page_header;

/// Upper bound for one underlying warm-image write.
///
Expand Down
57 changes: 28 additions & 29 deletions cache2/src/io_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,34 @@ use crate::resources::BufferLease;
use crate::resources::CACHE_THREAD_STACK_BYTES;
use crate::snapshot::CacheIoDirectionSnapshot;

mod posix;
pub(crate) use self::posix::BackendIoEngine;

#[cfg(all(
feature = "io-uring",
target_os = "linux",
any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64",
target_arch = "powerpc64"
)
))]
mod uring;
#[cfg(all(
feature = "io-uring",
target_os = "linux",
any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64",
target_arch = "powerpc64"
)
))]
pub(crate) use self::uring::UringIoEngine;

pub(crate) const IO_BUFFER_ALIGNMENT: usize = 4096;
pub(crate) const MAX_IO_REQUESTS_PER_ENGINE: usize = 4096;
// Common bounded command, completion, and request bookkeeping. Payload
Expand Down Expand Up @@ -1942,35 +1970,6 @@ impl Drop for RuntimeInner {
}
}

mod posix;
pub(crate) use posix::BackendIoEngine;

#[cfg(all(
feature = "io-uring",
target_os = "linux",
any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64",
target_arch = "powerpc64"
)
))]
mod uring;

#[cfg(all(
feature = "io-uring",
target_os = "linux",
any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64",
target_arch = "powerpc64"
)
))]
pub(crate) use uring::UringIoEngine;

#[cfg(unix)]
pub(crate) fn build_file_engine(
files: RuntimeFileSet,
Expand Down
69 changes: 36 additions & 33 deletions cache2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,46 @@
#[cfg(feature = "benchmarking")]
#[doc(hidden)]
pub mod benchmarking;
pub mod error;

pub use cache::Cache;
pub use cache::CacheTier;
pub use cache::Value;
pub use config::CacheConfig;
pub use config::IoEngine;
pub use config::IoMode;
pub use config::IoUringConfig;
pub use config::IoUringPoolConfig;
pub use config::IoUringSqPollConfig;
pub use config::L1EvictionPolicy;
pub use config::PosixIoConfig;
pub use config::ReadAdmission;
pub use config::RuntimeOptions;
pub use config::StorageLayout;
pub use config::StorageOptions;
pub use error::Error;
pub use error::ErrorKind;
pub use error::ErrorOperation;
pub use error::Result;
pub use snapshot::CacheHealth;
pub use snapshot::CacheIndexSnapshot;
pub use snapshot::CacheIoDirectionSnapshot;
pub use snapshot::CacheIoPathSnapshot;
pub use snapshot::CacheIoSnapshot;
pub use snapshot::CacheL1Snapshot;
pub use snapshot::CacheReclaimSnapshot;
pub use snapshot::CacheSnapshot;
pub use snapshot::DetailedCacheSnapshot;
pub use snapshot::RegionSnapshot;
pub use snapshot::StartupMode;
pub mod error;
pub use self::error::Error;
pub use self::error::ErrorKind;
pub use self::error::ErrorOperation;
pub use self::error::Result;

mod cache;
mod checksum;
pub use self::cache::Cache;
pub use self::cache::CacheTier;
pub use self::cache::Value;

mod config;
pub use self::config::CacheConfig;
pub use self::config::IoEngine;
pub use self::config::IoMode;
pub use self::config::IoUringConfig;
pub use self::config::IoUringPoolConfig;
pub use self::config::IoUringSqPollConfig;
pub use self::config::L1EvictionPolicy;
pub use self::config::PosixIoConfig;
pub use self::config::ReadAdmission;
pub use self::config::RuntimeOptions;
pub use self::config::StorageLayout;
pub use self::config::StorageOptions;

mod snapshot;
pub use self::snapshot::CacheHealth;
pub use self::snapshot::CacheIndexSnapshot;
pub use self::snapshot::CacheIoDirectionSnapshot;
pub use self::snapshot::CacheIoPathSnapshot;
pub use self::snapshot::CacheIoSnapshot;
pub use self::snapshot::CacheL1Snapshot;
pub use self::snapshot::CacheReclaimSnapshot;
pub use self::snapshot::CacheSnapshot;
pub use self::snapshot::DetailedCacheSnapshot;
pub use self::snapshot::RegionSnapshot;
pub use self::snapshot::StartupMode;

mod checksum;
mod eviction;
mod format;
mod hashing;
Expand All @@ -77,7 +81,6 @@ mod region_runtime;
mod region_staging;
mod region_store;
mod resources;
mod snapshot;

#[cfg(test)]
mod fixtures;
Expand Down
8 changes: 4 additions & 4 deletions cache2/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
//! backend-independent shutdown state machine remains in `region_store`.

pub(crate) mod core;
mod file_backend;

pub(crate) use file_backend::FileRegionBackend;
pub(crate) use file_backend::RegionFiles;
pub(crate) use file_backend::SystemRegionFileSystem;
mod file_backend;
pub(crate) use self::file_backend::FileRegionBackend;
pub(crate) use self::file_backend::RegionFiles;
pub(crate) use self::file_backend::SystemRegionFileSystem;
11 changes: 5 additions & 6 deletions cache2/src/region_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,12 @@ use asyncband::semaphore::OwnedSemaphorePermit;
use asyncband::semaphore::Semaphore;
use asyncband::watch;

#[cfg(test)]
use crate::config::ReadAdmission;

mod metrics;

pub(crate) use self::metrics::ActivityMetrics;
use self::metrics::RuntimeMetrics;
use crate::config::CacheConfig;
use crate::config::IoMode;
use crate::config::IoPoolTopology;
#[cfg(test)]
use crate::config::ReadAdmission;
use crate::config::RuntimeOptions;
use crate::format::MAX_KEY_SIZE;
use crate::hashing::route_hash;
Expand Down Expand Up @@ -94,6 +90,9 @@ use crate::snapshot::CacheIoSnapshot;
use crate::snapshot::CacheSnapshot;
use crate::snapshot::DetailedCacheSnapshot;

mod metrics;
pub(crate) use self::metrics::ActivityMetrics;

const WRITE_FLUSH_DELAY: Duration = Duration::from_millis(1);
const _RETRY_AGE: Duration = Duration::from_micros(50);
const LIFECYCLE_RUNNING: u8 = 0;
Expand Down