Skip to content

perf(app): poll active sessions adaptively (3s active, 30s idle)#64

Open
JeanBaptisteRenard wants to merge 1 commit into
doctly:mainfrom
JeanBaptisteRenard:contrib/adaptive-active-session-poll
Open

perf(app): poll active sessions adaptively (3s active, 30s idle)#64
JeanBaptisteRenard wants to merge 1 commit into
doctly:mainfrom
JeanBaptisteRenard:contrib/adaptive-active-session-poll

Conversation

@JeanBaptisteRenard

Copy link
Copy Markdown

Problem

The renderer polls active PTY sessions every 3s unconditionally via setInterval(pollActiveSessions, 3000). Each tick performs an IPC round-trip (getActiveSessions) plus a full-sidebar querySelectorAll sweep in updateRunningIndicators() — even when zero sessions are running. On an idle app this is steady, pointless CPU churn.

Fix

Poll adaptively:

  • pollActiveSessions() now re-arms itself via scheduleActiveSessionsPoll(), which schedules the next tick at 3s while any PTY is running (activePtyIds.size > 0) and 30s when idle.
  • Every renderer code path that starts a session already calls pollActiveSessions() explicitly, so an in-renderer session start re-arms the fast cadence immediately.
  • The 30s idle floor still catches sessions started outside the renderer (e.g. scheduler-spawned PTYs) within at most 30s.
  • The sidebar timeago setInterval now no-ops when lastActivityTime is empty.

Notes

Behavior-preserving: identical polling work and indicator updates while sessions run; the only change is cadence when idle. Syntax-checked (node --check); the test suite passes.

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