mirror of
https://github.com/microsoft/vscode.git
synced 2026-10-01 08:40:48 +01:00
nes: make cache delay configurable (#266)
This commit is contained in:
committed by
GitHub
parent
468c2937f7
commit
ac0b574dbd
@@ -41,8 +41,6 @@ import { CachedOrRebasedEdit, NextEditCache } from './nextEditCache';
|
||||
import { LlmNESTelemetryBuilder } from './nextEditProviderTelemetry';
|
||||
import { INextEditResult, NextEditResult } from './nextEditResult';
|
||||
|
||||
const ARTIFICIAL_CACHE_HIT_DELAY = 300; // delay cache hits by 300ms to make it more like a regular request and to reduce flicker ;)
|
||||
|
||||
export interface INextEditProvider<T extends INextEditResult, TTelemetry, TData = void> extends IDisposable {
|
||||
readonly ID: string;
|
||||
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
|
||||
let req: NextEditFetchRequest;
|
||||
let targetDocumentId = docId;
|
||||
|
||||
const cacheDelay = this._configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsCacheDelay, this._expService);
|
||||
|
||||
if (recentlyShownCachedEdit) {
|
||||
tracer.trace('using recently shown cached edit');
|
||||
edit = recentlyShownCachedEdit[0];
|
||||
@@ -173,7 +173,7 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne
|
||||
// back-date the recording bookmark of the cached edit to the bookmark of the original request.
|
||||
logContext.recordingBookmark = req.log.recordingBookmark;
|
||||
|
||||
await timeout(ARTIFICIAL_CACHE_HIT_DELAY);
|
||||
await timeout(cacheDelay);
|
||||
|
||||
} else if (cachedEdit) {
|
||||
tracer.trace('using cached edit');
|
||||
@@ -187,7 +187,7 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne
|
||||
// back-date the recording bookmark of the cached edit to the bookmark of the original request.
|
||||
logContext.recordingBookmark = req.log.recordingBookmark;
|
||||
|
||||
await timeout(ARTIFICIAL_CACHE_HIT_DELAY);
|
||||
await timeout(cacheDelay);
|
||||
|
||||
} else {
|
||||
tracer.trace('fetching next edit');
|
||||
|
||||
@@ -645,6 +645,7 @@ export namespace ConfigKey {
|
||||
export const InlineEditsYieldToCopilot = defineExpSetting<boolean>('chat.advanced.inlineEdits.yieldToCopilot', false, INTERNAL_RESTRICTED);
|
||||
export const InlineEditsLogContextRecorderEnabled = defineSetting('chat.advanced.inlineEdits.logContextRecorder.enabled', false, INTERNAL_RESTRICTED);
|
||||
export const InlineEditsDebounce = defineExpSetting<number>('chat.advanced.inlineEdits.debounce', 200, INTERNAL_RESTRICTED);
|
||||
export const InlineEditsCacheDelay = defineExpSetting<number>('chat.advanced.inlineEdits.cacheDelay', 300, INTERNAL_RESTRICTED);
|
||||
export const InlineEditsBackoffDebounceEnabled = defineExpSetting<boolean>('chat.advanced.inlineEdits.backoffDebounceEnabled', true, INTERNAL_RESTRICTED);
|
||||
export const InlineEditsExtraDebounceEndOfLine = defineExpSetting<number>('chat.advanced.inlineEdits.extraDebounceEndOfLine', 0, INTERNAL_RESTRICTED);
|
||||
export const InlineEditsDebounceOnSelectionChange = defineExpSetting<number | undefined>('chat.advanced.inlineEdits.debounceOnSelectionChange', undefined, INTERNAL_RESTRICTED);
|
||||
|
||||
Reference in New Issue
Block a user