mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 16:28:15 +00:00
refactor(config): remove dead Direct I/O constants from zero_copy.rs (#4379)
ENV_OBJECT_DIRECT_IO_ENABLE, DEFAULT_OBJECT_DIRECT_IO_ENABLE, ENV_OBJECT_DIRECT_IO_THRESHOLD and DEFAULT_OBJECT_DIRECT_IO_THRESHOLD were never read anywhere in the workspace. The real O_DIRECT read path landed in PR #4365 uses RUSTFS_OBJECT_DIRECT_IO_READ_ENABLE / RUSTFS_OBJECT_DIRECT_IO_READ_THRESHOLD (crates/ecstore/src/disk/local.rs). Keeping the near-identically named dead knobs invites operators to set the wrong variable and believe O_DIRECT is enabled. Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
@@ -56,58 +56,3 @@ pub const DEFAULT_OBJECT_MMAP_READ_ENABLE: bool = true;
|
||||
///
|
||||
/// Prefer [`DEFAULT_OBJECT_MMAP_READ_ENABLE`].
|
||||
pub const DEFAULT_OBJECT_ZERO_COPY_ENABLE: bool = DEFAULT_OBJECT_MMAP_READ_ENABLE;
|
||||
|
||||
// =============================================================================
|
||||
// Direct I/O Configuration
|
||||
// =============================================================================
|
||||
|
||||
/// Environment variable for Direct I/O enable (Linux only).
|
||||
///
|
||||
/// When enabled, uses O_DIRECT flag to bypass OS page cache for large files.
|
||||
/// This is only beneficial for specific workloads (databases, large sequential reads).
|
||||
///
|
||||
/// - Purpose: Enable or disable Direct I/O for large file operations
|
||||
/// - Acceptable values: `"true"` / `"false"` (case-insensitive) or a boolean typed config
|
||||
/// - Semantics: When enabled, files larger than the threshold will use O_DIRECT flag;
|
||||
/// this bypasses the OS page cache and transfers data directly between disk and application
|
||||
/// - Example: `export RUSTFS_OBJECT_DIRECT_IO_ENABLE=true`
|
||||
/// - Note: Direct I/O is disabled by default because it's only beneficial for specific
|
||||
/// use cases. For most workloads, the OS page cache provides better performance.
|
||||
pub const ENV_OBJECT_DIRECT_IO_ENABLE: &str = "RUSTFS_OBJECT_DIRECT_IO_ENABLE";
|
||||
|
||||
/// Default: Direct I/O is disabled.
|
||||
///
|
||||
/// Direct I/O is disabled by default because it's only beneficial for specific use cases:
|
||||
/// - Large file transfers (>128MB)
|
||||
/// - Databases with their own cache
|
||||
/// - Applications requiring predictable I/O latency
|
||||
///
|
||||
/// For most workloads, the OS page cache provides better performance through:
|
||||
/// - Read-ahead caching
|
||||
/// - Write buffering
|
||||
/// - Multi-use caching (same data cached for multiple operations)
|
||||
pub const DEFAULT_OBJECT_DIRECT_IO_ENABLE: bool = false;
|
||||
|
||||
/// Environment variable for Direct I/O minimum file size threshold.
|
||||
///
|
||||
/// Files smaller than this size will use regular I/O even if Direct I/O is enabled.
|
||||
/// This avoids the overhead of Direct I/O for small files where the OS page cache
|
||||
/// is more effective.
|
||||
///
|
||||
/// - Purpose: Set the minimum file size for Direct I/O operations
|
||||
/// - Unit: Bytes
|
||||
/// - Valid values: any positive integer (default: 134,217,728 bytes = 128 MB)
|
||||
/// - Semantics: Only files larger than this threshold will use Direct I/O when enabled;
|
||||
/// smaller files use regular buffered I/O
|
||||
/// - Example: `export RUSTFS_OBJECT_DIRECT_IO_THRESHOLD=268435456`
|
||||
/// - Note: The default threshold of 128MB balances the overhead of Direct I/O setup
|
||||
/// against the benefits of bypassing the page cache for large files.
|
||||
pub const ENV_OBJECT_DIRECT_IO_THRESHOLD: &str = "RUSTFS_OBJECT_DIRECT_IO_THRESHOLD";
|
||||
|
||||
/// Default Direct I/O threshold: 128 MB.
|
||||
///
|
||||
/// Only files larger than 128MB will use Direct I/O when enabled.
|
||||
/// Smaller files benefit from OS page cache.
|
||||
///
|
||||
/// Formula: 128 * 1024 * 1024 = 134,217,728 bytes
|
||||
pub const DEFAULT_OBJECT_DIRECT_IO_THRESHOLD: usize = 128 * 1024 * 1024;
|
||||
|
||||
Reference in New Issue
Block a user