mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 15:03:01 +02:00
- Move 7 loose top-level Markdown reports under docs/cleanup-2026-05/. - Relocate batch3_bloatware_uninstall.sh into phone_focus_mode/ where its ADB/phone wiring belongs. - Delete tracked out.json (empty puzzle_solver fixture). - Remove untracked clutter (mp4/wav/lcov/log/txt) from the working tree.
1.7 KiB
1.7 KiB
Quick Start: Polling Script Optimization
What Was Fixed
Your system was consuming 728,465 CPU-seconds (202 hours) just on the date command in a 5-hour window. This is a classic fork-storm anti-pattern from polling scripts.
Changes Made (3 files updated)
1. network_monitor.sh ✅
- Replaced
date +%sfork with/proc/uptimeread (zero-fork) - Saves: 1 fork per polling cycle (~60-120ms per invocation)
2. i3blocks config ✅
- Battery interval:
1s→5s(80% fewer checks) - Saves: ~240 forks/min = 12 CPU-seconds/min
3. music_parallelism.sh ✅
- Adaptive polling: 0.5s when active, 3s when idle
- Saves: 83% fork reduction when system is idle
New Tools Available
cd /home/kuhy/testsAndMisc
# Diagnose inefficient scripts in your codebase
./run.sh --diagnose
# Profile system for 60 seconds to catch fork-storms
./run.sh --profile 60
# Generate today's usage report
./run.sh
Expected Impact
- Estimated daily savings: 1-2 CPU-hours/day
- Fork reduction: 83% when idle (from 2/sec to 0.33/sec)
- Responsiveness: Improved (fewer context switches)
Verification
# Confirm changes applied:
grep -c "/proc/uptime" linux_configuration/i3-configuration/i3blocks/network_monitor.sh
grep "interval=5" linux_configuration/i3-configuration/i3blocks/config | grep battery
grep "sleep 3" linux_configuration/scripts/digital_wellbeing/music_parallelism.sh
Next Steps
After ~5 hours of normal system usage, run:
./run.sh --top 20
Compare against the original report—you should see the date command no longer in the top CPU consumers.
See POLLING_OPTIMIZATION_REPORT.md for detailed analysis and further optimization recommendations.