Skip to content

perf(desktop): stop 30s wake_after echo chamber and idle poll churn - #1692

Merged
Hona merged 1 commit into
devfrom
fix/idle-timer-echo-chamber
Nov 29, 2026
Merged

Hona merged 1 commit into
devfrom
fix/idle-timer-echo-chamber

Conversation

@Hona

@Hona Hona commented Nov 29, 2026

Copy link
Copy Markdown
Member

Summary

  • Eliminates a self-sustaining 45–60 Hz idle wake and allocation storm seen in Windows perf.log telemetry on Massive memory usage. #1649 (~1.3–5.1 MB/s of continuous UI-thread allocation traffic, 6.6–7.5 GB over 1–1.5 h while minimized/idle) caused by polling systems unconditionally re-pushing tx.wake_after / tx.wake_at deadlines on every poll().
  • apps/desktop/src/surfaces/automations/{mod,source}.rs:
    • Replaces unconditional per-poll tx.wake_after(30s) with an explicit PollWake state machine (Idle | Armed { due }) that arms at most one wake for the earliest server that will actually become due next (and arms nothing when all servers are Unsupported or have no automations).
    • Avoids marking changed = true on unchanged BgResult::List / Command responses (eliminating spurious 30 s redraws while visible) and uses inbox_wake so quiet results skip frame presents.
    • Guards entries/filtered_entries, tab_dirs, and get_mut(&AUTOMATIONS) so idle polls avoid unnecessary allocations and Tracked invalidations.
  • apps/desktop/src/shell/memory_reclaim.rs:
    • Switches MemorySweep::Scheduled to Rune's monotonic clock (due: f64) so the 30 s wake is scheduled once on transition/reschedule instead of re-pushing a sub-ms-drifted wake_after on every poll, and avoids bumping Tracked &SWEEP when state is unchanged.
  • apps/desktop/src/session/inbox/model.rs:
    • Adds TickWake (Cell<TickWake>) so the 1 s / 60 s age-tick wake is armed once per boundary instead of on every poll.
  • apps/desktop/src/workspace/servers/health.rs & apps/desktop/src/kernel.rs:
    • Adds per-window HealthWake (HEALTH_WAKE slot) so the 10 s health deadline is armed once per due timestamp instead of on every poll.
  • apps/desktop/src/surfaces/browser/rpc/{hold,mod}.rs:
    • Adds RpcWake so RPC deadlines arm once per due Instant, reads worker_rx untracked, and skips the std::mem::take/get_mut round-trip when no sessions or holds are active.

Verification

  • Verified locally on Windows: pwsh scripts/guardrails.ps1 (10/10 passed), cargo check -p opencode-desktop --lib --bins, and cargo clippy -p opencode-desktop --lib --bins --no-deps (zero warnings on touched code).
  • Not run live in a desktop GUI window or on macOS/Linux; cross-platform builds run in CI.

Related to #1649 (leaving #1649 open for live verification of overall Task Manager memory usage once this ships).

@Hona
Hona merged commit 1a17c84 into dev Nov 29, 2026
7 checks passed
@Hona
Hona deleted the fix/idle-timer-echo-chamber branch November 29, 2026 14:41
@Hona Hona mentioned this pull request Nov 29, 2026
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.

1 participant