Skip to content

Commit

Permalink
Add support for displaying extra IPC markers (PR #2535)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimporter committed Jun 24, 2020
2 parents dea0a66 + 6d87cb3 commit e721329
Show file tree
Hide file tree
Showing 15 changed files with 566 additions and 166 deletions.
1 change: 1 addition & 0 deletions docs-user/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* [Remote profiling on Android](./guide-remote-profiling.md)
* [Perf profiling on Linux](./guide-perf-profiling.md)
* [Memory Allocations](./memory-allocations.md)
* [IPC Messages](./ipc-messages.md)
* [Video Tutorials](./videos.md)
* [Firefox Profiler intro](./videos-intro.md)
* [Samples and markers](./videos-samples-markers.md)
Expand Down
Binary file added docs-user/images/ipc-messages-feature.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs-user/images/ipc-messages-io-threads.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs-user/images/ipc-messages-popup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions docs-user/ipc-messages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# IPC Messages

The Firefox Profiler supports recording IPC messages for any actively-profiled
thread. During profiling, each IPC message is recorded with 5 events:

1. When the `SendXXX` function is called on the origin thread
2. When the sender's IO thread begins sending bytes over the IPC channel
3. When the sender's IO thread finishes sending bytes over the IPC channel
4. When the recipient's IO thread finishes receiving bytes from the IPC channel
5. When the `RecvXXX` function is called on the destination thread

## IPC Track

After collecting a profile with IPC messages, there will be a new track in the
timeline showing the outgoing (blue) and incoming (purple) IPC messages.
Hovering over a marker for an IPC message will provide more details about it:

![A screenshot of the popup UI for an IPC message.](images/ipc-messages-popup.png)

Each IPC message has several durations associated with it, corresponding to the
spans of time between consecutive IPC message phases as described above:

* *Send thread latency*: the time between `SendXXX` being called and the first
byte sent over the IPC channel
* *IPC send duration*: the time taken to send all the bytes over the IPC channel
* *IPC recv latency*: the time between the last byte being sent over the IPC
channel and the last byte being *received*
* *Recv thread latency*: the time between the last byte being received from the
IPC channel and the `RecvXXX` function being called

## Enabling the Feature

In `about:profiling`, scroll down to the `Features` section and enable the
`IPC Messages` checkbox.

![A screenshot of the UI to turn on IPC messages.](images/ipc-messages-feature.png)

### Profiling the IO Threads

By default, the sender's and recipient's IO threads aren't included in a
profile. To include these, add `Gecko_IOThread` and `Chrome_ChildThread` to the
list of threads to be profiled.

![A screenshot of the UI to profile the IO threads](images/ipc-messages-io-threads.png)
22 changes: 22 additions & 0 deletions src/components/tooltip/Marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ function _sumMaybeEntries(
.reduce((a, x) => a + x, 0);
}

function _maybeFormatDuration(
start: number | void,
end: number | void
): string {
if (start !== undefined && end !== undefined) {
return formatMilliseconds(end - start);
}
return 'unknown';
}

const MaybeBacktrace = ({
marker,
thread,
Expand Down Expand Up @@ -635,6 +645,18 @@ function getMarkerDetails(
<TooltipDetails>
<TooltipDetail label="Type">{data.messageType}</TooltipDetail>
<TooltipDetail label="Sync">{data.sync.toString()}</TooltipDetail>
<TooltipDetail label="Send Thread Latency">
{_maybeFormatDuration(data.startTime, data.sendStartTime)}
</TooltipDetail>
<TooltipDetail label="IPC Speed">
{_maybeFormatDuration(data.sendStartTime, data.sendEndTime)}
</TooltipDetail>
<TooltipDetail label="IPC Latency">
{_maybeFormatDuration(data.sendEndTime, data.recvEndTime)}
</TooltipDetail>
<TooltipDetail label="Recv Thread Latency">
{_maybeFormatDuration(data.recvEndTime, data.endTime)}
</TooltipDetail>
</TooltipDetails>
);
break;
Expand Down
Loading

0 comments on commit e721329

Please sign in to comment.