dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.56k stars 4.55k forks source link

[Feature request]EventSource events for File IO #68435

Open noahfalk opened 2 years ago

noahfalk commented 2 years ago

It would be nice if we logged EventSource events when starting/finishing file IO operations so that profilers could understand where execution is IO bound rather than CPU bound. ETW provides events in a windows-specific context but doing it via EventSource would let us collect similar data using EventPipe as a uniform xplat tracing option. I haven't dived into the details of figuring out what the exact events should be or how we'd visualize it. This issue is just to track the idea.

ghost commented 2 years ago

Tagging subscribers to this area: @dotnet/area-system-io See info in area-owners.md if you want to be subscribed.

Issue Details
It would be nice if we logged EventSource events when starting/finishing file IO operations so that profilers could understand where execution is IO bound rather than CPU bound. ETW provides events in a windows-specific context but doing it via EventSource would let us collect similar data using EventPipe as a uniform xplat tracing option. I haven't dived into the details of figuring out what the exact events should be or how we'd visualize it. This issue is just to track the idea.
Author: noahfalk
Assignees: -
Labels: `enhancement`, `area-System.IO`
Milestone: -
adamsitnik commented 2 years ago

I am very supportive of this idea. 👍

or how we'd visualize it.

If we are able to connect the event with a CPU sample (by for example using the stack trace), we could extend the current speedscope exporter logic and emit OPEN/CLOSE events for the IO events as if they were just another method on the call stack.

Example:

void M()
{
    File.WriteAllText("test.txt", "test");
}

Currently:

Open M
Open File.WriteAllText
Close File.WriteAllText
Close M

After:

Open M
Open File.WriteAllText
Open FILE_WRITE
Close FILE_WRITE
Close File.WriteAllText
Close M

For Chromium, we could do the same and assign a new category to it, so perhaps it would get different color that typical CPU work.