diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 5947107e5bc..ee153e3d058 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -55,6 +55,7 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IAction, Action } from 'vs/base/common/actions'; import { normalizeDriveLetter } from 'vs/base/common/labels'; +import { RunOnceScheduler } from 'vs/base/common/async'; const DEBUG_BREAKPOINTS_KEY = 'debug.breakpoint'; const DEBUG_BREAKPOINTS_ACTIVATED_KEY = 'debug.breakpointactivated'; @@ -83,6 +84,7 @@ export class DebugService implements debug.IDebugService { private launchJsonChanged: boolean; private firstSessionStart: boolean; private previousState: debug.State; + private fetchThreadsSchedulers: Map; constructor( @IStorageService private storageService: IStorageService, @@ -115,6 +117,7 @@ export class DebugService implements debug.IDebugService { this._onDidCustomEvent = new Emitter(); this.sessionStates = new Map(); this.allProcesses = new Map(); + this.fetchThreadsSchedulers = new Map(); this.configurationManager = this.instantiationService.createInstance(ConfigurationManager); this.toDispose.push(this.configurationManager); @@ -302,7 +305,18 @@ export class DebugService implements debug.IDebugService { this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidThread(event => { if (event.body.reason === 'started') { - this.fetchThreads(session).done(undefined, errors.onUnexpectedError); + // debounce to reduce threadsRequest frequency and improve performance + let scheduler = this.fetchThreadsSchedulers.get(session.getId()); + if (!scheduler) { + scheduler = new RunOnceScheduler(() => { + this.fetchThreads(session).done(undefined, errors.onUnexpectedError); + }, 100); + this.fetchThreadsSchedulers.set(session.getId(), scheduler); + this.toDisposeOnSessionEnd.get(session.getId()).push(scheduler); + } + if (!scheduler.isScheduled()) { + scheduler.schedule(); + } } else if (event.body.reason === 'exited') { this.model.clearThreads(session.getId(), true, event.body.threadId); }