v0.1.33 - Auto-Reload Optimization with mtime Change Detection
π Performance Optimization
This release introduces mtime-based change detection for auto-reload workers, dramatically reducing disk I/O while maintaining cache freshness.
β¨ New Features
- Smart file change detection: Auto-reload workers now track file modification times (mtime) and skip reading unchanged CSV files
- 99.998% I/O reduction: From ~1.6 billion records/day to ~36K records/day
- Comprehensive documentation: New
docs/SYNC_LOAD.mdexplaining the sync and auto-reload architecture
π Performance Improvements
Before (v0.1.32):
- Auto-reload: Read ALL files every 30 seconds
- Daily I/O: ~555K records Γ 2,880 checks = 1.6 billion records
- No distinction between active trading and idle periods
After (v0.1.33):
- Auto-reload: Only read files whose mtime has changed
- Trading hours: ~36K records (only recently synced files)
- Off-hours/holidays: 0 records (no sync activity = no changes)
- Reload time: 422ms β 5ms when files unchanged (98.8% faster)
π§ Technical Details
How It Works:
- Track each CSV file's modification time after reading
- Before next reload: Check if
current_mtime != stored_mtime - If unchanged: Skip reading (file hasn't been modified by sync workers)
- If changed: Read file and update stored mtime
Key Insight:
- NOT a time threshold check ("is file recent?")
- IS a change detection check ("has mtime changed since last reload?")
- Sync workers always update mtime when writing β reliable change detection
π Changes
Modified:
src/services/data_store.rs: Add mtime tracking and comparison logic- New field:
file_mtimes: RwLock<HashMap<(String, Interval), SystemTime>> - Modified:
load_interval()to check mtime before reading - Added: Detailed logging for files read vs skipped
- New field:
Added:
docs/SYNC_LOAD.md: Comprehensive architecture documentation- Two-tier system: Sync workers (write) + Auto-reload workers (read)
- Why sync always rewrites files (and why that's beneficial)
- Timeline examples for trading hours and off-hours
- FAQ and troubleshooting guide
π― Use Cases
This optimization is especially beneficial for:
- β 24/7 deployments: Zero I/O during market holidays/weekends
- β Resource-constrained VPS: Reduced CPU and disk usage
- β Long-running servers: Consistent low overhead regardless of market activity
- β Multiple data modes: Benefits both VN stocks and crypto data
π Documentation
See docs/SYNC_LOAD.md for detailed technical documentation including:
- Architecture overview
- Performance characteristics
- Code references with line numbers
- FAQ addressing common questions