Skip to content

AIBench: Memory profiling on Android 10+ devices using Perfetto #484

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

KarlSimonsen
Copy link

Summary:
Use perfetto (built into all Android devices from os 10 on) to generate a native heap profile for analysis.

This feature extends the existing SimplePerf cpu-profiling feature by adding a type (cpu vs memory) and optional options field to the config / AIBenchAPI.

Options may need to be specified to get useful results for a given benchmark type. Also, results are more interesting on devices running Android OS 12 or at least 11. It does not work at all on devices running less than Android OS 10.

For now, we substitute a perfetto_config file for the perfetto_report link instead of the intended flamegraph output link.

Output can be observed by downloading the perfetto_data link and importing it into https://ui.perfetto.dev.

Caveats:

  1. Currently, the Perfetto Report link does not bring up the flamegraph directly. See workaround under test cases.
  2. More tuning is needed on the default profile options based on the run size and duration.
  3. User guidance needs to be documented for how to override the default options when necessary.

AIBenchAPI changes:

Amended the existing aibenchAPI profile argument to use a single bool || dict argument.

For example, for a test case below, here is the input:

profile={
          "profiler": "perfetto",
          "types": ["memory"],
          "options": {
            "shmem_size_bytes": "33554432",
            "sampling_interval_bytes": "2048",
            "buffer_size_kb": "262144",
            "buffer_size2_kb": "2048",
            "max_file_size_bytes": "200000000"
          }
        }

And here is what this translates to in the benchmark_config:

          "profiler": {
            "enabled": true,
            "profiler": "perfetto",
            "types": [
              "memory"
            ],
            "options": {
              "shmem_size_bytes": "33554432",
              "sampling_interval_bytes": "2048",
              "buffer_size_kb": "262144",
              "buffer_size2_kb": "2048",
              "max_file_size_bytes": "200000000"
            }
          }

In this case, the profiler flavor is redundant since if left unspecified, it will default to "perfetto" unless "cpu" (or nothing) is specified for types.

For simpleperf profiling, this argument can simply be

profile=True

or

profile={
          "types": ["cpu"]
}

or

profile={
          "profiler": "simpleperf"
}

Reviewed By: axitkhurana

Differential Revision: D31508439

Karl Simonsen added 2 commits March 31, 2022 11:43
Summary:
Pull Request resolved: facebook#483

Add large timeout to main Benchmark runs

Differential Revision: D35197481

fbshipit-source-id: 3e9ba606ecee543c6ad1c68e12abb1aefd7132fe
Summary:
Use perfetto (built into all Android devices from os 10 on) to generate a native heap profile for analysis.

This feature extends the existing SimplePerf cpu-profiling feature by adding a type (cpu vs memory) and optional options field to the config / AIBenchAPI.

Options may need to be specified to get useful results for a given benchmark type. Also, results are more interesting on devices running Android OS 12 or at least 11. It does not work at all on devices running less than Android OS 10.

For now, we substitute a perfetto_config file for the perfetto_report link instead of the intended flamegraph output link.

Output can be observed by downloading the perfetto_data link and importing it into https://ui.perfetto.dev.

__Caveats__:
1. Currently, the Perfetto Report link does not bring up the flamegraph directly. See workaround under test cases.
2. More tuning is needed on the default profile options based on the run size and duration.
3. User guidance needs to be documented for how to override the default options when necessary.

__AIBenchAPI changes__:

Amended the existing aibenchAPI profile argument to use a single bool || dict argument.

For example, for a test case below, here is the input:
```
profile={
          "profiler": "perfetto",
          "types": ["memory"],
          "options": {
            "shmem_size_bytes": "33554432",
            "sampling_interval_bytes": "2048",
            "buffer_size_kb": "262144",
            "buffer_size2_kb": "2048",
            "max_file_size_bytes": "200000000"
          }
        }
```
And here is what this translates to in the benchmark_config:
```
          "profiler": {
            "enabled": true,
            "profiler": "perfetto",
            "types": [
              "memory"
            ],
            "options": {
              "shmem_size_bytes": "33554432",
              "sampling_interval_bytes": "2048",
              "buffer_size_kb": "262144",
              "buffer_size2_kb": "2048",
              "max_file_size_bytes": "200000000"
            }
          }
```

In this case, the profiler flavor is redundant since if left unspecified, it will default to "perfetto" unless "cpu" (or nothing) is specified for types.

For simpleperf profiling, this argument can simply be
```
profile=True
```
or
```
profile={
          "types": ["cpu"]
}
```
or
```
profile={
          "profiler": "simpleperf"
}
```

Reviewed By: axitkhurana

Differential Revision: D31508439

fbshipit-source-id: fa1b9b56239e28e8d625fc3916c49700b99f28bb
@facebook-github-bot
Copy link

This pull request was exported from Phabricator. Differential Revision: D31508439

@facebook-github-bot
Copy link

Hi @KarlSimonsen!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants