Skip to content

Commit

Permalink
Removing deprecated code for the delays introduced for low perf langu…
Browse files Browse the repository at this point in the history
…ages (#5957)

This PR removes the artificial latency logic and associated feature
flags that were previously added for A/B testing to improve the
consistency and predictability of the autocomplete latency.

Context:
The artificial latency was initially introduced as an optimization for
low-performance languages, but recent testing and analysis have shown
that the latency changes are minimal, and the feature is no longer
necessary. Additionally, the smart throttle service is now enabled by
default, rendering the artificial latency code obsolete.

Changes:
- Removed the artificial latency code from
vscode/src/completions/artificial-delay.ts.
- Cleaned up related feature flags from the codebase to simplify the
code and avoid confusion in the future.
- Updated related test cases and documentation to reflect these changes.

## Test plan
Tested locally and it works perfect and the tests pass

<!-- Required. See
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles.
-->

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
  • Loading branch information
arafatkatze authored Oct 22, 2024
1 parent 07a44d3 commit 1bf95a9
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 132 deletions.
1 change: 0 additions & 1 deletion lib/shared/src/experimentation/FeatureFlagProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export enum FeatureFlag {
CodyAutocompleteFIMModelExperimentVariant2 = 'cody-autocomplete-model-v1-experiment-variant-2',
CodyAutocompleteFIMModelExperimentVariant3 = 'cody-autocomplete-model-v1-experiment-variant-3',
CodyAutocompleteFIMModelExperimentVariant4 = 'cody-autocomplete-model-v1-experiment-variant-4',
CodyAutocompleteDisableLowPerfLangDelay = 'cody-autocomplete-disable-low-perf-lang-delay',

CodyAutocompletePreloadingExperimentBaseFeatureFlag = 'cody-autocomplete-preloading-experiment-flag',
CodyAutocompletePreloadingExperimentVariant1 = 'cody-autocomplete-preloading-experiment-variant-1',
Expand Down
3 changes: 0 additions & 3 deletions vscode/src/completions/analytics-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ interface SharedEventPayload extends InteractionIDPayload {
*/
isFuzzyMatch?: boolean

/** Eventual artificial delay that was used to throttle unwanted completions. */
artificialDelay?: number

/**
* Mapping the completion intent to a higher level abstractions of syntax nodes (e.g. function
* declaration body)
Expand Down
45 changes: 0 additions & 45 deletions vscode/src/completions/artificial-delay.test.ts

This file was deleted.

49 changes: 0 additions & 49 deletions vscode/src/completions/artificial-delay.ts

This file was deleted.

7 changes: 0 additions & 7 deletions vscode/src/completions/completion-provider-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class CompletionProviderConfig {
FeatureFlag.CodyAutocompletePreloadingExperimentBaseFeatureFlag,
FeatureFlag.CodyAutocompletePreloadingExperimentVariant1,
FeatureFlag.CodyAutocompletePreloadingExperimentVariant2,
FeatureFlag.CodyAutocompleteDisableLowPerfLangDelay,
FeatureFlag.CodyAutocompleteDataCollectionFlag,
FeatureFlag.CodyAutocompleteTracing,
FeatureFlag.CodyAutocompleteFastPath,
Expand Down Expand Up @@ -183,12 +182,6 @@ class CompletionProviderConfig {
)
}

public get completionDisableLowPerfLangDelay(): Observable<boolean> {
return featureFlagProvider
.evaluatedFeatureFlag(FeatureFlag.CodyAutocompleteDisableLowPerfLangDelay)
.pipe(distinctUntilChanged())
}

public get completionDataCollectionFlag(): Observable<boolean> {
return featureFlagProvider
.evaluatedFeatureFlag(FeatureFlag.CodyAutocompleteDataCollectionFlag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ describe('[getInlineCompletions] completion event', () => {
],
"loggedPartialAcceptedLength": 0,
"params": {
"artificialDelay": undefined,
"completionIntent": "function.body",
"contextSummary": {
"prefixChars": 16,
Expand Down Expand Up @@ -205,7 +204,6 @@ describe('[getInlineCompletions] completion event', () => {
],
"loggedPartialAcceptedLength": 0,
"params": {
"artificialDelay": undefined,
"completionIntent": "return_statement",
"contextSummary": {
"prefixChars": 25,
Expand Down
6 changes: 1 addition & 5 deletions vscode/src/completions/get-inline-completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export interface InlineCompletionsParams {
abortSignal?: AbortSignal
cancellationListener?: vscode.Disposable
tracer?: (data: Partial<ProvideInlineCompletionsItemTraceData>) => void
artificialDelay?: number
firstCompletionTimeout: number
numberOfCompletionsToGenerate?: number

Expand Down Expand Up @@ -238,7 +237,6 @@ async function doGetInlineCompletions(
tracer,
handleDidAcceptCompletionItem,
handleDidPartiallyAcceptCompletionItem,
artificialDelay,
firstCompletionTimeout,
completionIntent,
lastAcceptedCompletionItem,
Expand Down Expand Up @@ -321,7 +319,6 @@ async function doGetInlineCompletions(
languageId: document.languageId,
testFile: isValidTestFile(document.uri),
completionIntent,
artificialDelay,
traceId: getActiveTraceAndSpanId()?.traceId,
stageTimings: stageRecorder.stageTimings,
})
Expand Down Expand Up @@ -422,8 +419,7 @@ async function doGetInlineCompletions(
? 0
: triggerKind !== TriggerKind.Automatic
? 0
: ((multiline ? debounceInterval?.multiLine : debounceInterval?.singleLine) ?? 0) +
(artificialDelay ?? 0)
: (multiline ? debounceInterval?.multiLine : debounceInterval?.singleLine) ?? 0

// We split the desired debounceTime into two chunks. One that is at most 25ms where every
// further execution is halted...
Expand Down
20 changes: 0 additions & 20 deletions vscode/src/completions/inline-completion-item-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { isInTutorial } from '../tutorial/helpers'

import type { CompletionBookkeepingEvent, CompletionItemID, CompletionLogID } from './analytics-logger'
import * as CompletionAnalyticsLogger from './analytics-logger'
import { getArtificialDelay } from './artificial-delay'
import { completionProviderConfig } from './completion-provider-config'
import { ContextMixer } from './context/context-mixer'
import { DefaultContextStrategyFactory } from './context/context-strategy'
Expand Down Expand Up @@ -129,8 +128,6 @@ export class InlineCompletionItemProvider
public get config(): InlineCompletionItemProviderConfig {
return InlineCompletionItemProviderConfigSingleton.configuration
}
private disableLowPerfLangDelay = false

constructor({
completeSuggestWidgetSelection = true,
triggerDelay = 0,
Expand Down Expand Up @@ -194,16 +191,6 @@ export class InlineCompletionItemProvider

void completionProviderConfig.prefetch()

// Subscribe to changes in disableLowPerfLangDelay and update the value accordingly
this.disposables.push(
subscriptionDisposable(
completionProviderConfig.completionDisableLowPerfLangDelay.subscribe(
disableLowPerfLangDelay => {
this.disableLowPerfLangDelay = disableLowPerfLangDelay
}
)
)
)
const strategyFactory = new DefaultContextStrategyFactory(
completionProviderConfig.contextStrategy
)
Expand Down Expand Up @@ -458,12 +445,6 @@ export class InlineCompletionItemProvider
return null
}

const artificialDelay = getArtificialDelay({
languageId: document.languageId,
codyAutocompleteDisableLowPerfLangDelay: this.disableLowPerfLangDelay,
completionIntent,
})

const debounceInterval = this.config.provider.mayUseOnDeviceInference ? 125 : 75
stageRecorder.record('preGetInlineCompletions')

Expand Down Expand Up @@ -495,7 +476,6 @@ export class InlineCompletionItemProvider
handleDidPartiallyAcceptCompletionItem:
this.unstable_handleDidPartiallyAcceptCompletionItem.bind(this),
completeSuggestWidgetSelection: takeSuggestWidgetSelectionIntoAccount,
artificialDelay,
firstCompletionTimeout: this.config.firstCompletionTimeout,
completionIntent,
lastAcceptedCompletionItem: this.lastAcceptedCompletionItem,
Expand Down

0 comments on commit 1bf95a9

Please sign in to comment.