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

Autocomplete: Add feature flags to disable network cache and request recycling #1409

Merged
merged 6 commits into from
Oct 18, 2023

Conversation

philipp-spiess
Copy link
Contributor

@philipp-spiess philipp-spiess commented Oct 17, 2023

This adds two feature flags to control the request manager behavior:

  • cody-autocomplete-disable-network-cache: When set, it won't cache completion requests anymore. My theory here is that this optimization is no longer necessary and when the first line of cache (the last candidate logic) does not hit, we actually want a new completion to be generated. This also makes it so that manual completions (which bypass the lastCandidate check) will now cycle through different completions instead of resolving with the same one. Note that this can still return the same completion from the backend in which case our ID deduplication logic will still work.

  • cody-autocomplete-disable-recycling-of-previous-requests: When set, it will not try to complete inflight requests base on the result of previous network requests. Instead, it will abort requests when they are no longer relevent. This was initially added as a mechanism to save latency but there are a few flaws here:

    1. The context for the previous request might be incorrect: E.g. a single-line request is used to respond to a multi-line reuqest.
    2. This prevents requests from being aborted which increases costs
    3. This adds quiete a bit of complexity
    4. The actual impact of this change was never measured as an A/B test

    My theory is that this is still relevant to improve UX and should probably receive fixes for i), however, I want to test if this hypothesis is true and it does indeed meaningfully improve the UX (CAR, Latency)

Test plan

Using the keyboard shortcut to trigger a completion will return one from cache:
Screenshot 2023-10-17 at 11 37 34

With cody-autocomplete-disable-network-cache on, it will do a request:
Screenshot 2023-10-17 at 11 38 09

Writing function bubbleSort( slowly will create a recycled result:

Screenshot 2023-10-17 at 12 01 34

With cody-autocomplete-disable-recycling-of-previous-requests on, the request will take longer and will not be recycled

Screenshot 2023-10-17 at 12 02 28

@philipp-spiess philipp-spiess requested a review from a team October 17, 2023 09:58
@@ -202,7 +203,7 @@ async function doGetInlineCompletions(params: InlineCompletionsParams): Promise<
return null
}

// Do not trigger when cusor is at the start of the file ending line, and the line above is empty
// Do not trigger when cursor is at the start of the file ending line and the line above is empty
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks 🙇‍♀️

Copy link
Contributor

@abeatrix abeatrix left a comment

Choose a reason for hiding this comment

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

LGTM

@philipp-spiess philipp-spiess merged commit 48aedba into main Oct 18, 2023
14 checks passed
@philipp-spiess philipp-spiess deleted the ps/ac-ff-network branch October 18, 2023 09:04
Copy link
Member

@valerybugakov valerybugakov left a comment

Choose a reason for hiding this comment

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

This also makes it so that manual completions (which bypass the lastCandidate check) will now cycle through different completions instead of resolving with the same one.

Even if we decide the second cache layer is helpful, let's implement the above behavior 🙏
I want this badly!

@philipp-spiess
Copy link
Contributor Author

@valerybugakov Yeah, I agree!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants