Refactor polling to event-driven architecture for CPU usage fix#111
Refactor polling to event-driven architecture for CPU usage fix#111onliner10 wants to merge 3 commits into
Conversation
Replaces the 250ms polling timer with event-driven status tracking using libghostty callbacks. Tab names refresh lazily on visibility changes, and a single deferred work item handles quiet settle (3s after last activity). - Removes processNameTimer polling loop entirely - Status updates flow through onCommandFinished/onProgressStarted/onProgressFinished - Tab names refresh on tabDidBecomeVisible/focusDidChange + app activation - scheduleQuietSettle() uses DispatchWorkItem with 3s defer, not repeating - App activation observers pause/resume activity tracking Fixes thdxg#110
…lling # Conflicts: # Macterm/Ghostty/GhosttyCallbacks.swift # Macterm/Model/SplitNode.swift # MactermTests/Model/TerminalExecutionTrackerTests.swift
|
Updated this PR to be the combined fix for #110. It now includes:
I also measured the larger warmed-tab case discussed in #110:
So this appears to fix the high-CPU scaling behavior while keeping the activity indicator reliable. What do you think about landing this as the combined #110 fix? |
|
Thanks @onliner10 for the thorough benchmarking and for engaging with @jcuhnoio's measurements. To answer your landing-path question: not quite this shape. Here's the plan and why.
Happy to re-review either shape. Thanks again for the benchmark rigor — it moved this issue forward materially. |
Replaces the 250ms polling timer with event-driven status tracking using libghostty callbacks.
Problem: Macterm used 10-20% CPU continuously when idle/minimized due to unconditional 250ms process polling timer.
Solution: Event-driven architecture:
Results:
Fixes #110