Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement searchable property for marker schema #4352

Merged
merged 4 commits into from Dec 9, 2022

Conversation

canova
Copy link
Member

@canova canova commented Dec 2, 2022

Fixes #2780.

We also need to land the Bugzilla counterpart here. It Adds searchable: true to:

  • Markers that we had manual checks for in the frontend, like: Log, FileIO, DOMEvent,
  • Markers that had generic payload fields like name and category.

This PR removes the manual filtering that we had and replaces it with checking all the payload's searchable fields.
We also had to add an upgrader for both gecko and processed format and add searchable fields for these fields, so even though we remove these manual checks, search on older profiles work as expected.

I wasn't sure if the performance would be the same but after doing some micro benchmarks, I've found out that it's at lest the same if not better. Here's a before and after running times of that getSearchFilteredMarkerIndexes that I measured.

Deploy preview:
I also got this profile from out spreadsheet that says "Awful lots of markers" :)
Before / After

@codecov
Copy link

codecov bot commented Dec 2, 2022

Codecov Report

Base: 88.37% // Head: 88.36% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (35c1c5c) compared to base (02cd177).
Patch coverage: 89.33% of modified lines in pull request are covered.

❗ Current head 35c1c5c differs from pull request most recent head 8de1e7b. Consider uploading reports for the commit 8de1e7b to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4352      +/-   ##
==========================================
- Coverage   88.37%   88.36%   -0.01%     
==========================================
  Files         282      282              
  Lines       25314    25351      +37     
  Branches     6826     6828       +2     
==========================================
+ Hits        22371    22402      +31     
- Misses       2731     2737       +6     
  Partials      212      212              
Impacted Files Coverage Δ
src/selectors/per-thread/markers.js 93.63% <ø> (ø)
src/test/fixtures/profiles/marker-schema.js 100.00% <ø> (ø)
src/profile-logic/marker-schema.js 89.18% <84.61%> (-0.29%) ⬇️
src/profile-logic/processed-profile-versioning.js 85.34% <86.95%> (+0.04%) ⬆️
src/profile-logic/gecko-profile-versioning.js 89.12% <88.88%> (-0.02%) ⬇️
src/app-logic/constants.js 100.00% <100.00%> (ø)
src/profile-logic/marker-data.js 93.64% <100.00%> (+0.06%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

@canova canova requested a review from julienw December 2, 2022 14:38
Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

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

This looks pretty good to me!

I don't see an upgrader part for these markers: https://searchfox.org/mozilla-central/rev/404408660a4d976e2ac25881cb1e1f2712f2d430/tools/profiler/core/MicroGeckoProfiler.cpp#47-88
do you think we could add one?

Comment on lines 1410 to 1413
const searchableFields = schema.data.filter((field) =>
searchableFieldKeys.includes(field.key)
);
for (const field of searchableFields) {
Copy link
Contributor

Choose a reason for hiding this comment

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

optional nit:

Doing this in 2 steps look a bit more complicated than how it could be. What about looping on schema.data directly?

for (const field of schema.data) {
  if (searchableFieldKeys.includes(field.key)) {
    field.searchable = true;
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment for the other versioning file

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, changed it, thanks :)

Comment on lines +1399 to +1402
// 'target' wasn't included in our code before. But I thought this
// would be a useful addition.
Copy link
Contributor

Choose a reason for hiding this comment

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

good idea! maybe target wasn't existing at the time we implemented the custom search. Not sure :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it looks like this was added after the initial implementation.

Comment on lines 1377 to 1383
case 'FileIO': {
searchableFieldKeys = [
'filename',
'operation',
'source',
'threadId',
];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change necessary? I see it was already done in the gecko code.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's probably not. I wasn't sure if they were added initially when we implemented the markers 2.0 or added later but it looks like they are actually added while we are implementing schemas. So we don't need to change them except threadId. We don't have the threadId in the schema, so added it manually.

markerSchema: MarkerSchema,
marker: Marker,
searchRegExp: RegExp
): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should set searchRegExp.lastIndex = 0 here too. Currently we should be good, but I'm concerned about how we might use this function in the future too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that makes sense. Added it.

Copy link
Member Author

@canova canova left a comment

Choose a reason for hiding this comment

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

Thanks for the review! I addressed your comments. Added the last commit, would you mind taking a quick look on it?

I don't see an upgrader part for these markers: https://searchfox.org/mozilla-central/rev/404408660a4d976e2ac25881cb1e1f2712f2d430/tools/profiler/core/MicroGeckoProfiler.cpp#47-88
do you think we could add one?

Good idea, added it.

Comment on lines 1410 to 1413
const searchableFields = schema.data.filter((field) =>
searchableFieldKeys.includes(field.key)
);
for (const field of searchableFields) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Right, changed it, thanks :)

Comment on lines +1399 to +1402
// 'target' wasn't included in our code before. But I thought this
// would be a useful addition.
Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it looks like this was added after the initial implementation.

Comment on lines 1377 to 1383
case 'FileIO': {
searchableFieldKeys = [
'filename',
'operation',
'source',
'threadId',
];
Copy link
Member Author

Choose a reason for hiding this comment

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

It's probably not. I wasn't sure if they were added initially when we implemented the markers 2.0 or added later but it looks like they are actually added while we are implementing schemas. So we don't need to change them except threadId. We don't have the threadId in the schema, so added it manually.

markerSchema: MarkerSchema,
marker: Marker,
searchRegExp: RegExp
): boolean {
Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that makes sense. Added it.

@canova canova requested a review from julienw December 6, 2022 12:41
Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

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

looks good to me, thanks for checking!

@canova canova enabled auto-merge December 9, 2022 15:54
@canova canova merged commit 4a00e43 into firefox-devtools:main Dec 9, 2022
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.

Implement "searchable" feature for the marker schema
2 participants