refactor(loader): parallelize I/O in registerPath; add registerPaths#39
Merged
refactor(loader): parallelize I/O in registerPath; add registerPaths#39
Conversation
… add concurrent tests Agent-Logs-Url: https://github.com/Shougo/dpp.vim/sessions/7ed39eb1-3de6-465d-bd04-410eb88bf707 Co-authored-by: Shougo <41495+Shougo@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Parallelize Loader module loading for reduced latency
refactor(loader): parallelize I/O in registerPath; add registerPaths
Apr 2, 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.
registerPathheld the register lock across the fullDeno.stat+importPlugincall, serializing all extension loads. With many extensions this compounds into significant startup latency.Changes
denops/dpp/loader.tsregisterPath: I/O (Deno.stat+importPlugin) moved outside the lock so concurrent calls overlap. Lock is acquired only for the state-update critical section. Re-checks#checkPathsinside the lock to prevent duplicate registration when concurrent callers race past the fast-path.Modwrapper type:importedModis now a localanyvariable, initialized only after successful I/O.#register: Kept; now delegates toregisterPath.registerPaths(type, paths): New public method — fans out toregisterPathviaPromise.allSettled; logs failures per-path without throwing.denops/dpp/tests/loader_concurrent_test.tsNew tests covering: single registration, concurrent same-path (idempotency, 8 parallel calls), concurrent different-paths, invalid-path error propagation,
registerPathswith mixed valid/invalid paths, and overlapping concurrentregisterPathscalls.Original prompt
Goal
Parallelize Loader module loading to reduce startup/registration latency when many extensions are present. Implemented changes should keep shared-state updates (this.#exts, this.#checkPaths) protected by the existing register lock to avoid races and double registration.
What to change (detailed)
Commit strategy
Testing steps
Notes and rationale
Please create the branch, commit the changes, run tests, and open a PR against main with an explanatory description. After creating the PR, provide the PR URL and summary of CI/test results. If any test failures occur, include the failing logs.
The following is the prior conversation context from the user's chat exploration (may be truncated):
Assistant: 直接のおすすめ:まずは安全かつ影響範囲の小さい最適化から着手します。優先順は
return awaitの削除(低リスク・一括適用可能)これらを実装してテストを実行し、問題なければ次に大きめのリファクタ(プロトコルキャッシュや I/O 最適化)に進みます。続けて PR を作成してよければ「PR作成して」と一言ください。すぐに作業します。
何を確認・実行済みか
安全で効果の高い具体的な最適化案(短期)
変更案 1 — 不要な return await の削除(低リスク)
return await foo()が使われています。多くの場合return foo()の方が余計な microtask を減らせてパフォーマンスとスタックトレースの扱いを改善できます(try/catch でスタックをホールドしたい場合はawaitを残す必要あり)。return foo()に置換する。CI でテストを実行。変更案 2 — import-map 読み込みと ImportMapImporter のキャッシュ化(低〜中リスク)
中期〜大きめのリファクタ案(要検証)
具体的に私が変更するファイル(短期優先)
This pull request was created from Copilot chat.