Skip to content

Add priority boost support for Perfetto.#2065

Merged
KirillTim merged 25 commits intomainfrom
dev/ktimofeev/priority_boost_v3
Jul 10, 2025
Merged

Add priority boost support for Perfetto.#2065
KirillTim merged 25 commits intomainfrom
dev/ktimofeev/priority_boost_v3

Conversation

@KirillTim
Copy link
Member

@KirillTim KirillTim commented Jul 8, 2025

This CL adds a support to boost priority for the traced and traced_probes processes.

When staring a tracing session it is now possible to configure the scheduling policy
and priority that should be used during the tracing session recording.
We have a separate configuration options for the traced process (in trace_config.proto)
and for the traced_probes process (in data_source_config.proto).

Priority boost requires the process to have a SYS_NICE capability, so in this PR we also
update the perfetto.rc file to enable this capability for traced and traced_probes
system daemons started by Android.

Tested:
To locally test Android Integration you need to do the follows:

  1. Pull this branch into the external/perfetto android subproject.
  2. Build the entire Android system, for the perfetto.rc and the perfetto system code to be
    build as part of the Android image.
  3. Flush the devices with the built system (or start the clutterfish emulator)
  4. Run the integration test on the device with atest: atest perfetto_integrationtests:PerfettoPriorityBoostIntegrationTest

To locally test the priority boost workflow without Android integration you can run
out/Default/perfetto_integrationtests --gtest_filter="*PerfettoPriorityBoostIntegrationTest*".

To run priority boost unit tests you can run
out/Default/perfetto_unittests '--gtest_filter=*ScopedSchedBoost*'

Bug: b/423561591

KirillTim added 2 commits July 8, 2025 01:59
This is part 2. DNS.

Priority boost: scoped_sched_boost.

This is part 1.
Copy link
Member

@primiano primiano left a comment

Choose a reason for hiding this comment

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

You reintroduced again a whole lotta complexity, which is what I tried to avoid, even showing you the code in dev/primiano/prioboost
I am not having this. please rewrite this CL without having all this complexity.
We are not wiritng a generalized library for os scheduling. we are writing a tiny class for boosting the priority.
Your test doesn't warrant all those classes. You are making the code more bug prone and harder to read for a test.
If you want to test without having CI capabilities, then add a tiny struct, which has IDENTICAL signatures to sched_getscheduler, so you can mock them in the test.

@KirillTim KirillTim marked this pull request as ready for review July 9, 2025 16:05
@KirillTim KirillTim requested a review from a team as a code owner July 9, 2025 16:05
@KirillTim KirillTim requested a review from primiano July 9, 2025 16:11
@KirillTim KirillTim changed the title WIP Priority boost implementation plus integration tests. Add priority boost support for Perfetto. Jul 10, 2025
Reset the 'SchedOsHooks' back to the system.
 This is needed when running multiple tests in one process.
@KirillTim KirillTim merged commit 694d051 into main Jul 10, 2025
20 checks passed
@KirillTim KirillTim deleted the dev/ktimofeev/priority_boost_v3 branch July 10, 2025 16:32
olehkuznetsov pushed a commit to olehkuznetsov/perfetto that referenced this pull request Mar 12, 2026
This CL adds a support to boost priority for the `traced` and
`traced_probes` processes.

When staring a tracing session it is now possible to configure the
scheduling policy
and priority that should be used during the tracing session recording.
We have a separate configuration options for the `traced` process (in
`trace_config.proto`)
and for the `traced_probes` process (in `data_source_config.proto`).

Priority boost requires the process to have a `SYS_NICE` capability, so
in this PR we also
update the `perfetto.rc` file to enable this capability for `traced` and
`traced_probes`
system daemons started by Android.

Tested:
To locally test Android Integration you need to do the follows:
1. Pull this branch into the `external/perfetto` android subproject.
2. Build the entire Android system, for the `perfetto.rc` and the
perfetto system code to be
    build as part of the Android image.
3. Flush the devices with the built system (or start the clutterfish
emulator)
4. Run the integration test on the device with atest: `atest
perfetto_integrationtests:PerfettoPriorityBoostIntegrationTest`

To locally test the priority boost workflow without Android integration
you can run
`out/Default/perfetto_integrationtests
--gtest_filter="*PerfettoPriorityBoostIntegrationTest*"`.

To run priority boost unit tests you can run
` out/Default/perfetto_unittests '--gtest_filter=*ScopedSchedBoost*'`

Bug: b/423561591
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.

2 participants