Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Incremental Performance Degradation with session.customRequest("variables") Calls #2119

Closed
neklesayurii opened this issue Oct 30, 2024 · 4 comments · Fixed by #2120
Closed
Assignees
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug debt Code quality issues verification-steps-needed Steps to verify are needed for verification
Milestone

Comments

@neklesayurii
Copy link

I've noticed that each time I call session.customRequest("variables") within a single debug session, the response time increases.
Restarting the debugger is the only way I've found to reset this slowdown, but I'd love to find a way to clear or reset any internal state or cache that might be causing this performance drop.
(I try to dump stack variables during debugging in extension)

System Info:

  • VS Code: 1.94.2
  • Debugger: Built-in Node.js Debugger
  • OS: Windows_NT x64 10.0.22631

Example Timing

for (let i = 0; i < 30; ++i) {
  const start = performance.now();
  await this.session.customRequest("variables", { variablesReference: variable.variablesReference });
  console.log("Time elapsed:", performance.now() - start);
}
Time elapsed:  11.290199999999459
Time elapsed:  11.23530000000028
Time elapsed:  12.20679999999993
...
Time elapsed:  34.46030000000246
Time elapsed:  33.31810000000041
Time elapsed:  36.91250000000218
Time elapsed:  34.52990000000136
Time elapsed:  37.4291000000012

I'm unsure if this is an issue with DAP or the debugger itself, but any tips on handling this without needing a full restart would be great!

@connor4312
Copy link
Member

DAP is just a protocol, this would be in the JS debugger

@connor4312 connor4312 transferred this issue from microsoft/debug-adapter-protocol Oct 30, 2024
@neklesayurii
Copy link
Author

Thanks for your quick reply, and I'm sorry for the mix-up

@connor4312
Copy link
Member

connor4312 commented Oct 31, 2024

I believe this is because we use a custom function sent to the runtime to generate property previews. This causes a new 'script' to be parsed and evaluated in the runtime. Unfortunately, CDP does not give us a way to 'release' these scripts, nor reuse a script/function that we can call again for each variable without a new script being parsed.

However, I observe that with support for clickable functions, we now call this for each function in a scope eagerly, which makes certain scopes like global scopes much more expensive.

this.baseChildren(),
]);
if (children.some(c => c instanceof FunctionLocationVariable)) {

Instead, we can just call the fast Runtime.getProperties which returns the location data we need without eagerly getting the representation for all properties.

@connor4312 connor4312 added the bug Issue identified by VS Code Team member as probable bug label Oct 31, 2024
@connor4312 connor4312 added this to the November 2024 milestone Oct 31, 2024
connor4312 added a commit that referenced this issue Oct 31, 2024
connor4312 added a commit that referenced this issue Oct 31, 2024
@alexr00 alexr00 added the verification-steps-needed Steps to verify are needed for verification label Dec 6, 2024
@connor4312
Copy link
Member

connor4312 commented Dec 6, 2024

@connor4312 connor4312 added the author-verification-requested Issues potentially verifiable by issue author label Dec 6, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug debt Code quality issues verification-steps-needed Steps to verify are needed for verification
Projects
None yet
3 participants