Skip to content
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

Use a throttler instead of a debouncer for code completion #8

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

brichet
Copy link
Collaborator

@brichet brichet commented Oct 23, 2024

Replace the debouncer by a throttler to invoke the code completion.

The debouncer waits for the delay before executing the function, whereas the throttler executes it instantaneously, but will prevent an other execution for the next {delay} seconds.

When comparing the time between invocation of the function and the return from the server, we gain 1s with the throttler.

@jtpio jtpio added the enhancement New feature or request label Oct 23, 2024
@jtpio
Copy link
Member

jtpio commented Oct 23, 2024

Thanks for looking into this!

Trying it locally, it looks like we sometimes get the suggestions for a previous completion request:

jupyterlite-codestral-inline.webm

But this also seems to be happening on the current main with the debouncer:

jupyterlite-codestral-inline-2.webm

Maybe we should also try to cancel a request if a new one is being made?

@brichet
Copy link
Collaborator Author

brichet commented Oct 23, 2024

For what I understand, the request is not made again if the input has changed within the 1s (after the request has been made) with the throttler.
Maybe we should write our own Throttler that mixes both of the Lumino Debouncer and Throttler:

  • execute the function right after the invoke
  • if an other invoke come during the delay, store it to execute the function as soon as the delay is over, and add a flag (waitingInvoke for example)

From the completion provider, if a response comes but the flag is true, do not show the response.

@jtpio
Copy link
Member

jtpio commented Oct 23, 2024

Right it might be worth to explore.

From a user point of view, high delays make the feature less useful if one has to stop typing to get suggestions.

But we can likely switch to the throttler already as an incremental improvement and investigate further in other PRs.

Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jtpio jtpio merged commit 6b2cae1 into jupyterlite:main Oct 23, 2024
7 of 8 checks passed
@brichet brichet deleted the throttler_completion branch October 23, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants