Skip to content

Add a transform to filter samples by marker name#4610

Closed
canova wants to merge 9 commits into
firefox-devtools:mainfrom
canova:filter-by-marker
Closed

Add a transform to filter samples by marker name#4610
canova wants to merge 9 commits into
firefox-devtools:mainfrom
canova:filter-by-marker

Conversation

@canova

@canova canova commented May 8, 2023

Copy link
Copy Markdown
Member

Fixes #4590.
This PR is ready for feedback and review

Deploy preview

This PR adds a marker context menu item called Filter samples by “<marker name>” markers.

It also changes the per-thread selectors creation pipeline so we can have derived marker selectors for the transform computation. Previously, we created the thread selectors, and then the marker selectors .It made it impossible to get the derived markers for transform applied thread computation. Now we do the thread selectors in 2 steps. We create basic thread selectors first, then we craate the marker selectors, and then we create the more advanced thread selectors that require markers to be computed.

Things I would like to get feedback on:

  • Wording on the context menu item. This is the best I could come up with but happy to get feedback for improvements.
  • How we get the "marker name". Currently this is a bit ad hoc. Because we can either have names in the marker payload (e.g. UserTiming markers) or in the name itself. So how I get is that, first I check if marker payload has a name and use it if it has. Otherwise I get the marker name. This is how it's done marker.data && marker.data.name ? marker.data.name : marker.name. We can possible use marker schema for this, but not sure what to pick there as we have multiple labels.
  • The context menu item icon. I found it from the photon icons here.

It could be better to look at the commits one by one.

Here's a screenshot of the new context menu item:
Screenshot 2023-05-09 at 11 57 27 AM

Here's a screenshot of the transform navigator:
Screenshot 2023-05-09 at 11 58 11 AM

@canova canova force-pushed the filter-by-marker branch 4 times, most recently from 68d5b71 to 7ff0a57 Compare May 8, 2023 19:33
@canova canova marked this pull request as ready for review May 9, 2023 09:59
@canova canova requested a review from a team as a code owner May 9, 2023 09:59
@canova canova requested a review from julienw May 9, 2023 10:00
Comment thread locales/en-US/app.ftl Outdated
# It filters the samples by the marker name.
# Variables:
# $markerName (String) - Name of the marker that is selected.
MarkerContextMenu--filter-samples-by-marker-name = Filter samples by “<strong>{ $markerName }</strong>” markers

@flodolo flodolo May 9, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it just me or this could read better with with? Also, plural or singular marker?

Filter samples with “<strong>{ $markerName }</strong>” marker

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I wasn't sure which one was best but I found this answer: https://english.stackexchange.com/a/392465
It says:

To choose either 'by' or 'with', you need to see if the phrase/word that comes next indicates a method or an instrument. If you want to show a method, you use by. If it's an instrument with which the activity was done, you use with

And here's the part that fits our example:

In your case, 'names' are a method used for filtering users list, not an instrument. So, you have to use 'by'. See the examples below:

I want to filter the users list by names

So I think it's "by", but this is only one answer and it could be wrong. Happy to get more feedback from other people.

For plurality, I chose the plural "markers" because there could be multiple markers with the same name and we account all the markers with that name while filtering.

@canova canova May 9, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After rereading the first paragraph of the answer, "instrument" sounds closer to our sentence though. with could be more suitable for this case. 🤔
@julienw @mstange what do you think?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After talking about this in the matrix channel, I've thought a bit about this and decided to use Filter samples within “{ $markerName }” markers (even though I was opposed to it at first :) )

I wanted to use it because I really wanted a one word alternative to the others.
The closes ones I was considering were Filter samples taken during "{ $markerName }" markers and Filter samples overlapping with “{ $markerName }” markers but I felt like they are long.

Let me know what you think!

@canova canova force-pushed the filter-by-marker branch 2 times, most recently from f017857 to cb0d410 Compare May 9, 2023 14:13
@canova canova force-pushed the filter-by-marker branch 2 times, most recently from a1570d0 to 8741c07 Compare May 9, 2023 15:31
canova added 5 commits May 9, 2023 20:00
…ransforms

Before the 'filter-samples' transform, we didn't need to get the
derived markers to be able to compute any thread related pre-thread
selectors. But with 'filter-samples' transform, we need to get the
derived markers to be able to compute the transform filtered thread
because this transform needs to find the markers that match the filter
and get the interval range out of them.

So because of this, I had to split the thread related selectors so we
can get the marker selectors in between them and have the marker
selectors in the second phase of thread selectors.

Previously the dependency graph was like this:

```
thread selectors
     |
     v
stack and sample
     +
marker selectors
     |
     v
composed selectors
```

Now it's like this:

```
basic thread selectors
       |
       v
marker selectors
       |
       v
rest of the thread selectors
       |
       v
stack and sample selectors
       |
       v
composed selectors
```

We can't put these thread selectors that require markers into the
`composed` selectors because stack and sample selectors require those
selectors earlier in the pipeline and I wanted to keep the thread
selectors still in their file to keep the pipeline in a single file.
@canova canova force-pushed the filter-by-marker branch from 8741c07 to d3361d7 Compare May 9, 2023 18:00

@julienw julienw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this seems to work very well!

I left a few comments, but my main concern is how we serialize the transform to the URL, that we could use the stringIndex for the marker name. Tell me what you think!

}

.markerContextMenuIconFilterSamples {
background-image: url(firefox-profiler-res/img/svg/filter.svg);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look great when the line is selected. Maybe try to invert it on hover (see below). Otherwise we may need to tweak it so that it doesn't have an alpha layer anymore.

Also I'm not sure this is the best icon, I don't see how it relates to droping or markers. But we can change it later so let's not focus on this. Or maybe we can just reuse the icon we use for "drop samples"? Indeed we're not in the same context menu.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not super happy about the icon but that's the only one I could find. I didn't want to use "drop function" icon because that uses the tree visualization to convey the meaning which is correct since we apply this to call tree. But we drop samples directly here. But maybe that's fine?

Here's how it looks with the inverter colors, what do you think?:
Screenshot 2023-05-15 at 10 00 58 AM

name: 'measure-2',
entryType: 'measure',
},
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: these markers do not look exactly like real profiles, because the name should probably be DOMEvent for dom events, and UserTiming for user timing markers. Then of course you'd have to find another marker type for Marker B so that it's different than the other UserTiming.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, to be able to identify quickly I did this, but I can change them.

Comment thread src/test/store/transforms.test.js
}}
elems={{ strong: <strong /> }}
>
<>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that you're using fragments so that <Localized> properly handles the tags inside the message. Can you please add a comment about this, otherwise it's a bit surprising.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the reason. Added a comment here.

Comment thread locales/en-US/app.ftl
Comment on lines +541 to +544
// This is also the case for drop-function transform. We need to have a
// generic mechanism for: if the selected call node (after the transformation
// has been applied to the call path) is not present in the call tree, run
// some generic code that finds a close-by call node which is present.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please file a bug and add the number here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed it and added it here.

Comment thread src/profile-logic/transforms.js Outdated
Comment thread src/profile-logic/transforms.js Outdated
Comment on lines +281 to +282
// Filter string may include "-" characters, so we need to join them back.
const filterString = filter.join('-');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we use the marker name, what do you think of using the index in the stringTable instead of the fullstring? If we want to change to a string in the future, we can still change the prefix (m -> M) for example. This would make the filter string a lot shorter and also would remove the problem of the dash character.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense! Change it to use string table index.

@canova canova force-pushed the filter-by-marker branch from 8c1290c to 9905613 Compare May 15, 2023 15:03
@canova

canova commented May 15, 2023

Copy link
Copy Markdown
Member Author

Thanks for the review! It should be ready for another review now.

@canova canova requested a review from julienw May 15, 2023 15:04
@codecov

codecov Bot commented May 15, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 84.96% and project coverage change: -0.10 ⚠️

Comparison is base (36bad68) 88.63% compared to head (36a374b) 88.53%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4610      +/-   ##
==========================================
- Coverage   88.63%   88.53%   -0.10%     
==========================================
  Files         293      294       +1     
  Lines       25990    26159     +169     
  Branches     6998     7051      +53     
==========================================
+ Hits        23035    23159     +124     
- Misses       2749     2791      +42     
- Partials      206      209       +3     
Impacted Files Coverage Δ
src/components/shared/MarkerSettings.js 85.71% <ø> (ø)
src/components/shared/PanelSearch.js 71.42% <ø> (ø)
src/selectors/per-thread/markers.js 93.63% <ø> (ø)
src/selectors/per-thread/stack-sample.js 96.96% <ø> (ø)
src/utils/text-measurement.js 100.00% <ø> (ø)
src/components/shared/MarkerContextMenu.js 84.56% <50.00%> (-1.80%) ⬇️
src/components/shared/CallNodeContextMenu.js 89.24% <60.00%> (-0.72%) ⬇️
src/profile-logic/transforms.js 91.42% <65.93%> (-3.00%) ⬇️
src/app-logic/url-handling.js 87.07% <75.00%> (-0.31%) ⬇️
src/components/marker-chart/Canvas.js 93.30% <75.00%> (-0.27%) ⬇️
... and 16 more

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@julienw julienw removed their request for review May 24, 2023 14:03
@julienw

julienw commented May 24, 2023

Copy link
Copy Markdown
Contributor

I'm removing my r request because this feature will need to be changed according to our last week discussion.

@canova

canova commented May 25, 2023

Copy link
Copy Markdown
Member Author

Thanks for all the feedback, I'm closing this in favor of #4631. I changed the behavior quite a bit, that's why I wanted to start from scratch.

@canova canova closed this May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to filter samples by marker name

3 participants