Conversation
… batch denops RPCs Agent-Logs-Url: https://github.com/Shougo/ddc.vim/sessions/e6374dc2-3019-42a7-92b9-dfaac21bbfe0 Co-authored-by: Shougo <41495+Shougo@users.noreply.github.com>
… cast Agent-Logs-Url: https://github.com/Shougo/ddc.vim/sessions/e6374dc2-3019-42a7-92b9-dfaac21bbfe0 Co-authored-by: Shougo <41495+Shougo@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Optimize CPU spike during fast input by caching results
perf: cache keywordPattern/RegExp, parallelize filter resolution, batch denops RPCs
Apr 27, 2026
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.
Fast typing causes repeated redundant work on every keypress:
iskeyword-derived string processing, freshRegExpcompilation, sequential filter loading, and two separate RPC round-trips indoCompletion.Changes
denops/ddc/utils.ts— keyword pattern and RegExp cachingconvertKeywordPatternnow caches results keyed bykeywordPattern + NUL + iskeyword, skippingvimoption2tsstring processing on repeated calls (the common case)getKeywordRegExp(expandedPattern)caches compiledRegExpobjects, avoiding re-compilation on everygetCompletePositioncalldenops/ddc/base/source.ts— use RegExp cache ingetCompletePositiondenops/ddc/ext.ts— parallel filter resolution incallFiltersSequential
for awaitovergetFiltercalls replaced withPromise.all, so sorters/converters are resolved concurrently rather than one at a time.denops/ddc/ddc.ts— batch RPC round-trips indoCompletionTwo sequential denops calls (
ddc#util#get_input+fn.mode) merged into a singlecollectbatch, eliminating one RPC round-trip per completion cycle.Original prompt
目的
高速入力時の CPU スパイクをさらに抑えるため、以下の3点を一つの PR として実装・提出します。
変更項目(まとめ)
convertKeywordPattern の結果キャッシュ化(denops/ddc/utils.ts)
filterItems 内での getFilter の重複解決を回避(denops/ddc/ext.ts)
doCompletion 内の denops RPC のバッチ化(denops/ddc/ddc.ts)
対象ファイル(変更予定)
denops/ddc/utils.ts
denops/ddc/base/source.ts
denops/ddc/ext.ts
denops/ddc/ddc.ts
実装の注意点
テスト/検証
PR タイトル(提案)
"perf: cache keywordPattern and RegExp, pre-resolve filters and batch denops RPCs"
備考
以上の内容で PR を作成してよいですか?問題なければこのままブランチを作り実装・PR を作成します。
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Shougo/ddc.vim のパフォーマンスを改善したいです。特にユーザーが素早く入力したときに CPU 使用率が上がってしまう問題があります
Assistant: 続行するには先ほどのツール呼び出しの許可ダイアログで応答していただく必要があるため、ご返答をお待ちしています。
User: @copilot Accepted Confirmation: Are you sure?
Assistant: 結論(まずやるべきこと)
やることの流れ(短く)
今すぐ試せる緩和策(優先度高)
簡単な計測(ユーザー側で素早くできること)
推測されるホットスポット(優先的にチェックすべき箇所)
計測で見るべき指標
改善案(優先度付き、設計観点)
短期(設定で済む/小変更)
中期(コード修正:比較的小さなリファクタ)
5. ソースの同期 API を非同期化(可能なら job/async)に移行。
6. リクエストの coalescing(前のリクエストをキャンセルし、新しい入力に対して一度だけ計算する...
This pull request was created from Copilot chat.