Skip to content

Enable concurrent execution for parallel-safe matchers#170

Merged
Shougo merged 2 commits intomainfrom
copilot/add-parallel-safe-matcher-execution
Mar 19, 2026
Merged

Enable concurrent execution for parallel-safe matchers#170
Shougo merged 2 commits intomainfrom
copilot/add-parallel-safe-matcher-execution

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

Ports ddu.vim PR#158 to ddc.vim: matchers that declare themselves parallel-safe can now run concurrently on item chunks, with automatic fallback to sequential execution.

New option

matcherConcurrency: number (default: 1) — max concurrent chunks when running matchers. Default preserves existing sequential behaviour completely.

Filter opt-in: parallelSafe

FilterOptions gains parallelSafe: boolean (default: false). Filters opt in per user config:

call ddc#custom#patch_global('filterOptions', #{ my_matcher: #{ parallelSafe: v:true } })
call ddc#custom#patch_global('matcherConcurrency', 4)

Parallel execution logic (runMatchersConcurrently)

Parallel execution activates only when all hold:

  1. matcherConcurrency > 1
  2. Every active matcher has parallelSafe: true
  3. Each chunk returns the same item count as received (runtime safety check)

Items are split into ⌈N/concurrency⌉-sized chunks; callFilters runs on each via Promise.all, results concatenated in order. Falls back transparently to sequential on: any opt-out filter, item count mismatch, or any exception.

Files changed

  • types.tsmatcherConcurrency: number added to DdcOptions; FilterOptions.placeholder replaced with parallelSafe: boolean
  • context.tsmatcherConcurrency: 1 default; two new unit tests
  • base/filter.tsdefaultFilterOptions() returns { parallelSafe: false }
  • ext.tscallFilters refactored to take explicit items parameter; runMatchersConcurrently added; matcher call site updated
  • doc/ddc.txtmatcherConcurrency option and parallelSafe filter option documented
Original prompt

ddu.vim の pull request #158 (Shougo/ddu.vim#158) で導入された「parallel-safe な matcher を並列実行できるようにする」変更を、同等の形で ddc.vim レポジトリに適用してください。

目的

  • ddc.vim の matcher 実行部分を改善し、parallel-safe (並列実行可能) と宣言された matcher を並列に実行できるようにする。

要件

  1. ddu.vim の PR vim-lsp candidates have a dot character at the beginning in C++ #158 の実装と振る舞いを参照し、同等の機能を ddc.vim に移植してください。具体的には:

    • matcher を実行するコア処理を変更して、matcher が並列実行可能であると宣言している場合のみ並列に実行する(宣言がない場合は従来どおり直列実行)。
    • matcher のインターフェース / 型定義(API)に並列実行可否を示すフラグやプロパティを追加または対応させる。既存 matcher はデフォルトで後方互換を保つこと。
    • 並列化は安全に行う(共有状態の競合を避ける)、エラーハンドリングとタイムアウト動作を確認する。
  2. 変更の範囲

    • core の dispatcher/runner に相当する箇所(matcher を呼び出して候補を集める処理)。
    • matcher のプロバイダ定義部分(matcher が並列実行可能と宣言する方法)。
    • 既存の matcher 実装に対する最小限の変更(可能な限り既存 matcher はそのまま動くこと)。
    • ドキュメント(README やマニュアル)に並列実行の説明と matcher 作者向けの注意点を追加。
    • 必要ならユニット/統合テストを追加して、並列実行時の正当性と後方互換を検証する。
  3. 互換性と品質

    • 既存のユーザー設定や matcher が壊れないこと(デフォルトは直列)。
    • Neovim / Vim での動作互換性に注意する(非同期 API が異なる場合は既存の ddc.vim の設計に合わせる)。
    • パフォーマンス回帰がないこと。並列化は matcher が安全と宣言した場合にのみ有効。
  4. テストと検証

    • 自動テストを可能な範囲で追加・更新する(既存テストがあればそれらが通ること)。
    • 手動での動作確認手順を PR の説明に記載する(簡単な手順で動作確認できること)。
  5. PR 内容

    • 変更点の要約(英日両方で簡潔に)。
    • どのファイルをどう変更したかの一覧。
    • 互換性に関する注記と既存 matcher 作者向けの移行ガイド。
    • 既存テストの結果や新規テストの説明。

参照

注意事項

  • レポジトリは Shougo/ddc.vim(このレポジトリ)に対して PR を作成してください。
  • 実装の詳細は ddu.vim の変更を踏襲してくださいが、ddc.vim のアーキテクチャ差分があれば適切に調整してください。
  • 変更が大きくなる場合は複数コミットに分け、コミット単位で読みやすくしてください。

期待するアウトプット

  • Shougo/ddc.vim に対する Pull Request(ブランチを作成して PR を開く)。PR には上記の説明、変更セット、テストの情報を含めてください。

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: @Shougo/ddu.vim/pull/158 ddu.vim の matcher 並列化を ddc.vim にも適用してください @Shougo/ddc.vim

Assistant: 許可ダイアログへのご回答(承認または拒否)をお待ちしています — ご選択いただければ続行します。

This pull request was created from Copilot chat.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Co-authored-by: Shougo <41495+Shougo@users.noreply.github.com>
Copilot AI changed the title [WIP] Add parallel-safe matcher execution for ddc.vim Enable concurrent execution for parallel-safe matchers Mar 18, 2026
Copilot AI requested a review from Shougo March 18, 2026 11:35
@Shougo Shougo marked this pull request as ready for review March 19, 2026 10:07
@Shougo Shougo merged commit 4a4404d into main Mar 19, 2026
3 checks passed
@Shougo Shougo deleted the copilot/add-parallel-safe-matcher-execution branch March 19, 2026 10:15
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