Skip to content

Commit

Permalink
config(amazonq): adjust timeout for supplemental context #5978
Browse files Browse the repository at this point in the history
## Problem
The overall supplemental context has a timeout of 50ms, each sub promise
has a timeout of 50ms. Problem is these 2 timeout are very tight,
leaving no buffer time for node js runtime to do context switch. The
poll interval of each sub promise is 10ms, which does not precisely
timeout at 50ms.

## Solution
Add a 10ms buffer time for supplemental context.
Reduce poll duration
  • Loading branch information
leigaol authored Nov 12, 2024
1 parent c09b09a commit 886ab29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/core/src/codewhisperer/util/editorContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ export async function buildGenerateRecommendationRequest(editor: vscode.TextEdit
const fileContext = extractContextForCodeWhisperer(editor)

const tokenSource = new vscode.CancellationTokenSource()
// the supplement context fetch mechanisms each has a timeout of supplementalContextTimeoutInMs
// adding 10 ms for overall timeout as buffer
setTimeout(() => {
tokenSource.cancel()
}, supplementalContextTimeoutInMs)
}, supplementalContextTimeoutInMs + 10)
const supplementalContexts = await fetchSupplementalContext(editor, tokenSource.token)

logSupplementalContext(supplementalContexts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ export async function fetchSupplementalContextForSrc(
async function () {
return await fetchSupplementalContextForSrcV1(editor, cancellationToken)
},
{ timeout: supplementalContextTimeoutInMs, interval: 10, truthy: false }
{ timeout: supplementalContextTimeoutInMs, interval: 5, truthy: false }
)
const promiseV2 = waitUntil(
async function () {
return await fetchSupplementalContextForSrcV2(editor)
},
{ timeout: supplementalContextTimeoutInMs, interval: 10, truthy: false }
{ timeout: supplementalContextTimeoutInMs, interval: 5, truthy: false }
)
const [resultV1, resultV2] = await Promise.all([promiseV1, promiseV2])
return resultV2 ?? resultV1
Expand Down

0 comments on commit 886ab29

Please sign in to comment.