Skip to content

Batch debug events sent from injected client to dwds #1487

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

Merged
merged 12 commits into from
Jan 21, 2022

Conversation

annagrin
Copy link
Contributor

@annagrin annagrin commented Jan 15, 2022

Flutter framework sends frequent frame events using developer.postEvent. In scenarios where we have to
use SSE between the browser and dwds (possibly on a different machine) this leads to high network load and slows down debugging.

Batch and send debug events every 1000ms instead.

Closes: #1466

Anna Gringauze added 5 commits January 14, 2022 17:10
Flutter framework sends frequent frame events using
`developer.postEvent`. In scenarios where we have to
use SSE between the browser and dwds this leads to
hign network load and slows down debugging.

Batch and send debug events every 1000ms instead.

Closes: dart-lang#1466

var lastSendTime = DateTime.now().millisecondsSinceEpoch;
while (await _inputQueue.hasNext.timeout(duration, onTimeout: () => true)) {
if (await _inputQueue.hasNext.timeout(duration, onTimeout: () => false)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment for this conditional. I'm confused about what the logic here is doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, this is trying not to pause batching until the next element arrives, times it instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made helpers with explanatory names and added comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to adding a few comments in this method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

already done:)

BatchedStreamController<DebugEvent>(delay: _batchDelayMilliseconds);
debugEventController.stream.listen((events) {
client.sink.add(jsonEncode(serializers.serialize(BatchedDebugEvents(
(b) => b..events = ListBuilder<DebugEvent>(events)))));
Copy link
Contributor

Choose a reason for hiding this comment

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

why the .. instead of . ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove the extra dot it seems, thanks! The result of the closure parameter in the constructor of BatchedDebugEvents is not used it appears.

@annagrin annagrin merged commit 2b61039 into dart-lang:master Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSE communication between the injected client and dwds is slow
5 participants