Skip to content
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

Support getStack limits #1180

Merged
merged 5 commits into from Nov 11, 2020
Merged

Support getStack limits #1180

merged 5 commits into from Nov 11, 2020

Conversation

Copy link
Member

@grouma grouma commented Nov 10, 2020

No description provided.

@grouma grouma requested review from devoncarew and bkonyi Nov 10, 2020
@google-cla google-cla bot added the cla: yes label Nov 10, 2020
Copy link
Contributor

@bkonyi bkonyi left a comment

LGTM once truncated matches the VM behavior.

@@ -148,12 +148,12 @@ class Debugger extends Domain {
/// Returns the current Dart stack for the paused debugger.
///
/// Returns null if the debugger is not paused.
Copy link
Contributor

@bkonyi bkonyi Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: does the comment here need to be updated?

var frames = await stackComputer.calculateFrames();
return Stack(frames: frames, messages: []);
var frames = await stackComputer.calculateFrames(limit: limit);
return Stack(frames: frames, messages: [], truncated: limit != null);
Copy link
Contributor

@bkonyi bkonyi Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would diverge from the VM's behavior if frames.length < limit.

Copy link
Member Author

@grouma grouma Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I'll change it. I assume it should be limit != null && frame.length <= limit?

@@ -458,8 +458,8 @@ ${globalLoadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension(
///
/// Returns null if the corresponding isolate is not paused.
Copy link
Contributor

@bkonyi bkonyi Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: does documentation here need updating?

@@ -11,12 +12,18 @@ import 'debugger.dart';
class FrameComputer {
final Debugger debugger;

final _pool = Pool(1);
Copy link
Contributor

@bkonyi bkonyi Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing we plan on increasing this pool size in the future?

Copy link
Member Author

@grouma grouma Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The pool is used to prevent the same work from happening multiple times.

Copy link
Member

@devoncarew devoncarew Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's worth an in-line comment to explain how we're using Pool here -

}

return dartFrames;
await _collectSyncFrames(limit: limit);
Copy link
Contributor

@bkonyi bkonyi Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason we're doing this recursively? Asking more out of curiosity than anything.

Copy link
Member Author

@grouma grouma Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The async frame computer is best modeled recursively due to the chaining nature. I wanted this function to align so that it is easier to understand both. They both have a similar format in that we break the recursion if a limit is met.

@@ -11,12 +12,18 @@ import 'debugger.dart';
class FrameComputer {
final Debugger debugger;

final _pool = Pool(1);
Copy link
Member

@devoncarew devoncarew Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's worth an in-line comment to explain how we're using Pool here -

@@ -458,8 +458,8 @@ ${globalLoadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension(
///
/// Returns null if the corresponding isolate is not paused.
@override
Future<Stack> getStack(String isolateId) async =>
(await _debugger).getStack(isolateId);
Future<Stack> getStack(String isolateId, {int limit}) async =>
Copy link
Member

@devoncarew devoncarew Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my own understanding, getStack() supports a limit now, but not an API to specify an offset (it can limit the number of frames returned, but not page through them)?

Copy link
Member Author

@grouma grouma Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. The initial approach was to offer paging but that proved difficult on the VM side of things. This approach should still offer the same performance improvements and be easy to implement on all platforms.

@grouma grouma merged commit 0036f44 into master Nov 11, 2020
2 checks passed
@grouma grouma deleted the limit branch Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants