In XtabProvider.provideNextEdit (extensions/copilot/src/extension/xtab/node/xtabProvider.ts), the two context-gathering steps are awaited one after the other:
langCtx = await gatherLanguageContext();
if (cancellationToken.isCancellationRequested) { return new NoNextEditReason.GotCancelled('afterLanguageContextAwait'); }
neighborSnippets = await gatherNeighborSnippets();
if (cancellationToken.isCancellationRequested) { return new NoNextEditReason.GotCancelled('afterNeighborSnippetsAwait'); }
gatherLanguageContext() and gatherNeighborSnippets() are independent, so awaiting them sequentially adds their latencies together on the critical path before the prompt can be built. They should be started together (e.g. Promise.all) so they run concurrently.
Notes for whoever picks this up:
- This pattern appears in both the global-budget branch and the legacy/prod
else branch, so both should be updated.
- Preserve the existing cancellation checks and their distinct
GotCancelled reasons (afterLanguageContextAwait, afterNeighborSnippetsAwait) for telemetry continuity, checking cancellation after the combined await.
- Preserve the
nLinesOfCurrentFileInPrompt telemetry timing in the prod branch (the current-file clip happens before these awaits there).
Surfaced during review of #323948.
In
XtabProvider.provideNextEdit(extensions/copilot/src/extension/xtab/node/xtabProvider.ts), the two context-gathering steps are awaited one after the other:gatherLanguageContext()andgatherNeighborSnippets()are independent, so awaiting them sequentially adds their latencies together on the critical path before the prompt can be built. They should be started together (e.g.Promise.all) so they run concurrently.Notes for whoever picks this up:
elsebranch, so both should be updated.GotCancelledreasons (afterLanguageContextAwait,afterNeighborSnippetsAwait) for telemetry continuity, checking cancellation after the combined await.nLinesOfCurrentFileInPrompttelemetry timing in the prod branch (the current-file clip happens before these awaits there).Surfaced during review of #323948.