Skip to content

[TrackEvent] Tweak category/tags filters priority #1432

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

Merged
merged 10 commits into from
Jun 2, 2025

Conversation

etiennep-chromium
Copy link
Contributor

@etiennep-chromium etiennep-chromium commented May 7, 2025

This PR tweaks priority of category and tags filter to fit Chromium use cases:

  • specific > pattern > single char "*" wildcard (see b/260418655)
  • tags disabled > enabled: this is mostly useful for tags
    E.g. disabled_tags: "slow", enabled_tags: "navigation"
    Expectation: categories with "navigation" tags are enabled, but not if "slow" tag is specified.
  • Don't disable slow/debug tags if there are any explicitly enabled tags: there's otherwise no way of 'not' disabled slow and debug at the tags level
    E.g. enabled_tags: "navigation"
    Expectation: categories with "navigation" tags are enabled, including ones with the "slow" tag
    We can't specify enabled_tags: "slow" because that would enable all "slow" categories.

So before logic ranks (in this order):

  • specific names > patterns
  • enabled > disabled
  • categories > tags

After logic ranks:

  • specific > pattern > single char "*" wildcard
  • categories (enabled > disabled) > tags (disabled > enabled)

Bug: chromium:260418655

@etiennep-chromium etiennep-chromium requested a review from a team as a code owner May 7, 2025 14:31
@betasheet betasheet requested a review from ddiproietto May 7, 2025 14:38
@betasheet
Copy link
Member

I'm generally onboard with such a change, but I'm a bit scared if we are silently breaking some configs people already use. We would definitely have to announce this in the changelog, maybe do some form of audit of existing configs by major customers. @ddiproietto should take a look too :)

@betasheet
Copy link
Member

So before logic ranks (in this order):

  • specific names > patterns
  • enabled > disabled
  • categories > tags

After logic ranks:

  • specific > pattern > single char "*" wildcard
  • disabled > enabled
  • categories > tags

I think this is actually also swapping the last two lines, i.e.

  1. specific > pattern > single char "*" wildcard
  2. categories > tags
  3. disabled > enabled

@etiennep-chromium
Copy link
Contributor Author

disabled_categories: "some_categories*", enabled_categories: "some_categories_i_want_*"
Would mean some_categories_i_want_ categories stay disabled.

Expending on this: I don't have a strong opinion on how this should be interpreted, but I think the similar situation with tags I gave in the description (E.g. disabled_tags: "slow", enabled_tags: "navigation") should be interpreted as "navigation.debug" is disabled.
Then, for consistency, I applied the same logic on categories.
It would be easy to implement
enabled categories > disabled categories > disabled tags > enabled tags
But I doubt there's a real use case for this at the time.

@ddiproietto
Copy link
Contributor

Thanks for doing this!

Useless complaint: this still doesn't give us perfect control over tracing categories. An explicit priority based approach (iptables style) woud be more powerful, but perhaps not worth it, due to the complexity and performance (I believe NameMatchesPattern has to be reasonably fast for dynamic categories). So this is fine.

W.R.T. the breaking change, I think chromium is the more advanced user of this. (we cannot know all the users and all their configs, though). After review, I would announce the change on https://groups.google.com/g/perfetto-dev, and give people one week to complain. If we have no complaints, I would go ahead with this.

@ddiproietto
Copy link
Contributor

If you want to pile up another breaking change, I was thinking we could disable all categories that don't match anything by default. We had some discussions a year ago and people were generally on board. (totally up to you if you want to do this separately).

@ddiproietto
Copy link
Contributor

Also, can I ask you to check in a test like:

  auto* tracing_session = NewTraceWithCategories({"foo"});
  EXPECT_TRUE(TRACE_EVENT_CATEGORY_ENABLED("foo"));

that covers most of the scenarios in the bug, BEFORE submitting this PR? That way we can check what's changing?

Thanks!

@etiennep-chromium
Copy link
Contributor Author

If you want to pile up another breaking change, I was thinking we could disable all categories that don't match anything by default

I tried this out and it showed a lot of tests in perfetto need updating (they use the empty track event config). I'm a bit opposed to piling up this change because there's lower benefit (it's easy to add disable_categories = [*] everywhere), and risks blocking the API change I want to get in in this CL.

Also, can I ask you to check in a test like:

Done here: https://github.com/google/perfetto/pull/1484/files

etiennep-chromium added a commit that referenced this pull request May 13, 2025
This adds TrackEvent tests in preparation for API changes in
#1432

Bug: chromium:260418655
@etiennep-chromium etiennep-chromium requested a review from a team as a code owner May 13, 2025 19:48
@etiennep-chromium
Copy link
Contributor Author

After review, I would announce the change on https://groups.google.com/g/perfetto-dev, and give people one week to complain. If we have no complaints, I would go ahead with this.

Announce sent and CHANGELOG updated, PTAnL?

@etiennep-chromium etiennep-chromium enabled auto-merge (squash) June 2, 2025 17:04
@etiennep-chromium etiennep-chromium merged commit 394a187 into main Jun 2, 2025
27 of 33 checks passed
@etiennep-chromium etiennep-chromium deleted the dev/etiennep/tags branch June 2, 2025 18:27
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.

3 participants