Skip to content

perf: reduce idle GUI and daemon CPU - #168

Merged
matej21 merged 6 commits into
refactorx/full-headlessfrom
perf/reduce-idle-cpu
Jul 29, 2026
Merged

perf: reduce idle GUI and daemon CPU#168
matej21 merged 6 commits into
refactorx/full-headlessfrom
perf/reduce-idle-cpu

Conversation

@neumie

@neumie neumie commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Present parsed output following terminal input immediately, then coalesce unrelated sustained terminal-only UI updates into one app-wide 20 ms (~50 FPS) cadence while keeping every open window live.
  • Keep terminal parsing/input, notifications, key-window focus reporting, and OSC clipboard behavior immediate.
  • Tier daemon Git polling by project relevance so visible/subscribed repositories remain responsive without continuously scanning every hidden repository.

Changes

GUI activity rendering

  • Batch exact dirty terminal IDs across the application rather than letting independent streams drive separate presentation clocks.
  • Use a leading edge: the first output after idle is presented immediately.
  • Track a causal output epoch for user input so parsed post-input output bypasses an already-active batch; pre-input backlog cannot consume the priority request, while unrelated terminal IDs remain queued.
  • Expire unanswered input-priority requests and do not arm them for empty input.
  • Fan each frame out to every rendered pane copy and window sidebar, including visible non-key windows on other monitors.
  • Do not infer visibility from key-window activation; focus reporting and notification suppression still follow the actual key window.
  • Preserve immediate terminal parsing/input dispatch, bells/notifications, and OSC 52 clipboard reads and writes.

Daemon Git polling

  • Keep visible and remotely subscribed projects on 250 ms HEAD and 5 s full-status cadences.
  • Move hidden, unsubscribed projects to 2 s HEAD and 30 s full-status fallback cadences.
  • Keep targeted HEAD/action refreshes immediate, anchor periodic polling to wall-clock deadlines, and retain cached status for projects skipped in a cycle.

Measurements

  • 31 real repositories, 60 seconds: daemon mean 22.93% → 5.69%; p95 94.44% → 18.67%.
  • Original controlled single-terminal GUI curve: 12.25% at 60 Hz and 19.20% at 120 Hz.
  • Final release, verified-frontmost synthetic sustained output: GUI mean 17.17% at 60 Hz and 17.71% at 120 Hz. Doubling output frequency increased GUI CPU by only 3.1%, consistent with the ~50 FPS presentation cap.
  • Earlier 33 ms/background-gated GUI figures are intentionally not claimed for the final implementation.

Test plan

  • cargo test --workspace
  • cargo test -p okena-terminal input_repaint
  • cargo test -p okena-ui activity_repaint
  • cargo test -p okena-app -p okena-views-terminal
  • cargo build --release
  • cargo fmt --all -- --check
  • LSP and pi-lens diagnostics across all changed Rust files
  • Controlled before/after CPU sampling with macOS proc_pid_rusage

neumie added 2 commits July 27, 2026 18:44
Batch repaint-only terminal activity at an app-wide presentation cadence and defer inactive-window paints while keeping parsing, notifications, focus reporting, and OSC clipboard handling immediate.
Keep visible and remotely subscribed projects responsive while moving hidden repositories to bounded fallback cadences. Preserve cached statuses across targeted polls and anchor periodic work to wall-clock deadlines.
@neumie
neumie requested a review from matej21 July 27, 2026 17:03
@neumie
neumie marked this pull request as draft July 28, 2026 12:48
@neumie
neumie removed the request for review from matej21 July 28, 2026 12:48
Do not infer visibility from key-window activation, because a visible window on another monitor is normally non-key. Keep every pane and sidebar on the shared capped repaint cadence while focus reporting remains scoped to the actual key window.
@neumie
neumie marked this pull request as ready for review July 28, 2026 13:49
@neumie
neumie requested a review from matej21 July 28, 2026 13:53
neumie and others added 3 commits July 29, 2026 13:47
Use a leading-edge repaint for the first output after idle, then coalesce sustained activity into 20 ms frames. This keeps typed echo responsive while bounding high-frequency terminal presentation across all windows.
Track a causal output epoch for each input so parsed post-input output bypasses an active 20 ms presentation batch. Keep unrelated terminal activity queued, expire unanswered requests, and cover backlog and enqueue races.
Trace input through the daemon, PTY, repaint throttle, and GPUI frame boundaries. Keep the instrumentation behind a Cargo feature and require an explicit runtime opt-in.
@matej21
matej21 merged commit aa9f4e8 into refactorx/full-headless Jul 29, 2026
4 checks passed
@matej21
matej21 deleted the perf/reduce-idle-cpu branch July 29, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants