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

Events for blocking calls #1671

Open
ueman opened this issue Oct 9, 2023 · 8 comments
Open

Events for blocking calls #1671

ueman opened this issue Oct 9, 2023 · 8 comments

Comments

@ueman
Copy link
Collaborator

ueman commented Oct 9, 2023

Problem Statement

Similar to https://twitter.com/brungarc/status/1711484812702171309 it should be possible in Dart to detect blocking file IO calls.

There's also a lint rule (https://dart.dev/tools/linter-rules/avoid_slow_async_io) to enforce sync io but that can't be detected for 3rd party code. Depending on the lint rule, it could make sense to send events based on sync or async file io. In mobile apps, async io is probably the better choice, while on CLIs or backend code sync io could be better.

Solution Brainstorm

Whenever a sync file API is called, an event should be sent to Sentry. This can be done with the existing file plugin by adding extra events when the sync APIs are called.

Are you willing to submit a PR?

None

@bruno-garcia
Copy link
Member

Relates to: getsentry/sentry-dotnet#2709

@stefanosiano
Copy link
Member

stefanosiano commented Oct 12, 2023

This could be a performance issue generated by the backend, without the need to send an event when one of those APIs is called. We already have file.async in the span, so we could leverage that.
Also, this is probably relevant to Flutter projects only

@stefanosiano stefanosiano moved this from Needs Discussion to Backlog in Mobile & Cross Platform SDK Oct 12, 2023
@buenaflor buenaflor moved this from Backlog to Needs Discussion in Mobile & Cross Platform SDK Oct 31, 2023
@buenaflor
Copy link
Contributor

How could a backend know if a File I/O call in a flutter app has been made? or am I understanding it wrong

@kahest
Copy link
Member

kahest commented Nov 6, 2023

@buenaflor the idea is that we create a perf issue for sync file I/O, but only for Flutter apps. Since we already have the file.async flag in the file spans we send, the detector living in the backend needs to check if it's a Flutter app and can then create a perf issue.

@buenaflor
Copy link
Contributor

Got it, sounds reasonable, I would also opt for that route since we already have the mechanism in place to make it happen - unless there are other concerns

@bruno-garcia
Copy link
Member

In .NET the situation we want to track is when an async call is blocked on:

async Execute(delegate d)
{
     SomeAsyncMethod().Wait(); // blocks and can cause thread pool starvation

   // right call would be: 
   await SomeAsyncMethod();
}

So that's any async method (not just I/O) that happens on a async flow that's blocked on. Any .Result or .Wait() for example.
A simple blocking file I/O wouldn't fire the detection, unless that was called within an async method (anywhere in the call chain).

In other words: On a program: void Main() { File.ReadAllLines()} -> Blocking I/O wouldn't fire anything because there's nothing async here being blocked on.

@buenaflor buenaflor moved this from Needs Discussion to Needs Investigation in Mobile & Cross Platform SDK Nov 14, 2023
@stefanosiano
Copy link
Member

Let's understand if it makes sense for Flutter, too.
Let's investigate if the await keyword has the same meaning in Dart and .NET, and if Dart has a similar mechanism of .NET's Wait()

@denrase
Copy link
Collaborator

denrase commented Dec 5, 2023

We can check if we run on the main or the background isolate, so we can add this info in the file plugin to spans wrapping sync/async calls.

#1727 (comment)

#1727 (comment)

@buenaflor buenaflor moved this from Needs Investigation to Needs Discussion in Mobile & Cross Platform SDK Dec 7, 2023
@buenaflor buenaflor moved this from Needs Discussion to Backlog in Mobile & Cross Platform SDK Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

6 participants