-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Feature Request: Auto CPU Scaling
Overview
Add a 4th CPU speed option "Auto" that dynamically scales between existing power levels based on CPU load.
Implementation Strategy
Use existing CPU speed levels (no platform-specific frequency tables needed):
CPU_SPEED_POWERSAVE- Base level when idleCPU_SPEED_NORMAL- Standard gaming performanceCPU_SPEED_PERFORMANCE- Emergency boost when needed
Simple 3-tier auto-scaling algorithm:
if (cpu_usage > 90%) {
PWR_setCPUSpeed(CPU_SPEED_PERFORMANCE); // Max boost
}
else if (cpu_usage > 70%) {
PWR_setCPUSpeed(CPU_SPEED_NORMAL); // Standard
}
else {
PWR_setCPUSpeed(CPU_SPEED_POWERSAVE); // Low power
}Platform Opt-In Architecture
Platforms can opt into auto-scaling by implementing:
// In platform.h
#define PLAT_SUPPORTS_AUTO_CPU 1
// In platform.c
void* PLAT_cpu_monitor(void *arg) {
// Platform-specific monitoring implementation
}Platforms without PLAT_SUPPORTS_AUTO_CPU will simply not show the "Auto" option in the menu.
Benefits
- Cross-platform compatible - Uses existing
CPU_SPEED_*constants - Opt-in - Platforms without support work unchanged
- Simple - 3-tier scaling vs NextUI's 33-step approach
- Battery friendly - Stays at low power when possible, boosts only when needed
- Cool running - Reduces heat during lighter gameplay
Implementation Tasks
- Add
volatile int useAutoCpuglobal flag - Create reference
PLAT_cpu_monitor()implementation for tg5040/miyoomini - Add CPU usage measurement helpers (
CLOCK_PROCESS_CPUTIME_ID) - Add "Auto" option to minarch CPU Speed menu (when platform supports it)
- Add
#ifdef PLAT_SUPPORTS_AUTO_CPUguards - Test on platforms with auto-scaling support
- Document platform opt-in requirements
Reference Implementation
NextUI's auto-scaling:
workspace/tg5040/platform/platform.c:2234-2345- Background pthread monitoring every 20ms
- Uses POSIX
clock_gettime(CLOCK_PROCESS_CPUTIME_ID)for accurate CPU time - Mutex-protected shared state
Questions to Answer
- What threshold percentages work best across platforms? (70%/90% proposed)
- Should we expose thresholds as config options?
- What monitoring interval is optimal? (20ms? 50ms? 100ms?)
Related to NextUI investigation in #[TBD]
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request