-
Notifications
You must be signed in to change notification settings - Fork 748
fix(amazonq): debounce inline suggestion requests. #7289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
| * the interval of the background thread invocation, which is triggered by the timer | ||
| * Delay for making requests once the user stops typing. Without a delay, inline suggestions request is triggered every keystroke. | ||
| */ | ||
| export const defaultCheckPeriodMillis = 1000 * 60 * 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't see these used anymore, so I deleted for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these were probably missed when I was deleting code. One of the problems with exporting in typescript is that it makes it very hard to detect which exports are actually used
| * the interval of the background thread invocation, which is triggered by the timer | ||
| * Delay for making requests once the user stops typing. Without a delay, inline suggestions request is triggered every keystroke. | ||
| */ | ||
| export const defaultCheckPeriodMillis = 1000 * 60 * 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these were probably missed when I was deleting code. One of the problems with exporting in typescript is that it makes it very hard to detect which exports are actually used
|
Could we use something like https://www.npmjs.com/package/ts-unused-exports? I just ran it and got 951 results, so this might be noisy. Perhaps something to investigate in the future if more bandwidth is available. |
Problem
When typing a decent amount of text in quick succession, the language server will get throttled in its requests to the backend. This is because we send a request for recommendations on every key stroke, causing the language server to make a request on each key stroke. This is rightfully getting throttled by the backend.
Solution
debounce. However, we need to extend debounce slightly outlined below.debounceto the recommendations such that we wait 20 ms after typing stops before fetching the results.Debounce Changes
-Let f be some debounced function that takes a string argument, our current debounce does the following:
The issue is is that for suggestions, this means the language server request will be made with stale context (i.e. not including our most recent content). What we want instead is for the case above to call f with
'abc'and not with'a'or'ab'.We can accomplish this by adding a flag to
debounceallowing us to choose whether we call it with the first args of the debounce interval (default, and 'a' in the example above), or the most recent args ('abc' in the example above).Verification
feature/xbranches will not be squash-merged at release time.