-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Call Stack performance with many threads, fixes #44248 #44249
Conversation
9add8be
to
b27256c
Compare
b27256c
to
96f67c7
Compare
@isidorn change looks good and makes sense to me. |
@rsalvador Thanks a lot for your PR. I left comments directly in the code, once you address those we could merge this in. |
if (timer) { | ||
clearTimeout(timer); | ||
} | ||
this.displayThreadsTimer.set(session.getId(), setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a timeoue please use a Scheduler
.
An example usage can be found here https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/debug/electron-browser/callStackView.ts#L38
@@ -81,6 +81,7 @@ export class DebugService implements debug.IDebugService { | |||
private launchJsonChanged: boolean; | |||
private firstSessionStart: boolean; | |||
private previousState: debug.State; | |||
private displayThreadsTimer: Map<String, number>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use lowercase string
@@ -113,6 +114,7 @@ export class DebugService implements debug.IDebugService { | |||
this._onDidCustomEvent = new Emitter<debug.DebugEvent>(); | |||
this.sessionStates = new Map<string, debug.State>(); | |||
this.allProcesses = new Map<string, debug.IProcess>(); | |||
this.displayThreadsTimer = new Map<String, number>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use lowercase string
clearTimeout(timer); | ||
} | ||
this.displayThreadsTimer.set(session.getId(), setTimeout(() => { | ||
this.fetchThreads(session).done(undefined, errors.onUnexpectedError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will make
@rsalvador Also before we accpet this change I would still need convincing vscode blocks the UI. Since I like what we are already doing - we are refreshing the callstack view with a 50ms delay. So if multiple changes come in that range we will only refresh once. Do you still see the vscode blocking if you change this 50ms to 200 ms for example here https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/debug/electron-browser/callStackView.ts#L82 Including @testforstephen to see if this can be fixed on the Java extension side. Even though vscode UI should protect against such behavior from an extension. |
@isidorn thank for looking into this! |
@rsalvador thanks for more details. I will look into this in greater details next week. Until then we can also get @testforstephen feedback |
Looks good. The fix could help to reduce the |
@@ -113,6 +115,7 @@ export class DebugService implements debug.IDebugService { | |||
this._onDidCustomEvent = new Emitter<debug.DebugEvent>(); | |||
this.sessionStates = new Map<string, debug.State>(); | |||
this.allProcesses = new Map<string, debug.IProcess>(); | |||
this.displayThreadsScheduler = new Map<string, RunOnceScheduler>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if this was called fetchThreadsSchedulers
@@ -300,7 +303,7 @@ 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); | |||
this.debouncedDisplayThreads(session); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if this method was inlined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please add a one line comment about why we are debouncing
scheduler = new RunOnceScheduler(() => { | ||
this.fetchThreads(session).done(undefined, errors.onUnexpectedError); | ||
}, 100); | ||
this.displayThreadsScheduler.set(session.getId(), scheduler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scheduler should be added to toDisposeOnSessionEnd
so it gets properly disposed
@rsalvador I have commented in the code - mostly polish. |
@isidorn performed all changes and rebased/resolved |
@rsalvador thanks a lot. Looks good to me, let's merge it in. |
No description provided.