rustfs-io-core
Overview
rustfs-io-core holds the shared I/O primitives for RustFS, a distributed object storage system. It provides:
- Buffer Pool: Tiered
BytesPoolfor buffer reuse - Storage Profiling: Storage-media and access-pattern model (
io_profile) - Scheduler Configuration: The
IoSchedulerConfig/IoPriorityQueueConfigshapes the storage layer projects into - Backpressure Control: System overload protection with graceful degradation
- Deadlock Detection: Wait-for graph based deadlock detection algorithm
- Lock Optimizer: Adaptive spin lock optimization
- Progress Tracking: Byte progress and staleness for long-running operations
The scheduling algorithm itself lives in rustfs/src/storage/concurrency/io_schedule.rs; this crate carries the configuration shapes it projects into, not a second implementation.
Features
Backpressure Control
System overload protection:
use ;
let config = BackpressureConfig ;
let monitor = new;
// Check state
match monitor.state
Deadlock Detection
Wait-for graph based deadlock detection:
use ;
let detector = with_defaults;
// Register locks
let lock1 = detector.register_lock;
let lock2 = detector.register_lock;
// Record lock acquisition
detector.record_acquire; // Thread 1 acquires lock1
detector.record_wait; // Thread 1 waits for lock2
// Detect deadlock
if let Some = detector.detect_deadlock
Lock Optimizer
Adaptive spin lock optimization:
use ;
let optimizer = with_defaults;
// Record lock operations
optimizer.on_acquire;
// ... do work ...
optimizer.on_release;
// View statistics
let stats = optimizer.stats;
println!;
Progress Tracking
Byte progress and staleness for long-running operations:
use OperationProgress;
use Duration;
let progress = new;
progress.update;
assert_eq!;
assert!;
Configuration
Code Configuration
use IoSchedulerConfig;
let config = IoSchedulerConfig ;
// Validate configuration
if let Err = config.validate
Module Structure
rustfs-io-core/
├── src/
│ ├── lib.rs # Module entry
│ ├── config.rs # Configuration types
│ ├── pool.rs # Tiered buffer pool
│ ├── backpressure.rs # Backpressure control
│ ├── deadlock_detector.rs # Deadlock detection
│ ├── lock_optimizer.rs # Lock optimization
│ ├── progress.rs # Operation progress tracking
│ └── io_profile.rs # I/O profile
└── Cargo.toml
Testing
# Run all tests
# Run specific tests
Documentation
Related Modules
- rustfs-io-metrics: Metrics collection and configuration
- rustfs: Main storage service
License
Apache License 2.0