Skip to content

Mesclar dev-talesam em master#1

Merged
talesam merged 7 commits into
masterfrom
dev-talesam
Feb 7, 2026
Merged

Mesclar dev-talesam em master#1
talesam merged 7 commits into
masterfrom
dev-talesam

Conversation

@talesam

@talesam talesam commented Feb 7, 2026

Copy link
Copy Markdown

PR automatizado criado por build_package.py

Conflitos resolvidos automaticamente (se houver)
Pronto para mesclagem automática

… 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)
@talesam talesam merged commit c4a9c0c into master Feb 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant