Back to Codexbar

CodexBar Issue #139 Performance/Energy Simulation Report

docs/perf-energy-issue-139-simulation-report-2026-02-19.md

0.243.6 KB
Original Source

CodexBar Issue #139 Performance/Energy Simulation Report

Date: 2026-02-19 Workspace: /Users/michalkrsik/windsurf_project_folder/CodexBar Issue: https://github.com/steipete/codexbar/issues/139

Purpose

Determine which suspected culprit(s) can produce the abnormal CPU/energy behavior reported by users, using short reproducible simulations and process-level sampling.

Host/Tooling

  • macOS: Darwin 25.2.0 (arm64)
  • Swift: 6.2.3
  • Sampling tools: ps, top
  • Note: powermetrics was unavailable (requires sudo password in this session), so energy was sampled via top POWER proxy.

Simulated Culprits

  • Culprit A: CLI/PTTY-style heavy subprocess churn with polling loop behavior.
  • Culprit B: Web dashboard scrape/retry loop with repeated parse work and 400-600ms waits.
  • Culprit C: 75ms idle polling loop (blink-style wakeups).
  • Combined: A + B + C at once.
  • Baseline: near-idle control.

Test Pass 1 (Primary Mechanism Pass)

Artifacts:

  • /tmp/codexbar_perf_sim/results_20260219_111607

Summary:

ScenarioAvg CPUMax CPUAvg RSS MBAvg POWERAvg IDLEW
Baseline0.000.100.540.000.00
Culprit A113.68117.40121.760.000.00
Culprit B4.6413.3064.150.005.04
Culprit C0.252.3033.120.0010.43
Combined114.62121.30217.620.000.00

Interpretation:

  • CPU ranking was clear (A dominates strongly).
  • POWER field in this pass was unusable (stuck at 0.00 for several scenarios due top sampling mode).

Test Pass 2 (Calibrated Energy Pass)

Artifacts:

  • /tmp/codexbar_perf_sim/energy2_results_20260219_112350

Sampling correction:

  • Switched to top -l 2 and parsed the second sample for tracked PIDs to get non-zero POWER values.

Summary:

ScenarioAvg CPUMax CPUAvg RSS MBAvg POWERMax POWERAvg IDLEW
Baseline0.000.000.550.000.000.00
Culprit A113.32115.90114.7394.85150.606106.70
Culprit B4.3010.1062.092.944.202.18
Culprit C0.352.6034.090.230.6014.27
Combined115.67118.90218.4893.29129.603858.60

Validation Against Expected Pattern

Computed checks on pass 2: 10/10 passed.

  • A dominates CPU vs B (>=10x): PASS
  • A dominates CPU vs C (>=50x): PASS
  • A dominates POWER vs B (>=10x): PASS
  • A dominates POWER vs C (>=100x): PASS
  • Combined close to A CPU (+/-15%): PASS
  • Combined close to A POWER (+/-25%): PASS
  • C is low CPU (<1%): PASS
  • B is moderate CPU (<15%): PASS
  • Baseline near zero CPU (<1%): PASS
  • Baseline near zero POWER (<1): PASS

Final Finding

Primary root-cause class for the extreme behavior is Culprit A (heavy long-lived CLI/subprocess churn under bad/failure paths).

Secondary:

  • Culprit B contributes moderate load.
  • Culprit C contributes wakeups/noise but is not a major CPU/energy driver.

Human-level answer: A tiny toolbar app should never keep heavyweight background subprocess/UI loops alive in failure conditions. That behavior is what creates the abnormal battery/CPU footprint.

Limitations

  • These were controlled simulations, not a full end-user UI replay of CodexBar.app with all real auth/cookie/account paths.
  • powermetrics could not be used in this session due sudo restriction.
  • Run one short real-app before/after validation after fixes:
    • baseline
    • culprit A-focused repro
    • optional combined
  • Capture powermetrics if sudo is available, plus process CPU snapshots.
  • Publish before/after table in issue #139.