* feat(get): consolidate GET performance optimization Consolidated implementation of all GET performance optimizations into a single, well-organized commit replacing the previous patch-on-patch approach. ## Changes ### Configuration (set_disk/mod.rs) - Consolidated all GET optimization flags into a single organized section - Enabled by default: codec streaming, metadata early-stop, page cache reclaim - Added codec streaming multipart flag (default: disabled) - Added version-aware early-stop flag (default: disabled) - Added adaptive duplex buffer sizing based on object size - All flags use OnceLock caching with rollout percentage support ### Metadata Early-Stop (set_disk/read.rs) - Delete marker early-stop when quorum agrees - Version-aware early-stop for versioned GET requests - MetadataQuorumAccumulator enhanced with: - delete_marker_votes tracking - requested_version_id and matching_version_votes tracking - version_early_stop_decision() method - 6 new tests for version early-stop scenarios ### Codec Streaming (erasure/coding/decode_reader.rs) - DualInFlight (2-stripe lookahead) enabled by default ### Decode Pipeline (erasure/coding/decode.rs) - Stripe prefetch count configuration - Bitrot-decode overlap configuration ### Disk Layer (disk/local.rs) - O_DIRECT read configuration constants (preparation) ### Metrics (io-metrics/lib.rs) - BytesPool acquisition/return metrics - Metadata phase duration with early-stop label - Total duration with reader_path label ### Diagnostics (diagnostics/) - Early-stop reason constants - Pool tier/outcome label constants ### Observability (.docker/observability/) - 3 Grafana dashboards for GET optimization monitoring - Prometheus alert rules (6 alerts: 3 critical, 3 warning) - Updated README.md and README_ZH.md with usage docs ### Config (config/src/constants/runtime.rs) - Page cache reclaim read enabled by default ## Environment Variables | Variable | Default | Description | |----------|---------|-------------| | RUSTFS_GET_CODEC_STREAMING_ENABLE | true | Codec streaming base flag | | RUSTFS_GET_CODEC_STREAMING_ROLLOUT_PCT | 100 | Codec streaming rollout % | | RUSTFS_GET_CODEC_STREAMING_MULTIPART_ENABLE | false | Multipart codec streaming | | RUSTFS_GET_METADATA_EARLY_STOP_ENABLE | true | Early-stop base flag | | RUSTFS_GET_METADATA_EARLY_STOP_ROLLOUT_PCT | 100 | Early-stop rollout % | | RUSTFS_GET_METADATA_VERSION_EARLY_STOP_ENABLE | false | Version-aware early-stop | | RUSTFS_OBJECT_FILE_CACHE_RECLAIM_READ_ENABLE | true | Page cache reclaim | | RUSTFS_OBJECT_DIRECT_IO_READ_ENABLE | false | O_DIRECT (preparation) | | RUSTFS_GET_DECODE_STRIPE_PREFETCH_COUNT | 1 | Stripe prefetch | | RUSTFS_GET_BITROT_DECODE_OVERLAP_ENABLE | false | Bitrot-decode overlap | | RUSTFS_GET_CODEC_STREAMING_MAX_INFLIGHT | 2 | DualInFlight stripes | ## Rollback All optimizations can be disabled via environment variables: RUSTFS_GET_CODEC_STREAMING_ENABLE=false RUSTFS_GET_METADATA_EARLY_STOP_ENABLE=false RUSTFS_OBJECT_FILE_CACHE_RECLAIM_READ_ENABLE=false Co-Authored-By: heihutu <heihutu@gmail.com> * test(get): add stress test scripts for GET optimization validation - quick-validate-get-optimization.sh: Quick 5-minute validation - stress-test-get-optimization.sh: Full 30+ minute stress test - README-stress-test.md: Usage documentation Co-Authored-By: heihutu <heihutu@gmail.com> * test(ecstore): align file cache reclaim defaults * chore(deps): update redis and erasure codec * test(ecstore): align decode fill policy default * fix(get): wire codec streaming rollout gate * perf(get): skip metrics-off codec timers * test(get): capture codec streaming diagnostics * test(get): add multipart fallback probe * test(get): add encrypted fallback probe * test(get): add compressed fallback probe * test(get): add degraded read fallback probe * test(get): cover remote fallback probe * test(get): report warp request p99 * test(get): capture OTLP metric deltas * perf(get): align codec streaming inflight default * perf(get): reuse codec reader output buffers * test(get): count codec reader fill starts * perf(get): reuse codec reader fill worker * perf(get): lazy init rustfs codec reconstruct * test(get): cover rustfs codec source faults * docs(get): record rustfs codec fallback scope * feat(get): add multipart codec reader opt-in * test(get): add multipart codec smoke option * test(get): cover multipart codec degraded fallback * perf(get): bound multipart codec eager setup * test(get): satisfy codec hardening PR gate --------- Co-authored-by: heihutu <heihutu@gmail.com>
rustfs-io-metrics
· Home · Docs · Issues · Discussions
Overview
rustfs-io-metrics is the metrics and configuration module for RustFS, a distributed object storage system. It provides:
- Cache Configuration: L1/L2 tiered cache configuration management
- Adaptive TTL: Dynamic TTL adjustment based on access frequency
- Metrics Collection: Unified metrics recording and reporting
- Bandwidth Monitoring: Real-time bandwidth observation and analysis
- Performance Metrics: I/O performance metrics collection
- Unified Configuration: Centralized configuration management
- Exporter Boundary: Emit via
metrics, export viarustfs-obs, no Prometheus HTTP endpoint
Features
Cache Configuration
Tiered cache configuration management:
use rustfs_io_metrics::{CacheConfig, CacheConfigError};
// Create configuration
let config = CacheConfig::new();
// Validate configuration
if let Err(e) = config.validate() {
println!("Invalid configuration: {}", e);
}
// Custom configuration
let config = CacheConfig {
max_capacity: 10_000,
default_ttl_seconds: 300,
max_memory_bytes: 100 * 1024 * 1024, // 100 MB
..Default::default()
};
Adaptive TTL
Dynamic TTL adjustment based on access frequency:
use rustfs_io_metrics::{AdaptiveTTL, AdaptiveTTLStats};
use std::time::Duration;
let config = CacheConfig::new().with_ttl_range(60, 300, 3600);
let ttl = AdaptiveTTL::new(config);
// Cold object (few accesses)
let cold_ttl = ttl.calculate_ttl(Duration::from_secs(60), 1, 0.8);
println!("Cold object TTL: {:?}", cold_ttl);
// Hot object (many accesses)
let hot_ttl = ttl.calculate_ttl(Duration::from_secs(60), 100, 0.8);
println!("Hot object TTL: {:?}", hot_ttl);
Access Tracking
Track cache item access patterns:
use rustfs_io_metrics::{AccessTracker, AccessRecord};
use std::time::Duration;
let mut tracker = AccessTracker::new(1000, Duration::from_secs(300));
// Record accesses
tracker.record_access("object-key-1", 1024);
tracker.record_access("object-key-1", 1024);
tracker.record_access("object-key-2", 2048);
// Get access count
let count = tracker.get_access_count("object-key-1");
println!("Access count: {}", count);
// Detect hot/cold
if tracker.is_hot("object-key-1", 1) {
println!("Hot object");
}
// Get top keys
let top_keys = tracker.top_keys(10);
for (key, count) in top_keys {
println!("{}: {} accesses", key, count);
}
Metrics Recording
Unified metrics recording functions:
use rustfs_io_metrics::{
// I/O scheduler metrics
record_io_scheduler_decision,
record_io_strategy_change,
record_io_load_level,
// Cache metrics
record_cache_size,
// Backpressure metrics
record_backpressure_event,
record_backpressure_state,
// Timeout metrics
record_timeout_event,
record_operation_duration,
};
// Record I/O scheduler decision
record_io_scheduler_decision("sequential", "high_priority");
// Record cache size
record_cache_size("L1", 1024, 1);
// Record backpressure event
record_backpressure_event("warning", 0.85);
// Record operation timeout
record_timeout_event("GetObject", Duration::from_secs(30));
Internode Transport Metrics
Internode metrics are recorded by src/internode_metrics.rs. Aggregate metrics
remain unlabeled for compatibility with existing dashboards:
| Metric | Meaning |
|---|---|
rustfs_system_network_internode_sent_bytes_total |
Total internode bytes sent by this node. |
rustfs_system_network_internode_recv_bytes_total |
Total internode bytes received by this node. |
rustfs_system_network_internode_requests_outgoing_total |
Total outgoing internode requests. |
rustfs_system_network_internode_requests_incoming_total |
Total incoming internode requests. |
rustfs_system_network_internode_errors_total |
Total internode errors. |
rustfs_system_network_internode_dial_errors_total |
Failed internode connection attempts. |
rustfs_system_network_internode_dial_avg_time_nanos |
Average internode dial duration. |
Operation-level metrics use the same low-cardinality label set:
| Metric | Labels | Meaning |
|---|---|---|
rustfs_system_network_internode_operation_sent_bytes_total |
operation, backend |
Bytes sent for an internode operation. |
rustfs_system_network_internode_operation_recv_bytes_total |
operation, backend |
Bytes received for an internode operation. |
rustfs_system_network_internode_operation_requests_outgoing_total |
operation, backend |
Outgoing request attempts for an internode operation. |
rustfs_system_network_internode_operation_requests_incoming_total |
operation, backend |
Incoming request attempts for an internode operation. |
rustfs_system_network_internode_operation_errors_total |
operation, backend |
Failed internode operation attempts. |
rustfs_system_network_internode_operation_classified_errors_total |
operation, backend, classification |
Classified internode transport failures. |
rustfs_system_network_internode_operation_retries_total |
operation, backend, classification |
Retry attempts for retryable internode transport failures. |
rustfs_system_network_internode_operation_retry_successes_total |
operation, backend, classification |
Successful recoveries after retryable internode transport failures. |
rustfs_system_storage_erasure_write_quorum_failures_total |
stage, dominant_error |
Erasure write quorum failures grouped by failure stage and dominant error class. |
Current operation values are read_file_stream, put_file_stream,
walk_dir, grpc_read_all, and grpc_write_all. Current backend values are
tcp-http for the InternodeDataTransport TCP/HTTP path and grpc for the
remaining gRPC byte paths. The compatibility wrapper uses unknown only for
callers that have not been classified yet.
Success/failure is intentionally not a high-cardinality label today. Failures
are represented by rustfs_system_network_internode_operation_errors_total;
successful completions are not emitted as a dedicated result-labeled metric.
Adding completion/result labels is a follow-up once stream completion semantics
are defined consistently for request setup, body transfer, and shutdown.
Current low-cardinality classification values come from the TCP/HTTP internode
path and include:
connect_timeoutconnection_refuseddns_resolution_failedconnection_resetbody_stream_abortedhttp_429http_502http_503http_504http_status_otherunknown
scripts/run_internode_transport_baseline.sh --metrics-url ... records metric
deltas with operation and backend columns, so the TCP baseline can attribute
bytes and request/error counts to tcp-http transport operations.
Unified Configuration
Centralized configuration management:
use rustfs_io_metrics::{
IoConfig, CacheSettings, IoSchedulerSettings,
BackpressureSettings, TimeoutSettings,
};
let config = IoConfig::new()
.with_cache(CacheSettings::new()
.with_max_capacity(10_000)
.with_ttl(std::time::Duration::from_secs(300)))
.with_scheduler(IoSchedulerSettings::new()
.with_max_concurrent_reads(64))
.with_backpressure(BackpressureSettings::new())
.with_timeout(TimeoutSettings::new());
// Access configuration
println!("Cache capacity: {}", config.cache.max_capacity);
println!("Max concurrent reads: {}", config.scheduler.max_concurrent_reads);
Module Structure
rustfs-io-metrics/
├── src/
│ ├── lib.rs # Module entry
│ ├── cache_config.rs # Cache configuration
│ ├── adaptive_ttl.rs # Adaptive TTL
│ ├── config.rs # Unified configuration
│ ├── io_metrics.rs # I/O metrics
│ ├── backpressure_metrics.rs # Backpressure metrics
│ ├── deadlock_metrics.rs # Deadlock metrics
│ ├── lock_metrics.rs # Lock metrics
│ ├── timeout_metrics.rs # Timeout metrics
│ ├── internode_metrics.rs # Internode transport metrics
│ ├── bandwidth.rs # Bandwidth monitoring
│ ├── global_metrics.rs # Global metrics
│ └── performance.rs # Performance metrics
└── Cargo.toml
Testing
# Run all tests
cargo test --package rustfs-io-metrics
# Run specific tests
cargo test --package rustfs-io-metrics --lib adaptive_ttl
# Run benchmarks
cargo bench --package rustfs-io-metrics --bench metrics_pipeline
Documentation
This crate records metrics through the Rust metrics crate and leaves
exporting to rustfs-obs or the application-level observability pipeline. It
does not expose Prometheus-compatible HTTP endpoints such as
/rustfs/v2/metrics/cluster or /rustfs/v2/metrics/node.
API documentation can be generated locally:
cargo doc --package rustfs-io-metrics --no-deps --open
Useful source references:
Related Modules
- rustfs-io-core: Core I/O scheduling
- rustfs: Main storage service
License
Apache License 2.0