firefox-devtools / firefox-devtools/profiler

A taxonomy of call tree transforms

Open
#5,340 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.5k
Forks
491
Avg merge
3d 46m
Merged PRs (30d)
27

Description

There is nothing to do in this issue, I'm just filing this so that it's recorded somewhere.

I've been thinking about call tree transforms and noticed some patterns.

For each transform, you can visualize how they act on the call tree.
But you can also visualize how they act on an individual stack. For example, say you have this stack:

```
(root)
XREMain::XRE_main
NS_ProcessNextEvent
mozilla::TaskController::RunTask
nsRefreshDriver::Tick
nsLayoutUtils::PaintFrame
```

Now you apply the transform "Merge function" on the `nsRefreshDriver::Tick` transform and get:

```
(root)
XREMain::XRE_main
NS_ProcessNextEvent
mozilla::TaskController::RunTask
nsLayoutUtils::PaintFrame
```

So, on a per-stack level, the "Merge function" transform means "Exclude stack frames with this function from each stack".

The other filters at the top of the call tree can also be regarded as transforms: The implementation filter (JS / C++ / Both) is very similar to a "merge function" transform. And the search filter acts as "drop non-matching samples" transform.

Most of our transforms act on stacks. But some act on samples, for example the "Drop samples with this function" transform.

We have both exclusive and inclusive transforms. For example "drop samples" excludes, and the search filter includes.

We have various ways to classify stack frames that the transforms act on: Based on function, category, resource, implementation, and whether the frame matches the search filter.

---

In summary, we support various primitives in very specific combinations.

But what if we supported all combinations? We'd end up with something like this:

## Transforms

- Merge based on individual stack frames:
- Only include frames with function `nsLayoutUtils::PaintFrame`
- Exclude frames with function `nsLayoutUtils::PaintFrame`
- Today: "Merge function"
- Only include frames with resource `XUL`
- Exclude frames with resource `XUL`
- Today: "Collapse `XUL`" + "Merge function"
- Only include frames with category `Graphics`
- Today: "Focus on category `Graphics`"
- Exclude frames with category `Graphics`
- Only include frames of type JS / C++ / label / unaccounted native
- Today (partial): Implementation filter
- Exclude frames of type JS / C++ / label / unaccounted native
- Today (partial): "Merge unaccounted native"
- Only include frames matching search `js::`
- Exclude frames matching search `js::`
- Merge consecutive stack frames:
- Merge consecutive frames with function `nsLayoutUtils::PaintFrame`
- Today: "Collapse direct recursion only"
- Merge consecutive frames with resource `XUL`
- Today: "Collapse `XUL`"
- Merge consecutive frames with category `Graphics`
- Merge consecutive frames of type JS / C++ / label / unaccounted native
- Merge consecutive frames matching search `js::`
- Slice stacks based on individual stack frame:
- Only include function `nsLayoutUtils::PaintFrame` and callees, leave stacks without this function unchanged
- Only include function `nsLayoutUtils::PaintFrame` and callees, drop stacks without this function
- Today: "Focus on function"
- Exclude function `nsLayoutUtils::PaintFrame` and callees
- Today: "Collapse function" + "Merge function"
- Only include function `nsLayoutUtils::PaintFrame` and callers, leave stacks without this function unchanged
- Today: "Collapse function"
- Only include function `nsLayoutUtils::PaintFrame` and callers, drop stacks without this function
- Exclude function `nsLayoutUtils::PaintFrame` and callers
- Slice stacks based on prefix/postfix:
- Exclude stack prefix `(start)`, ..., `nsLayoutUtils::PaintFrame` (keep last), leave stacks without this prefix unchanged
- Exclude stack prefix `(start)`, ..., `nsLayoutUtils::PaintFrame` (keep last), drop stacks without this prefix
- Today: "Focus on subtree only" in non-inverted mode
- Exclude stack suffix `MaybeMutex::Unlock`, ..., `RtlLeaveCriticalSection` (keep first), leave stacks without this suffix unchanged
- Exclude stack suffix `MaybeMutex::Unlock`, ..., `RtlLeaveCriticalSection` (keep first), drop stacks without this suffix
- Today: "Focus on subtree only" in inverted mode
- Slice out middle of stack based on recursion:
- Collapse recursion of function `nsLayoutUtils::PaintFrame`
- Today: "Collapse recursion"
- Collapse recursion of resource `XUL`
- Collapse recursion of category `Graphics`
- Collapse recursion of frame type JS / C++ / label / unaccounted native
- Collapse recursion of frames matching search `js::`
- Include/exclude samples containing stack frame anywhere in the stack:
- Only include samples containing function `nsLayoutUtils::PaintFrame`
- Exclude samples containing function `nsLayoutUtils::PaintFrame`
- Today: "Drop samples with this function"
- Only include samples containing resource `XUL`
- Exclude samples containing resource `XUL`
- Only include samples containing category `Graphics`
- Exclude samples containing category `Graphics`
- Only include samples containing type JS / C++ / label / unaccounted native
- Exclude samples containing type JS / C++ / label / unaccounted native
- Only include samples containing frames which match the search `js::`
- Today: Default behavior of call tree search field
- Exclude samples containing frames which match the search `js::`
- Include/exclude samples based on the sample's self frame:
- Only include self samples of function `nsLayoutUtils::PaintFrame`
- Today: "Focus on subtree only" on root nodes in the inverted tree
- Exclude self samples of function `nsLayoutUtils::PaintFrame`
- Only include self samples of resource `XUL`
- Exclude self samples of resource `XUL`
- Only include self samples of category `Graphics`
- Exclude self samples of category `Graphics`
- Only include self samples of type JS / C++ / label / unaccounted native
- Exclude self samples of type JS / C++ / label / unaccounted native
- Only include self samples of frames matching search `js::`
- Exclude self samples of frames matching search `js::`

┆Issue is synchronized with this [Jira Task](https://mozilla-hub.atlassian.net/browse/FP-871)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.