Skip to content

perf(chat): cache context bar rendering - #262

Merged
ericdallo merged 1 commit into
editor-code-assistant:masterfrom
itkonen:perf/cache-context-bar
Jun 29, 2026
Merged

ericdallo merged 1 commit into
editor-code-assistant:masterfrom
itkonen:perf/cache-context-bar

Conversation

@itkonen

@itkonen itkonen commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

I noticed the CPU load increased after the introduction of the context bar - enough to make it the bottleneck on older computers - so I did some benchmarking and found the problem. I'm not quite sure if this fix is ideal, but at least it brought down the CPU load.

AI Summary

  • Cache the context usage mode-line bar so streaming redisplay does not rebuild the same propertized bar and tooltip on every mode-line evaluation.
  • Use a normalized cache key based on the actual rendering inputs, including context totals/categories, graphical state, frame char width, and fallback colors.
  • Add a focused streaming benchmark entry point for comparing default, no-context, no-mode-line, mode-line, context-bar, and usage-event paths.

Verification

  • emacs -Q --batch -L . ... --batch -f batch-byte-compile eca-chat.el benchmarks/eca-chat-bench.el
    • passes; only pre-existing optional Evil warnings remain.
  • emacs -Q --batch -L . -L test ... -l buttercup -l test/eca-chat-test.el -f buttercup-run
    • 79 specs, 0 failed.
  • emacs -Q --batch -L . ... -l benchmarks/eca-chat-bench.el -f eca-chat-bench-run-streaming
    • confirms cached context-bar mode-line rendering remains close to the no-context path.
  • git diff --check
    • clean.

🤖 Generated with ECA (openai/gpt-5.5 - high)

Avoid rebuilding the context usage mode-line bar on every mode-line
evaluation during assistant streaming. The cache key tracks the actual
rendering inputs so usage updates and graphical fallback color changes
still invalidate naturally.

Add focused streaming benchmarks to compare default, no-context, and
no-mode-line rendering paths.

🤖 Generated with [ECA](https://eca.dev) (openai/gpt-5.5 - high)

Co-Authored-By: eca-agent <git@eca.dev>
@itkonen
itkonen marked this pull request as ready for review June 24, 2026 18:01

@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.

Thank you

@ericdallo
ericdallo merged commit 399c860 into editor-code-assistant:master Jun 29, 2026
11 of 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