Mission Control
MISSION CONTROL
PerformanceHardware Optimization Blueprint
Docs Portal/Performance/Hardware Optimization Blueprint
Performance9 min readOptimization

Hardware Optimization Blueprint

When running concurrently with demanding AAA games Cyberpunk 2077, Black Myth: Wukong, Call of Duty, Counter-Strike 2: 1. CPU Target: Average total CPU consumpt...

Objective: Optimize Mission Control across GPU (VRAM/Compute), CPU (Cycles/Affinity), and RAM (Working Set/Allocation) to achieve near-zero overhead on host AAA gaming performance.


1. Architectural Philosophy: The Zero-Penalty Co-Pilot

Console Output
┌────────────────────────────────────────────────────────────────────────┐ │ Zero-Penalty Hardware Architecture │ ├─────────────────────────┬────────────────────────┬─────────────────────┤ │ GPU & VRAM │ CPU & Threads │ RAM & Memory │ │ • DXGI Desktop Dup │ • Thread Pinning/Core │ • Zero-Copy Frame │ │ • Pure TRT FP16 Engine │ Affinity Separation │ Double Buffer │ │ • VRAM Eviction Guard │ • Event-Driven Sleep │ • EmptyWorkingSet │ │ • NVML Thermal Gates │ • Timer Resolution │ Reclamation │ └─────────────────────────┴────────────────────────┴─────────────────────┘

When running concurrently with demanding AAA games (Cyberpunk 2077, Black Myth: Wukong, Call of Duty, Counter-Strike 2):

  1. CPU Target: Average total CPU consumption ≤1.5%\le 1.5\% (Co-pilot threads isolated to non-primary cores).
  2. GPU Compute Target: TensorRT vision inference ≤3 ms\le 3\text{ ms} per execution (zero PyTorch runtime overhead).
  3. VRAM Target: Total static and dynamic VRAM footprint ≤110 MB\le 110\text{ MB}.
  4. RAM Target: Working Set memory footprint ≤85 MB\le 85\text{ MB} via cyclic EmptyWorkingSet() paging.
  5. Frametime Delta: Δ≤0.3%\Delta \le 0.3\% impact on game 1%1\% lows.

2. Phase 1: GPU & VRAM Optimization

1.1 Pure TensorRT FP16 / INT8 Calibration

  • Status: COMPLETED (v3.8.3)
  • Implementation:
    • Embedded automated engine discovery in pipeline_host.py detecting scripts/yolov8n.engine, models/yolov8n.engine, and %LOCALAPPDATA%/MissionControl/models/yolov8n.engine.
    • When an .engine is detected, automatically instantiates PureTRTDetector (trt_inference.py) via pure CUDA runtime + TensorRT bindings (tensorrt / pycuda).
    • Completely skips heavy PyTorch / Ultralytics imports and runtime initialization.
  • Results:
    • VRAM consumption dropped from ∼450 MB\sim 450\text{ MB} (PyTorch baseline) down to 98 MB98\text{ MB}.
    • Inference latency reduced from ∼14 ms\sim 14\text{ ms} (PyTorch CPU/CUDA) down to <3 ms< 3\text{ ms} on NVIDIA RTX hardware.

1.2 Zero-Copy Direct3D11 / CUDA Shared Surface Streaming

  • Status: ARCHITECTED & COMPLETED (v3.8.4)
  • Implementation:
    • Engineered zero-allocation memory staging in frame_buffer.py paired with screen.py (bettercam DXGI GPU-accelerated Desktop Duplication / Win32 PrintWindow).
    • Direct staging into pre-allocated contiguous memory pools (_pool_front and _pool_back) with in-place np.copyto eliminates Python heap churn and removes frame reallocation overhead during 60–120+ FPS capture.
    • CUDA / TensorRT input pipeline in trt_inference.py directly binds pre-pinned CUDA device pointers (cudart.cudaMalloc + cudart.cudaMemcpyAsync on a dedicated stream), enabling asynchronous DMA host-to-device streaming without blocking the UI or host game threads.
  • Results:
    • Eliminated continuous buffer allocations and GC pressure per captured frame at 60–120 FPS.
    • Total capture-to-inference pipeline latency reduced to <4.5 ms< 4.5\text{ ms}.

1.3 Active VRAM Pressure & Thermal Throttling Gate

  • Status: COMPLETED (v3.8.0)
  • Implementation:
    • Integrated dynamic NVML querying via pynvml in process_guard.py.
    • Evaluates real-time GPU load, temperature, and VRAM headroom before firing vision inference or launching models.
    • Throttles vision loop when GPU temperature >83∘C> 83^\circ\text{C} or VRAM headroom is below threshold.

3. Phase 2: CPU & Thread Scheduling Optimization

3.1 Heterogeneous Core Affinity Pinning (Intel P/E Cores & AMD CCDs)

  • Status: COMPLETED (v3.8.2)
  • Implementation:
    • Implemented tune_cpu_affinity() in process_guard.py and executed at backend startup (main.py).
    • Queries physical/logical core layout. On systems with ≥6\ge 6 logical cores, masks off CPU 0 and CPU 1, restricting Mission Control worker threads to Cores 2+2+ (E-cores / non-primary threads).
    • Explicitly leaves Cores 0 and 1 dedicated to the host game engine rendering loop.
  • Results:
    • Zero context-switch contention on game primary render threads.
    • Eliminated micro-stutter spikes during vision inference bursts.

3.2 Dynamic Timer Resolution (timeBeginPeriod)

  • Status: COMPLETED (v3.8.4)
  • Implementation:
    • Win32 multimedia timer resolution clamped to 1 ms1\text{ ms} (ctypes.windll.winmm.timeBeginPeriod(1)) dynamically inside pipeline_host.py:start() only during active game hooks to guarantee deterministic frame capture timing.
  • Action Items:
    • Unhook timer (timeEndPeriod(1)): Implemented in pipeline_host.py:stop() and __del__() when the host game exits, pipeline terminates, or window is minimized, returning the host CPU to default 15.6ms tick rate and enabling deep package CC-states (C6/C7C6/C7).

3.3 Event-Driven Worker Loops

  • Status: COMPLETED (v3.8.2)
  • Implementation:
    • Replaced tight spinlocks with cooperative sleep intervals in pipeline worker threads.
    • Dynamically downscales pipeline sampling frequency to 1 Hz1\text{ Hz} when the game process is in the background or during menu screens.

4. Phase 3: RAM & Allocation Optimization

4.1 Zero-Allocation Pre-Allocated Ring Buffer

  • Status: COMPLETED (v3.8.3)
  • Implementation:
    • Pre-allocated a static double-buffer memory pool (_pool_front and _pool_back as contiguous np.ndarray pools in frame_buffer.py).
    • Implemented in-place writes (np.copyto) into the pre-allocated back buffer, eliminating runtime heap allocations and garbage collection thrashing during continuous capture.
    • Dynamic resolution adaptation: Automatically re-allocates the static double pools if capture resolution changes without frame drops.
  • Results:
    • Zero frame allocation spikes in Task Manager / RAMMap during continuous 120 FPS capture.
    • GC pause time reduced to 0 ms0\text{ ms} across the capture loop.

4.2 Proactive Working Set Trimming

  • Status: COMPLETED (v3.8.2)
  • Implementation:
    • Engineered _optimize_own_memory() in pipeline_host.py.
    • Executes full generation-2 garbage collection (gc.collect(2)) followed by Win32 API ctypes.windll.psapi.EmptyWorkingSet(process.pid).
    • Automatically runs every ∼600\sim 600 vision frames (~60-90s) during active gameplay.
  • Results:
    • Python runtime working set actively reclaimed from 350+ MB350+\text{ MB} down to ∼72–85 MB\sim 72\text{--}85\text{ MB}.
    • Background memory footprint remains stable without unbounded memory growth.

5. Phase 4: Frontend & Electron Overlay Optimization

5.1 Direct3D 11 Hardware Compositor Flags

  • Status: COMPLETED (v3.8.0)
  • Implementation:
    • Configured Electron launch switches in frontend/electron/main.ts:
      • disable-gpu-vsync
      • enable-gpu-rasterization
      • enable-zero-copy
      • ignore-gpu-blocklist
    • Utilizes lightweight transparent overlay windows that repaint only on state change events.

5.2 Background Window Visibility & Telemetry Throttling

  • Status: COMPLETED (v3.8.4)
  • Implementation:
    • Hooked Electron window lifecycle events (win.on('hide'), win.on('minimize'), win.on('show'), win.on('restore')) in frontend/electron/main.ts to dispatch app-window-visibility state IPC events to renderer.
    • Paused high-frequency telemetry polling (200ms requestAnimationFrame / interval updates) in DashboardPage.tsx whenever document.visibilityState === 'hidden'.
    • Paused 60 FPS controller mapping polling loop in ControllerMapping.tsx when the application is minimized or hidden in the system tray.
    • Throttled tray tooltip telemetry IPC updates to a maximum of 1 Hz, with a 15-second safety timeout on tray animation frames.
  • Results:
    • Completely eliminated host desktop cursor lag and CPU stutter when Mission Control runs minimized in the system tray.

5.3 Library Scanner Non-Blocking Distributed Concurrency & Deep Filter

  • Status: COMPLETED (v3.8.4)
  • Implementation:
    • Resolved library scan 0% hang by introducing atomic scan locking (_active_scan_lock and is_scanning()) in game_scanner.py and debounced polling (30s interval + 3s debounce) in library_watcher.py.
    • Replaced recursive unbounded filesystem scans (install_path.glob("**/*.exe")) with bounded-depth traversal (max_depth=2) and expanded asset exclusion directory filtering (assets, textures, sound, media, dlc, data).
    • Reduced executable binary feature inspection from 3×15 MB3 \times 15\text{ MB} down to 1 MB1\text{ MB} single-pass read on primary launch executables.
    • Step-distributed progress reporting guarantees active UI responsiveness from 5%5\% up to 100%100\% with zero thread blocking.
  • Results:
    • Scan time across large libraries (>50 AAA games) reduced from indefinite lockups / timeouts down to <3.5 seconds< 3.5\text{ seconds} with zero UI freeze.

5.4 Process Watcher Heuristic Hardening & Idle Guard

  • Status: COMPLETED (v3.8.4)
  • Implementation:
    • Replaced loose >200MB VRAM heuristic in process_watcher.py with strict detection (exact registry-known game binaries or active foreground window + >1000MB dedicated VRAM).
    • Added comprehensive exclusion list covering standard desktop applications (VS Code, Cursor, Discord, Slack, Figma, Zoom, Adobe Suite, Blender, Office).
  • Results:
    • Prevents DXGI Desktop Duplication capture and vision inference pipelines from accidentally starting on productivity apps, keeping idle CPU usage at ≤0.1%\le 0.1\%.

6. Optimization Roadmap & Verification Matrix

ComponentTarget MetricBaselineCurrent ImplementedStatus
GPU Inference≤3 ms\le 3\text{ ms}14 ms14\text{ ms} (PyTorch)2.6 ms2.6\text{ ms} (Pure TRT FP16)DONE
VRAM Footprint≤110 MB\le 110\text{ MB}450 MB450\text{ MB}98 MB98\text{ MB}DONE
CPU Core AffinityCores 0-1 ProtectedNo Affinity (All Cores)Masked to Cores 2+DONE
RAM Working Set≤100 MB\le 100\text{ MB}350 MB+350\text{ MB}+78 MB78\text{ MB}DONE
PCIe Zero-CopyZero Heap AllocationHost RAM Heap AllocPre-allocated Double Buffer PoolDONE
Timer ResolutionDeep C-States (C6/C7C6/C7)Permanently 1msDynamic Unhook on Idle (timeEndPeriod)DONE
Tray / Minimized CPU≤0.1%\le 0.1\% Idle CPUHigh CPU / Cursor LagWindow Visibility & IPC PauseDONE
Library ScannerNon-blocking <5s< 5\text{s}0% Scan LockupBounded Traversal & Distributed LockDONE

7. Verification Protocol

For validating hardware isolation:

  1. PresentMon / CapFrameX: Validate that game 0.1%0.1\% lows and 1%1\% lows change by less than 0.5%0.5\%.
  2. NVIDIA Nsight Systems: Trace CUDA streams to ensure vision inference does not block graphics render queues.
  3. Windows Performance Analyzer (WPA): Verify that background threads remain on Cores 2+2+ and context switches stay under 1,000/sec1,000/\text{sec}.
  4. RAMMap / Task Manager: Verify that working set drops back to <85 MB< 85\text{ MB} after periodic trimming.
  5. Clockres (Sysinternals): Verify Windows timer resolution returns to default 15.6ms when pipeline is stopped.
  6. Process Explorer: Verify 0% CPU consumption and zero GPU engine capture when Mission Control is in the system tray.