diff --git a/lib/shared/src/experimentation/FeatureFlagProvider.ts b/lib/shared/src/experimentation/FeatureFlagProvider.ts index d6e2571f66b5..004dbe92717e 100644 --- a/lib/shared/src/experimentation/FeatureFlagProvider.ts +++ b/lib/shared/src/experimentation/FeatureFlagProvider.ts @@ -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', diff --git a/vscode/src/completions/analytics-logger.ts b/vscode/src/completions/analytics-logger.ts index 6de5c89bfb96..8880e864e509 100644 --- a/vscode/src/completions/analytics-logger.ts +++ b/vscode/src/completions/analytics-logger.ts @@ -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) diff --git a/vscode/src/completions/artificial-delay.test.ts b/vscode/src/completions/artificial-delay.test.ts deleted file mode 100644 index 882eb2fb51d0..000000000000 --- a/vscode/src/completions/artificial-delay.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { getArtificialDelay, lowPerformanceConfig } from './artificial-delay' - -describe('getArtificialDelay', () => { - const testCases = [ - { languageId: 'css', completionIntent: undefined, isLowPerf: true }, - { languageId: 'css', completionIntent: 'comment', isLowPerf: true }, - { languageId: 'go', completionIntent: 'comment', isLowPerf: true }, - { languageId: 'go', completionIntent: undefined, isLowPerf: false }, - ] - - it('correctly identifies low performance configurations', () => { - for (const { languageId, completionIntent, isLowPerf } of testCases) { - const isLowPerfLang = lowPerformanceConfig.languageIds.has(languageId) - const isLowPerfIntent = completionIntent - ? lowPerformanceConfig.completionIntents.has(completionIntent as string) - : false - expect(isLowPerfLang || isLowPerfIntent).toBe(isLowPerf) - } - }) - - it.each(testCases)( - 'returns correct delay based on configuration when codyAutocompleteDisableLowPerfLangDelay is false', - ({ languageId, completionIntent, isLowPerf }) => { - const params = { - languageId, - completionIntent: completionIntent as 'comment' | undefined, - codyAutocompleteDisableLowPerfLangDelay: false, - } - expect(getArtificialDelay(params)).toBe(isLowPerf ? 1000 : 0) - } - ) - - it.each(testCases)( - 'returns no delay when codyAutocompleteDisableLowPerfLangDelay is true', - ({ languageId, completionIntent }) => { - const params = { - languageId, - completionIntent: completionIntent as 'comment' | undefined, - codyAutocompleteDisableLowPerfLangDelay: true, - } - expect(getArtificialDelay(params)).toBe(0) - } - ) -}) diff --git a/vscode/src/completions/artificial-delay.ts b/vscode/src/completions/artificial-delay.ts deleted file mode 100644 index c7d056a26565..000000000000 --- a/vscode/src/completions/artificial-delay.ts +++ /dev/null @@ -1,49 +0,0 @@ -import type { CompletionIntent } from '../tree-sitter/queries' -import { autocompleteOutputChannelLogger } from './output-channel-logger' - -export const lowPerformanceConfig = { - languageIds: new Set([ - 'css', - 'html', - 'scss', - 'vue', - 'dart', - 'json', - 'yaml', - 'postcss', - 'markdown', - 'plaintext', - 'xml', - 'twig', - 'jsonc', - 'handlebars', - ]), - completionIntents: new Set(['comment', 'import.source']), -} - -/** - * Calculates the artificial delay to apply to code completions based on the language ID and completion intent. - * The function adds a baseline latency for low-performance languages or low-performance completion intents, - * unless the user has enabled the flag that stops this behavior. - */ -export function getArtificialDelay({ - languageId, - codyAutocompleteDisableLowPerfLangDelay, - completionIntent, -}: { - languageId: string - codyAutocompleteDisableLowPerfLangDelay: boolean - completionIntent?: CompletionIntent -}): number { - const isLowPerformance = - lowPerformanceConfig.languageIds.has(languageId) || - (completionIntent ? lowPerformanceConfig.completionIntents.has(completionIntent) : false) - - const latency = !codyAutocompleteDisableLowPerfLangDelay && isLowPerformance ? 1000 : 0 - - if (latency > 0) { - autocompleteOutputChannelLogger.logDebug('getLatency', `Delay added: ${latency}`) - } - - return latency -} diff --git a/vscode/src/completions/completion-provider-config.ts b/vscode/src/completions/completion-provider-config.ts index 8484a824f096..17250af2f768 100644 --- a/vscode/src/completions/completion-provider-config.ts +++ b/vscode/src/completions/completion-provider-config.ts @@ -34,7 +34,6 @@ class CompletionProviderConfig { FeatureFlag.CodyAutocompletePreloadingExperimentBaseFeatureFlag, FeatureFlag.CodyAutocompletePreloadingExperimentVariant1, FeatureFlag.CodyAutocompletePreloadingExperimentVariant2, - FeatureFlag.CodyAutocompleteDisableLowPerfLangDelay, FeatureFlag.CodyAutocompleteDataCollectionFlag, FeatureFlag.CodyAutocompleteTracing, FeatureFlag.CodyAutocompleteFastPath, @@ -183,12 +182,6 @@ class CompletionProviderConfig { ) } - public get completionDisableLowPerfLangDelay(): Observable { - return featureFlagProvider - .evaluatedFeatureFlag(FeatureFlag.CodyAutocompleteDisableLowPerfLangDelay) - .pipe(distinctUntilChanged()) - } - public get completionDataCollectionFlag(): Observable { return featureFlagProvider .evaluatedFeatureFlag(FeatureFlag.CodyAutocompleteDataCollectionFlag) diff --git a/vscode/src/completions/get-inline-completions-tests/analytics.test.ts b/vscode/src/completions/get-inline-completions-tests/analytics.test.ts index b1bf2f807948..1b8849a0bb62 100644 --- a/vscode/src/completions/get-inline-completions-tests/analytics.test.ts +++ b/vscode/src/completions/get-inline-completions-tests/analytics.test.ts @@ -133,7 +133,6 @@ describe('[getInlineCompletions] completion event', () => { ], "loggedPartialAcceptedLength": 0, "params": { - "artificialDelay": undefined, "completionIntent": "function.body", "contextSummary": { "prefixChars": 16, @@ -205,7 +204,6 @@ describe('[getInlineCompletions] completion event', () => { ], "loggedPartialAcceptedLength": 0, "params": { - "artificialDelay": undefined, "completionIntent": "return_statement", "contextSummary": { "prefixChars": 25, diff --git a/vscode/src/completions/get-inline-completions.ts b/vscode/src/completions/get-inline-completions.ts index 0b933c3c00f2..3e78632df0d2 100644 --- a/vscode/src/completions/get-inline-completions.ts +++ b/vscode/src/completions/get-inline-completions.ts @@ -62,7 +62,6 @@ export interface InlineCompletionsParams { abortSignal?: AbortSignal cancellationListener?: vscode.Disposable tracer?: (data: Partial) => void - artificialDelay?: number firstCompletionTimeout: number numberOfCompletionsToGenerate?: number @@ -238,7 +237,6 @@ async function doGetInlineCompletions( tracer, handleDidAcceptCompletionItem, handleDidPartiallyAcceptCompletionItem, - artificialDelay, firstCompletionTimeout, completionIntent, lastAcceptedCompletionItem, @@ -321,7 +319,6 @@ async function doGetInlineCompletions( languageId: document.languageId, testFile: isValidTestFile(document.uri), completionIntent, - artificialDelay, traceId: getActiveTraceAndSpanId()?.traceId, stageTimings: stageRecorder.stageTimings, }) @@ -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... diff --git a/vscode/src/completions/inline-completion-item-provider.ts b/vscode/src/completions/inline-completion-item-provider.ts index 254e2bea1ae6..357f546ecae7 100644 --- a/vscode/src/completions/inline-completion-item-provider.ts +++ b/vscode/src/completions/inline-completion-item-provider.ts @@ -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' @@ -129,8 +128,6 @@ export class InlineCompletionItemProvider public get config(): InlineCompletionItemProviderConfig { return InlineCompletionItemProviderConfigSingleton.configuration } - private disableLowPerfLangDelay = false - constructor({ completeSuggestWidgetSelection = true, triggerDelay = 0, @@ -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 ) @@ -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') @@ -495,7 +476,6 @@ export class InlineCompletionItemProvider handleDidPartiallyAcceptCompletionItem: this.unstable_handleDidPartiallyAcceptCompletionItem.bind(this), completeSuggestWidgetSelection: takeSuggestWidgetSelectionIntoAccount, - artificialDelay, firstCompletionTimeout: this.config.firstCompletionTimeout, completionIntent, lastAcceptedCompletionItem: this.lastAcceptedCompletionItem,