PerformanceElectron Ultra-Low-Footprint Plan
Performance5 min readZero-Hang
Electron Ultra-Low-Footprint Plan
Based on your exact requirements, this optimization plan enforces four strict runtime guarantees:
Mission Control // Ultra-Low-Footprint & Anti-Hang Performance Plan
Guaranteed Zero-Hang Execution, Ultra-Low RAM (<150MB), Minimal Disk Footprint, and Instant Interactions
1. Core Directives & Guarantees
Based on your exact requirements, this optimization plan enforces four strict runtime guarantees:
- Zero-Hang Guarantee: The UI thread must never block or freeze under any condition. All disk I/O, game library scans, network queries, and hardware telemetry must execute non-blockingly in background processes with strict failover timeouts.
- Ultra-Low Memory (RAM):
- Frontend/Renderer: Under 150 MB idle RAM (down from ~350 MB).
- Backend: Under 70 MB idle RAM.
- Decoded image caches and off-screen game posters are automatically evicted when scrolled out of view.
- Minimal Storage Footprint:
- Log files are auto-rotated with a strict 5 MB cap (no runaway
app.logfiles). - Image & telemetry caches are pruned with an LRU (Least Recently Used) ceiling of 50 MB.
- Log files are auto-rotated with a strict 5 MB cap (no runaway
- Buttery-Smooth UI (60–120 FPS):
- Offload rendering from CPU to dedicated GPU hardware compositing.
- Eliminate re-render thrashing on every telemetry tick.
SYSTEM ARCHITECTURE DIAGRAMMERMAID SVG ENGINEGenerating visual flowchart...
2. Anti-Hang Architecture (Preventing Freezes & Spinner Locks)
A. Non-Blocking Main & Renderer Threads
- The Problem: Running synchronous operations (
fs.readFileSync, heavy regex, or synchronous JSON serialization on large arrays) pauses the JavaScript event loop. The app appears frozen/hung. - The Solution:
- Move all JSON cache persistence to asynchronous microtasks with
requestIdleCallback/setTimeout(..., 0). - Implement an Electron Watchdog Heartbeat: If the main window ever stops responding for >3 seconds, an IPC health check immediately flags the degraded state and releases any locked resources rather than freezing the window.
- Strict 1.5s Network & Process Timeouts: Every background query (game metadata, remote node health, Steam discovery) has an
AbortControllertimeout so no modal or button gets stuck on a spinning wheel.
- Move all JSON cache persistence to asynchronous microtasks with
B. Graceful Loading & Smooth Skeleton UI
- When navigating between pages or loading game lists, never block the UI with a full-screen frozen spinner. Use lightweight GPU-composited skeleton cards that render immediately.
3. Ultra-Low RAM Footprint (<150 MB Target)
A. Chromium Memory Ceilings & Aggressive GC
In electron/main.ts:
TS// Enforce tight memory boundary and tell V8 to optimize for low memory over raw throughput app.commandLine.appendSwitch('js-flags', '--max-old-space-size=256 --optimize-for-size --expose-gc'); app.commandLine.appendSwitch('force-fieldtrials', '*BackgroundTabLowMemoryTier/Enabled/');
- In
electron/main.ts, invokeglobal.gc()during page transitions or window minimize to immediately purge dead heap objects.
B. Image Cache & DOM Node Eviction
- High-resolution game covers consume ~5–10 MB of GPU texture memory each if kept in memory.
- In
GamesPage.tsx, applyloading="lazy"anddecoding="async"to all cover images. - Unload game cards that are scrolled far out of view to keep DOM node count below 200 elements.
4. Minimal Disk Footprint (Storage Protection)
A. Bounded Rotating Log System
In electron/main.ts:
- Currently,
logToFileappends indefinitely toapp.log. - Optimization: Wrap with a bounded rotation policy:
- Check file size before writing; if
app.logexceeds 5 MB, rotate toapp.log.oldand truncate. - Never allow total log storage to exceed 10 MB.
- Check file size before writing; if
B. Clean Bundle Size
- Bundle code-splitting reduces the installed JavaScript footprint in
dist/assetsfrom monolithic multi-megabyte files into small, on-demand modules.
5. Execution Steps
SYSTEM ARCHITECTURE DIAGRAMMERMAID SVG ENGINEGenerating visual flowchart...
Action Items:
- Step 1 (Main Process Flags & Watchdog):
- In
electron/main.ts, removedisable-gpu-compositing, add GPU hardware acceleration switches, enforce V8 memory limits (--max-old-space-size=256), and add log rotation.
- In
- Step 2 (Frontend Route Splitting & Bundle Pruning):
- In
App.tsx, dynamically lazy-loadGamesPage,VisionPage,SystemPage,SettingsPage, etc. - Defer modals so they load only when clicked.
- In
- Step 3 (Telemetry Delta Sync & Anti-Thrash):
- In
GamesPage.tsxand telemetry hooks, debounce state updates and prevent duplicate re-renders.
- In
- Step 4 (Validation & Benchmarking):
- Measure cold start time, verify working set RAM in Windows Task Manager, and confirm 0 dropped frames.