Mesclar dev-talesam em master#1
Merged
Merged
Conversation
… responsiveness
This commit addresses system slowdown issues caused by aggressive swap
behavior and insufficient anti-thrashing protection across different RAM
profiles.
PROBLEM IDENTIFIED:
- Systems with 8-16GB RAM were classified as "Standard" profile with only
1000ms MGLRU protection, causing excessive thrashing
- Small swap chunk size (512M) created too many swap files, leading to
fragmentation and I/O overhead
- Static RAM-based detection didn't consider actual memory pressure
- VeryHigh profile (>32GB) had only 250ms protection, inadequate for
heavy workstation loads
CHANGES MADE:
1. Increased MGLRU min_ttl values for all profiles (src/autoconfig.rs):
- UltraLow (≤2GB): 5000ms (unchanged)
- Low (2-4GB): 3000ms → 4000ms (+33%)
- Medium (4-8GB): 2000ms → 3000ms (+50%)
- Standard (8-16GB): 1000ms → 3000ms (+200%) [CRITICAL FIX]
- High (16-32GB): 500ms → 2000ms (+300%)
- VeryHigh (>32GB): 250ms → 2000ms (+700%)
2. Increased default swap chunk size (src/autoconfig.rs):
- NVMe/SSD: 512M → 1G (less fragmentation, better performance)
- HDD: 256M → 512M
3. Added dynamic memory pressure detection (src/meminfo.rs):
- New MemoryPressure enum (Low/Medium/High/Critical)
- get_memory_pressure() function based on MemAvailable
- get_available_ram_percent() for accurate memory detection
4. Implemented adaptive MGLRU adjustment (src/autoconfig.rs):
- New recommended_mglru_with_pressure() method
- Increases MGLRU protection based on actual memory pressure:
* Medium pressure (20-40% available): +50%
* High pressure (10-20% available): +100%
* Critical pressure (<10% available): +200%
5. Applied pressure detection at daemon startup (src/main.rs):
- Daemon now detects memory pressure on initialization
- Automatically adjusts MGLRU value based on real system conditions
- Falls back to static values if pressure detection unavailable
6. Updated default configuration documentation (include/swap-default.conf):
- Changed swapfile_chunk_size from 512M to 1G in comments
IMPACT:
Before (16GB RAM system under pressure):
- MGLRU: 1000ms (1 second)
- Chunk size: 512M
- Result: 14 small swap files, excessive thrashing, system slowdown
After (same system):
- MGLRU: 3000-6000ms (3-6 seconds, adaptive)
- Chunk size: 1G
- Result: Fewer larger swap files, better responsiveness, no thrashing
TESTING:
- Verified on 15GB RAM system with high swap usage (13GB/19GB)
- Memory pressure detection working correctly
- MGLRU values now adapt to actual system load
- Backward compatible: manual config values still respected
BENEFITS:
- Better desktop responsiveness across all RAM configurations
- Reduced swap fragmentation and I/O overhead
- Adaptive protection based on actual memory pressure, not just RAM size
- Suitable for light systems (4GB) and heavy workstations (64GB+)
- Maintains efficiency while preventing thrashing
Related issue: System slowdown with automatic swap configuration
Distribution: BigLinux (affects thousands of users)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR automatizado criado por build_package.py
Conflitos resolvidos automaticamente (se houver)
Pronto para mesclagem automática