perf(dashboard): keep session-DB, cron, PID-probe and log-tail I/O off the event loop (salvage #58238/#45491/#53511/#58389/#39140/#53966) - #60884
Closed
kshitijk4poor wants to merge 0 commit into
Conversation
tonydwb
reviewed
Jul 8, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment (token read-only - high surface area)
PR 60884 moves session-DB, cron, PID-probe and log-tail I/O off the event loop in the dashboard. Substantial performance refactor (7 files, 537 additions, 60 deletions). References multiple prior issues (#58238, #45491, #53511, #58389, #39140, #53966).
Well-scoped performance fix. LGTM - awaiting maintainer approval.
kshitijk4poor
force-pushed
the
salvage/web-server-event-loop
branch
from
July 8, 2026 19:54
3aaac17 to
c95cf31
Compare
kshitijk4poor
added a commit
to kshitijk4poor/hermes-agent
that referenced
this pull request
Jul 8, 2026
Rebase reconciliation with NousResearch#60884: _count_status_active_sessions (from NousResearch#58238) now passes compact_rows=True (this branch's NousResearch#47437 projection), so the fake asserts both.
This was referenced Jul 8, 2026
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
Rebase reconciliation with NousResearch#60884: _count_status_active_sessions (from NousResearch#58238) now passes compact_rows=True (this branch's NousResearch#47437 projection), so the fake asserts both.
justemu
pushed a commit
to justemu/hermes-agent
that referenced
this pull request
Jul 18, 2026
Rebase reconciliation with NousResearch#60884: _count_status_active_sessions (from NousResearch#58238) now passes compact_rows=True (this branch's NousResearch#47437 projection), so the fake asserts both.
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
Rebase reconciliation with NousResearch#60884: _count_status_active_sessions (from NousResearch#58238) now passes compact_rows=True (this branch's NousResearch#47437 projection), so the fake asserts both.
This was referenced Aug 3, 2026
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
Rebase reconciliation with NousResearch#60884: _count_status_active_sessions (from NousResearch#58238) now passes compact_rows=True (this branch's NousResearch#47437 projection), so the fake asserts both.
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
Rebase reconciliation with NousResearch#60884: _count_status_active_sessions (from NousResearch#58238) now passes compact_rows=True (this branch's NousResearch#47437 projection), so the fake asserts both.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Six event-loop / hot-path fixes for the dashboard backend, salvaged from five contributor PRs onto current main with authorship preserved via cherry-pick — the uvicorn event loop stops paying for session-DB reads, cron profile scans, gateway PID lock probes, and unbounded log-tail reads.
/api/statusactive-session count runs in an executor with a 0.75s deadline and a read-only SQLite attach, so a locked/migrating state.db can no longer stall the status endpoint.run_in_threadpool(_call_cron_for_profileretargets module globals under a lock while doing file I/O — previously on the loop).get_running_pid()opens+locksgateway.lockon every call; dashboard polling churned FDs up toEMFILE. Adds a 1s TTL cache invalidated by pid/lock/runtime-status file signatures and by every in-process write site./api/actions/{name}/statuslog tails read the whole file; now a bounded reverse-chunk read (256KB cap) with partial-first-line handling._session_latest_descendantfetched EVERY session row and built the tree in Python; now a recursive CTE loading only the target's descendant branch. (The PR's schema-init cache and Rust PTY bridge are intentionally NOT salvaged.)GET /api/sessionsflipped to syncdefso FastAPI's threadpool runs the SessionDB read off the loop. (Its other two hunks already landed via [Bug]: Remote desktop over Tailscale: async routes block the asyncio loop 10-25s (list_profiles, /api/profiles/sessions) starving the WS; plus Chromium LNA + Electron net stalls #54523 / are superseded by fix(dashboard): keep status responsive when session db locks #58238.)Follow-up commits (mine):
UNION ALLrecurses forever on a corrupted parent chain (a→b→a) — reproduced live, query never returns. The old Python walk was cycle-safe via a seen-set. Switched toUNION(dedups the working set, terminates); regression test added and mutation-verified (UNION ALL hangs the test).SessionDB(read_only=True)'s documented contract requires the DB file to exist; on a fresh install every/api/statuspoll paid anOperationalError. Short-circuit to 0 when state.db is absent, with tests.Notes for reviewers:
get_running_pid_cachedis safe for gateway-start detection: cache hits require both TTL freshness AND an unchanged file signature (pid/lock/runtime-status mtime_ns+size), so a gateway writing its pid file invalidates immediately. One legacy directgateway.pidunlink ingateway/run.py --replacebypasses the in-process cache clear but is caught by the signature check._run_cron_dashboard_iousesrun_in_threadpoolwhile two sibling helpers userun_in_executor— consolidation to one offload idiom is a reasonable follow-up sweep, not done here to keep contributor commits intact.Validation