google / UIforETW

User interface for recording and managing ETW traces
https://randomascii.wordpress.com/2015/04/14/uiforetw-windows-performance-made-easier/
Apache License 2.0
1.55k stars 201 forks source link

Can ETW capture Task Queue events related to Chrome? #128

Open rainkin1993 opened 5 years ago

rainkin1993 commented 5 years ago

In my understanding, when chrome download a file from a URL, 1) A Socket thread will dequeue a network request from it's task queue. And try to connect and receive data from a certain URL.

2) A File IO thread will dequeue a request from it's task queue, and obtain the received data and write it to disk file.

My question is whether ETW can capture the task 1) enqueue and dequeue event 2) details of the task, such as id of task?

randomascii commented 5 years ago

UIforETW can ask Chrome to emit ETW events for particular tracing categories. This requires cooperation between UIforETW and Chrome as they have to agree on how to map between category names and a bit mask. So, look in the UIforETW settings and the Chrome source code to see if the categories you care about can be monitored.

The Chrome ETW events will show up in WPA's Generic Events table. They aren't in the tidiest format ever, but sometimes they can be helpful. Improving this integration would be great but nobody is currently working on it.

rainkin1993 commented 5 years ago

I have one more question, how can I know which categories Chrome export to ETW? I mean whether Chrome export all logs of chrome://tracing to ETW?

After reading code from: https://cs.chromium.org/chromium/src/base/trace_event/trace_event_etw_export_win.cc?q=f:trace_event_etw_export_win.cc&sq=package:chromium&g=0&l=65

It seems that Chrome only export limited categories to ETW.

randomascii commented 5 years ago

That source code is code that controls what categories can be requested. If we want to add more categories to that list (and to the equivalent list in UIforETW) then that is easy enough to do. We can't add all categories because we are ultimately squeezing them in to a bit mask, but there is still lots of room.

rainkin1993 commented 5 years ago

Very thanks for your help.

I also open a discussion thread in Chrome-dev google group. https://groups.google.com/a/chromium.org/forum/#!mydiscussions/chromium-dev/9tHXHi0NScI


The following is the new question I copy from the link above:

My goal is to build a tool which can convert ETW traces of Chrome provider to json file which can be loaded in chrome://tracing. Hopefully, recording trace for same chrome activities, the json my tool generated is the same as the json exported by chrome://tracing. I have already noticed that someone proposed this kind of tool in this link: https://bugs.chromium.org/p/chromium/issues/detail?id=508663

Now I have the following problems:

  1. It seems that Chrome emit incomplete field listed in Trace Event Foramt which is used by the Chrome://tracing tool.

For example, browser process send a IPC message to render process. There should be two events, send ipc and receive ipc. Each event has a field called bind_id, which can be used to connect two event.

{"pid":18252,"tid":4756,"ts":614252235944,"ph":"X","cat":"disabled-by-default-ipc.flow","name":"MessagePipeReader::Send","args":{},"dur":2,"tdur":2,"tts":448747888,"id":"0x0","bind_id":"0xd31a3a02","flow_out":true},

{"pid":10636,"tid":3476,"ts":614252235989,"ph":"X","cat":"disabled-by-default-ipc.flow","name":"MessagePipeReader::Receive","args":{},"dur":4,"tdur":4,"tts":2558781,"id":"0x0","bind_id":"0xd31a3a02","flow_in":true}

The following is raw event I obtained from ETW:

"MessagePipeReader::Send", "Complete", "", "", "", "", "", ""

"MessagePipeReader::Receive", "Complete", "", "", "", "", "", ""

The conclusion is that I cannot recover the results showed in chrome://tracing due to incomplete events. Please correct me if I misunderstand ETW traces.

  1. Is there any other tools which can capture the same events as chrome://tracing but these tools can be executed outside Chrome, just like ETW? Or does chrome support automatically saving events of chrome://tracing to disk in background without touching the chrome://tracing page manually.

Thanks

randomascii commented 5 years ago

I replied on the chromium-dev thread. That's probably the best place for the conversation.

On Mon, Feb 25, 2019 at 10:57 PM rainkin1993 notifications@github.com wrote:

Very thanks for your help.

I also open a discussion thread in Chrome-dev google group.

https://groups.google.com/a/chromium.org/forum/#!mydiscussions/chromium-dev/9tHXHi0NScI

The following is the new question I copy from the link above:

My goal is to build a tool which can convert ETW traces of Chrome provider to json file which can be loaded in chrome://tracing. Hopefully, recording trace for same chrome activities, the json my tool generated is the same as the json exported by chrome://tracing. I have already noticed that someone proposed this kind of tool in this link: https://bugs.chromium.org/p/chromium/issues/detail?id=508663

Now I have the following problems:

  1. It seems that Chrome emit incomplete field listed in Trace Event Foramt which is used by the Chrome://tracing tool.

For example, browser process send a IPC message to render process. There should be two events, send ipc and receive ipc. Each event has a field called bind_id, which can be used to connect two event.

{"pid":18252,"tid":4756,"ts":614252235944,"ph":"X","cat":"disabled-by-default-ipc.flow","name":"MessagePipeReader::Send","args":{},"dur":2,"tdur":2,"tts":448747888,"id":"0x0","bind_id":"0xd31a3a02","flow_out":true},

{"pid":10636,"tid":3476,"ts":614252235989,"ph":"X","cat":"disabled-by-default-ipc.flow","name":"MessagePipeReader::Receive","args":{},"dur":4,"tdur":4,"tts":2558781,"id":"0x0","bind_id":"0xd31a3a02","flow_in":true}

The following is raw event I obtained from ETW:

"MessagePipeReader::Send", "Complete", "", "", "", "", "", ""

"MessagePipeReader::Receive", "Complete", "", "", "", "", "", ""

The conclusion is that I cannot recover the results showed in chrome://tracing due to incomplete events. Please correct me if I misunderstand ETW traces.

  1. Is there any other tools which can capture the same events as chrome://tracing but these tools can be executed outside Chrome, just like ETW? Or does chrome support automatically saving events of chrome://tracing to disk in background without touching the chrome://tracing page manually.

Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/google/UIforETW/issues/128#issuecomment-467319536, or mute the thread https://github.com/notifications/unsubscribe-auth/AKTLqSpeq5uEyTggitbn2gXsWY9nPt01ks5vRNrjgaJpZM4ZY4DX .

-- Bruce Dawson