Skip to content

Commit 80889e5

Browse files
authored
nes: make cache delay configurable (#266)
1 parent d842be4 commit 80889e5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/extension/inlineEdits/node/nextEditProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ import { CachedOrRebasedEdit, NextEditCache } from './nextEditCache';
4141
import { LlmNESTelemetryBuilder } from './nextEditProviderTelemetry';
4242
import { INextEditResult, NextEditResult } from './nextEditResult';
4343

44-
const ARTIFICIAL_CACHE_HIT_DELAY = 300; // delay cache hits by 300ms to make it more like a regular request and to reduce flicker ;)
45-
4644
export interface INextEditProvider<T extends INextEditResult, TTelemetry, TData = void> extends IDisposable {
4745
readonly ID: string;
4846
getNextEdit(docId: DocumentId, context: vscode.InlineCompletionContext, logContext: InlineEditRequestLogContext, cancellationToken: CancellationToken, telemetryBuilder: TTelemetry, data?: TData): Promise<T>;
@@ -160,6 +158,8 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne
160158
let req: NextEditFetchRequest;
161159
let targetDocumentId = docId;
162160

161+
const cacheDelay = this._configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsCacheDelay, this._expService);
162+
163163
if (recentlyShownCachedEdit) {
164164
tracer.trace('using recently shown cached edit');
165165
edit = recentlyShownCachedEdit[0];
@@ -173,7 +173,7 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne
173173
// back-date the recording bookmark of the cached edit to the bookmark of the original request.
174174
logContext.recordingBookmark = req.log.recordingBookmark;
175175

176-
await timeout(ARTIFICIAL_CACHE_HIT_DELAY);
176+
await timeout(cacheDelay);
177177

178178
} else if (cachedEdit) {
179179
tracer.trace('using cached edit');
@@ -187,7 +187,7 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne
187187
// back-date the recording bookmark of the cached edit to the bookmark of the original request.
188188
logContext.recordingBookmark = req.log.recordingBookmark;
189189

190-
await timeout(ARTIFICIAL_CACHE_HIT_DELAY);
190+
await timeout(cacheDelay);
191191

192192
} else {
193193
tracer.trace('fetching next edit');

src/platform/configuration/common/configurationService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ export namespace ConfigKey {
645645
export const InlineEditsYieldToCopilot = defineExpSetting<boolean>('chat.advanced.inlineEdits.yieldToCopilot', false, INTERNAL_RESTRICTED);
646646
export const InlineEditsLogContextRecorderEnabled = defineSetting('chat.advanced.inlineEdits.logContextRecorder.enabled', false, INTERNAL_RESTRICTED);
647647
export const InlineEditsDebounce = defineExpSetting<number>('chat.advanced.inlineEdits.debounce', 200, INTERNAL_RESTRICTED);
648+
export const InlineEditsCacheDelay = defineExpSetting<number>('chat.advanced.inlineEdits.cacheDelay', 300, INTERNAL_RESTRICTED);
648649
export const InlineEditsBackoffDebounceEnabled = defineExpSetting<boolean>('chat.advanced.inlineEdits.backoffDebounceEnabled', true, INTERNAL_RESTRICTED);
649650
export const InlineEditsExtraDebounceEndOfLine = defineExpSetting<number>('chat.advanced.inlineEdits.extraDebounceEndOfLine', 0, INTERNAL_RESTRICTED);
650651
export const InlineEditsDebounceOnSelectionChange = defineExpSetting<number | undefined>('chat.advanced.inlineEdits.debounceOnSelectionChange', undefined, INTERNAL_RESTRICTED);

0 commit comments

Comments
 (0)