Skip to content

perf: Cache Lua edit callback presence - #1626

Open
enzi221 wants to merge 1 commit into
kwaroran:mainfrom
enzi221:perf/selective-lua-running
Open

enzi221 wants to merge 1 commit into
kwaroran:mainfrom
enzi221:perf/selective-lua-running

Conversation

@enzi221

@enzi221 enzi221 commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

  • Required Checks
    • Have you added type definitions?
    • Have you tested your changes?
    • Have you checked that it won't break any existing features?

Summary

Caches Lua triggers, evaluate the trigger only when it has a matching callback.

Related Issues

None.

Changes

This enhances initial chat rendering time by roughly 15%. The exact percentage will vary by numbers of chat messages and Lua triggers.

In a Lua-heavy environment with 30 messages, it takes ~1.7s. See #1625.

With this PR, it takes ~1.45s, which is a 15% enhancement. When combined with #1625, the final result is ~1.05s, or 39% faster.

Implementation details:

Lua evaluation is itself a very heavy operation. Current implementation runs per message, evaluates all triggers , and then determines whether each trigger has the callback.

This PR caches the first evaluation result. For subsequent messages, the evaluation skips when no there is no callback.

Impact

None.

@enzi221
enzi221 force-pushed the perf/selective-lua-running branch from df5da8a to 832d5ed Compare October 8, 2026 13:08
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