Skip to content

perf(tui): stop polling nori-skillsets; cache version#444

Merged
theahura merged 2 commits intomainfrom
auto/verify-system-report-s-nori-cli-culprit-20260416-034440
Apr 16, 2026
Merged

perf(tui): stop polling nori-skillsets; cache version#444
theahura merged 2 commits intomainfrom
auto/verify-system-report-s-nori-cli-culprit-20260416-034440

Conversation

@theahura
Copy link
Copy Markdown
Contributor

Summary

  • spawn_system_info_worker in codex-rs/tui/src/app/mod.rs was firing a full SystemInfo refresh every 5 seconds via recv_timeout fall-through, which in turn spawned nori-skillsets --version and nori-skillsets list-active as Node.js subprocesses. With several concurrent nori sessions this produced sustained CPU load just to paint the footer (see discovery notes below). Switch to blocking recv() so refreshes only happen on explicit request_system_info_refresh() calls.
  • Cache nori-skillsets --version in a process-wide OnceLock (NORI_VERSION_CACHE) in codex-rs/tui/src/system_info.rs. The installed CLI version is stable for the lifetime of the TUI process, so the subprocess runs at most once per session. list-active is still re-invoked on every refresh.
  • Document the new event-driven refresh model and version caching in codex-rs/tui/docs.md.

Refreshes are still triggered on: startup, user message submit, task completion, effective cwd changes (debounced 500ms by EffectiveCwdTracker), and skillset install/switch success.

Tradeoff

An external nori-skillsets switch run in another terminal while the TUI is idle will not be reflected in the footer until the user does something that triggers a refresh. Discussed and accepted.

Impact

  • Per-session baseline load: ~0.4 nori-skillsets spawns/sec → 0 when idle.
  • Per-refresh cost: 2 subprocesses → 1.

Test plan

  • cargo test -p nori-tui — 1199 passed, 0 failed
  • just fmt + just fix -p nori-tui — clean
  • cargo build --bin nori — success
  • cargo test -p tui-pty-e2e — all suites pass
  • End-to-end: launched nori --agent elizacp under tmux; TUI rendered, prompt appeared, footer populated with active skillset and cached version string; user submit triggered a refresh that updated the footer. No panics.

theahura and others added 2 commits April 16, 2026 00:36
The system info background worker was firing `nori-skillsets --version`
and `nori-skillsets list-active` every 5 seconds per session via a
`recv_timeout` loop that fell through to refresh on timeouts, producing
a sustained ~0.4 subprocess spawns/sec per idle `nori` session. With
multiple concurrent sessions this added up to hundreds of percent of
CPU for footer display alone.

Switch the worker to blocking `recv()` so refreshes only happen on
explicit `request_system_info_refresh()` calls (startup, user submit,
task complete, effective cwd change, skillset install/switch). Cache
`nori-skillsets --version` in a process-wide `OnceLock` since the
installed CLI version is stable for the lifetime of a TUI process;
this halves the per-refresh cost by skipping the version subprocess.

Tradeoff: an external `nori-skillsets switch` run in another terminal
while the TUI is idle will not update the footer until the next event.
🤖 Generated with [Nori](https://noriagentic.com)

Co-Authored-By: Nori <contact@tilework.tech>
@theahura theahura merged commit 65fe683 into main Apr 16, 2026
3 checks passed
@theahura theahura deleted the auto/verify-system-report-s-nori-cli-culprit-20260416-034440 branch April 16, 2026 04:50
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