Skip to content

Cache chat tab-line descriptors - #316

Merged
ericdallo merged 2 commits into
editor-code-assistant:masterfrom
plux:hn/chat-tab-line-cache
Sep 14, 2026
Merged

ericdallo merged 2 commits into
editor-code-assistant:masterfrom
plux:hn/chat-tab-line-cache

Conversation

@plux

@plux plux commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Description

ECA chat tab-line rendering rebuilt stable tab descriptors during redisplay.
That work repeated title formatting, activity checks, and session chat traversal for every redraw.

With many open chats, tab-line updates spent increasing time on data that only changes when chat state changes.
This PR caches stable tab descriptors per session.
It keeps per-redisplay selection state outside the cache.

Changes

  • Cache stable chat tab-line descriptors per session.
  • Keep selected state out of the stable cache so each buffer renders the correct active tab.
  • Store chat activity state in cached descriptors so tab face selection avoids repeated buffer scans.
  • Invalidate the tab-line cache when chat titles, loading state, pending approvals, chat registration, chat removal, chat exit, inline rollback, or session deletion changes.
  • Add a session deletion hook so session-scoped caches clear before the session is removed.
  • Add regression coverage for stale tab titles, selected state, active state, chat registration and removal, chat exit, and session deletion.
  • Add benchmarks/eca-chat-tab-line-bench.el for focused tab-line timing and profiler runs.

Benchmarks

Measured benchmarks/eca-chat-tab-line-bench.el with synthetic chat buffers on Emacs 30.1.
Each chat had 20 turns.
Each result uses the median from 3 runs.

workload chats before after speedup
tabs-warm 10 140.74 us 25.02 us 5.63x
tabs-warm 50 638.53 us 78.44 us 8.14x
tab-face-all 10 96.48 us 24.74 us 3.90x
tab-face-all 50 545.82 us 106.76 us 5.11x

The normal warm tab-list path improved by 8.14x at 50 chats.
The tab face workload improved by 5.11x at 50 chats.

The forced rebuild path is slower after this change because that benchmark invalidates the cache before every call.
That row measures worst-case invalidation cost, not normal redisplay.
The intended path keeps stable tab descriptors cached between redisplays.

Reuse stable tab-line descriptor data between redisplay calls and invalidate it when chat metadata, loading, approval, registry, or session state changes. Add focused tab-line cache tests for the update paths and cleanup paths.
Add a focused benchmark for chat tab-line redisplay costs and clean up
tab-line cache test advice so later tests see unmodified edit commands.
@plux
plux force-pushed the hn/chat-tab-line-cache branch from ae62875 to 65d284e Compare September 12, 2026 18:51

@ericdallo ericdallo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks

@ericdallo
ericdallo merged commit a2cae54 into editor-code-assistant:master Sep 14, 2026
15 checks passed
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.

2 participants