Skip to content

Commit

Permalink
Merge "ui: tp: remove legacy derived events from trace processor" int…
Browse files Browse the repository at this point in the history
…o main
  • Loading branch information
LalitMaganti authored and Gerrit Code Review committed Oct 14, 2024
2 parents 436c1ec + e9ccb72 commit 4d39a15
Show file tree
Hide file tree
Showing 33 changed files with 33 additions and 899 deletions.
10 changes: 0 additions & 10 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -2783,7 +2783,6 @@ python_library_host {
"protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto",
"protos/perfetto/metrics/android/android_oom_adjuster_metric.proto",
"protos/perfetto/metrics/android/android_sysui_notifications_blocking_calls_metric.proto",
"protos/perfetto/metrics/android/android_trusty_workqueues.proto",
"protos/perfetto/metrics/android/anr_metric.proto",
"protos/perfetto/metrics/android/app_process_starts_metric.proto",
"protos/perfetto/metrics/android/auto_metric.proto",
Expand Down Expand Up @@ -2817,7 +2816,6 @@ python_library_host {
"protos/perfetto/metrics/android/monitor_contention_metric.proto",
"protos/perfetto/metrics/android/multiuser_metric.proto",
"protos/perfetto/metrics/android/network_metric.proto",
"protos/perfetto/metrics/android/other_traces.proto",
"protos/perfetto/metrics/android/package_list.proto",
"protos/perfetto/metrics/android/powrails_metric.proto",
"protos/perfetto/metrics/android/process_metadata.proto",
Expand Down Expand Up @@ -5419,7 +5417,6 @@ genrule {
"protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto",
"protos/perfetto/metrics/android/android_oom_adjuster_metric.proto",
"protos/perfetto/metrics/android/android_sysui_notifications_blocking_calls_metric.proto",
"protos/perfetto/metrics/android/android_trusty_workqueues.proto",
"protos/perfetto/metrics/android/anr_metric.proto",
"protos/perfetto/metrics/android/app_process_starts_metric.proto",
"protos/perfetto/metrics/android/auto_metric.proto",
Expand Down Expand Up @@ -5453,7 +5450,6 @@ genrule {
"protos/perfetto/metrics/android/monitor_contention_metric.proto",
"protos/perfetto/metrics/android/multiuser_metric.proto",
"protos/perfetto/metrics/android/network_metric.proto",
"protos/perfetto/metrics/android/other_traces.proto",
"protos/perfetto/metrics/android/package_list.proto",
"protos/perfetto/metrics/android/powrails_metric.proto",
"protos/perfetto/metrics/android/process_metadata.proto",
Expand Down Expand Up @@ -5515,7 +5511,6 @@ genrule {
"protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto",
"protos/perfetto/metrics/android/android_oom_adjuster_metric.proto",
"protos/perfetto/metrics/android/android_sysui_notifications_blocking_calls_metric.proto",
"protos/perfetto/metrics/android/android_trusty_workqueues.proto",
"protos/perfetto/metrics/android/anr_metric.proto",
"protos/perfetto/metrics/android/app_process_starts_metric.proto",
"protos/perfetto/metrics/android/auto_metric.proto",
Expand Down Expand Up @@ -5549,7 +5544,6 @@ genrule {
"protos/perfetto/metrics/android/monitor_contention_metric.proto",
"protos/perfetto/metrics/android/multiuser_metric.proto",
"protos/perfetto/metrics/android/network_metric.proto",
"protos/perfetto/metrics/android/other_traces.proto",
"protos/perfetto/metrics/android/package_list.proto",
"protos/perfetto/metrics/android/powrails_metric.proto",
"protos/perfetto/metrics/android/process_metadata.proto",
Expand Down Expand Up @@ -5595,7 +5589,6 @@ genrule {
"protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto",
"protos/perfetto/metrics/android/android_oom_adjuster_metric.proto",
"protos/perfetto/metrics/android/android_sysui_notifications_blocking_calls_metric.proto",
"protos/perfetto/metrics/android/android_trusty_workqueues.proto",
"protos/perfetto/metrics/android/anr_metric.proto",
"protos/perfetto/metrics/android/app_process_starts_metric.proto",
"protos/perfetto/metrics/android/auto_metric.proto",
Expand Down Expand Up @@ -5629,7 +5622,6 @@ genrule {
"protos/perfetto/metrics/android/monitor_contention_metric.proto",
"protos/perfetto/metrics/android/multiuser_metric.proto",
"protos/perfetto/metrics/android/network_metric.proto",
"protos/perfetto/metrics/android/other_traces.proto",
"protos/perfetto/metrics/android/package_list.proto",
"protos/perfetto/metrics/android/powrails_metric.proto",
"protos/perfetto/metrics/android/process_metadata.proto",
Expand Down Expand Up @@ -13128,7 +13120,6 @@ genrule {
"src/trace_processor/metrics/sql/android/android_multiuser_populator.sql",
"src/trace_processor/metrics/sql/android/android_netperf.sql",
"src/trace_processor/metrics/sql/android/android_oom_adjuster.sql",
"src/trace_processor/metrics/sql/android/android_other_traces.sql",
"src/trace_processor/metrics/sql/android/android_package_list.sql",
"src/trace_processor/metrics/sql/android/android_powrails.sql",
"src/trace_processor/metrics/sql/android/android_proxy_power.sql",
Expand All @@ -13139,7 +13130,6 @@ genrule {
"src/trace_processor/metrics/sql/android/android_sysui_notifications_blocking_calls_metric.sql",
"src/trace_processor/metrics/sql/android/android_task_names.sql",
"src/trace_processor/metrics/sql/android/android_trace_quality.sql",
"src/trace_processor/metrics/sql/android/android_trusty_workqueues.sql",
"src/trace_processor/metrics/sql/android/codec_metrics.sql",
"src/trace_processor/metrics/sql/android/composer_execution.sql",
"src/trace_processor/metrics/sql/android/composition_layers.sql",
Expand Down
4 changes: 0 additions & 4 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2267,7 +2267,6 @@ perfetto_filegroup(
"src/trace_processor/metrics/sql/android/android_multiuser_populator.sql",
"src/trace_processor/metrics/sql/android/android_netperf.sql",
"src/trace_processor/metrics/sql/android/android_oom_adjuster.sql",
"src/trace_processor/metrics/sql/android/android_other_traces.sql",
"src/trace_processor/metrics/sql/android/android_package_list.sql",
"src/trace_processor/metrics/sql/android/android_powrails.sql",
"src/trace_processor/metrics/sql/android/android_proxy_power.sql",
Expand All @@ -2278,7 +2277,6 @@ perfetto_filegroup(
"src/trace_processor/metrics/sql/android/android_sysui_notifications_blocking_calls_metric.sql",
"src/trace_processor/metrics/sql/android/android_task_names.sql",
"src/trace_processor/metrics/sql/android/android_trace_quality.sql",
"src/trace_processor/metrics/sql/android/android_trusty_workqueues.sql",
"src/trace_processor/metrics/sql/android/codec_metrics.sql",
"src/trace_processor/metrics/sql/android/composer_execution.sql",
"src/trace_processor/metrics/sql/android/composition_layers.sql",
Expand Down Expand Up @@ -4962,7 +4960,6 @@ perfetto_proto_library(
"protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto",
"protos/perfetto/metrics/android/android_oom_adjuster_metric.proto",
"protos/perfetto/metrics/android/android_sysui_notifications_blocking_calls_metric.proto",
"protos/perfetto/metrics/android/android_trusty_workqueues.proto",
"protos/perfetto/metrics/android/anr_metric.proto",
"protos/perfetto/metrics/android/app_process_starts_metric.proto",
"protos/perfetto/metrics/android/auto_metric.proto",
Expand Down Expand Up @@ -4996,7 +4993,6 @@ perfetto_proto_library(
"protos/perfetto/metrics/android/monitor_contention_metric.proto",
"protos/perfetto/metrics/android/multiuser_metric.proto",
"protos/perfetto/metrics/android/network_metric.proto",
"protos/perfetto/metrics/android/other_traces.proto",
"protos/perfetto/metrics/android/package_list.proto",
"protos/perfetto/metrics/android/powrails_metric.proto",
"protos/perfetto/metrics/android/process_metadata.proto",
Expand Down
30 changes: 0 additions & 30 deletions docs/analysis/trace-processor.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,36 +509,6 @@ TIP: To see how to add to add a new metric to trace processor, see the checklist
The metrics subsystem is a significant part of trace processor and thus is
documented on its own [page](/docs/analysis/metrics.md).

## Creating derived events

TIP: To see how to add to add a new annotation to trace processor, see the
checklist [here](/docs/contributing/common-tasks.md#new-annotation).

This feature allows creation of new events (slices and counters) from the data
in the trace. These events can then be displayed in the UI tracks as if they
were part of the trace itself.

This is useful as often the data in the trace is very low-level. While low
level information is important for experts to perform deep debugging, often
users are just looking for a high level overview without needing to consider
events from multiple locations.

For example, an app startup in Android spans multiple components including
`ActivityManager`, `system_server`, and the newly created app process derived
from `zygote`. Most users do not need this level of detail; they are only
interested in a single slice spanning the entire startup.

Creating derived events is tied very closely to
[metrics subsystem](/docs/analysis/metrics.md); often SQL-based metrics need to
create higher-level abstractions from raw events as intermediate artifacts.

From previous example, the
[startup metric](/src/trace_processor/metrics/sql/android/android_startup.sql)
creates the exact `launching` slice we want to display in the UI.

The other benefit of aligning the two is that changes in metrics are
automatically kept in sync with what the user sees in the UI.

## Python API
The trace processor's C++ library is also exposed through Python. This
is documented on a [separate page](/docs/analysis/trace-processor-python.md).
Expand Down
41 changes: 0 additions & 41 deletions docs/contributing/common-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,47 +138,6 @@ Here is an [example change](https://android-review.googlesource.com/c/platform/e
3. Run the newly added test with `tools/diff_test_trace_processor.py <path to trace processor shell binary>`.
4. Upload and land your change as normal.

## Adding new derived events

As derived events depend on metrics, the initial steps are same as that of developing a metric (see above).

NOTE: the metric can be just an empty proto message during prototyping or if no summarization is necessary. However, generally if an event is important enough to display in the UI, it should also be tracked in benchmarks as a metric.

To extend a metric with annotations:

1. Create a new table or view with the name `<metric name>_event`.
* For example, for the [`android_startup`]() metric, we create a view named `android_startup_event`.
* Note that the trailing `_event` suffix in the table name is important.
* The schema required for this table is given below.
2. List your metric in the `initialiseHelperViews` method of `trace_controller.ts`.
3. Upload and land your change as normal.

The schema of the `<metric name>_event` table/view is as follows:

| Name | Type | Presence | Meaning |
| :----------- | -------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `track_type` | `string` | Mandatory | 'slice' for slices, 'counter' for counters |
| `track_name` | `string` | Mandatory | Name of the track to display in the UI. Also the track identifier i.e. all events with same `track_name` appear on the same track. |
| `ts` | `int64` | Mandatory | The timestamp of the event (slice or counter) |
| `dur` | `int64` | Mandatory for slice, NULL for counter | The duration of the slice |
| `slice_name` | `string` | Mandatory for slice, NULL for counter | The name of the slice |
| `value` | `double` | Mandatory for counter, NULL for slice | The value of the counter |
| `group_name` | `string` | Optional | Name of the track group under which the track appears. All tracks with the same `group_name` are placed under the same group by that name. Tracks that lack this field or have NULL value in this field are displayed without any grouping. |

#### Known issues:

* Nested slices within the same track are not supported. We plan to support this
once we have a concrete usecase.
* Tracks are always created in the global scope. We plan to extend this to
threads and processes in the near future with additional contexts added as
necessary.
* Instant events are currently not supported in the UI but this will be
implemented in the near future. In trace processor, instants are always `0`
duration slices with special rendering on the UI side.
* There is no way to tie newly added events back to the source events in the
trace which were used to generate them. This is not currently a priority but
something we may add in the future.


## Update `TRACE_PROCESSOR_CURRENT_API_VERSION`

Expand Down
7 changes: 0 additions & 7 deletions docs/contributing/embedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,3 @@ Any registered metrics can be computed using using the `ComputeMetric` function.
Metrics can also be registered at run time using the `RegisterMetric` and `ExtendMetricsProto` functions. These can subsequently be executed with `ComputeMetric`.

WARNING: embedders should ensure that the path of any registered metric is consistent with the name used to execute the metric and output view in the SQL.

### Creating derived events

As creating derived events is tied to the metrics subsystem, the `ComputeMetrics` function in the trace processor API should be called with the appropriate metrics. This will create the `<metric_name>_event` table/view which can then be queried using the `ExectueQuery` function.

NOTE: At some point, there are plans to add an API which does not create the metrics proto but just executes the queries in the metric.

2 changes: 0 additions & 2 deletions protos/perfetto/metrics/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ perfetto_proto_library("@TYPE@") {
"android_garbage_collection_unagg_metric.proto",
"android_oom_adjuster_metric.proto",
"android_sysui_notifications_blocking_calls_metric.proto",
"android_trusty_workqueues.proto",
"anr_metric.proto",
"app_process_starts_metric.proto",
"auto_metric.proto",
Expand Down Expand Up @@ -66,7 +65,6 @@ perfetto_proto_library("@TYPE@") {
"monitor_contention_metric.proto",
"multiuser_metric.proto",
"network_metric.proto",
"other_traces.proto",
"package_list.proto",
"powrails_metric.proto",
"process_metadata.proto",
Expand Down
22 changes: 0 additions & 22 deletions protos/perfetto/metrics/android/android_trusty_workqueues.proto

This file was deleted.

25 changes: 0 additions & 25 deletions protos/perfetto/metrics/android/other_traces.proto

This file was deleted.

12 changes: 6 additions & 6 deletions protos/perfetto/metrics/metrics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import "protos/perfetto/metrics/android/mem_metric.proto";
import "protos/perfetto/metrics/android/mem_unagg_metric.proto";
import "protos/perfetto/metrics/android/multiuser_metric.proto";
import "protos/perfetto/metrics/android/network_metric.proto";
import "protos/perfetto/metrics/android/other_traces.proto";
import "protos/perfetto/metrics/android/package_list.proto";
import "protos/perfetto/metrics/android/powrails_metric.proto";
import "protos/perfetto/metrics/android/profiler_smaps.proto";
Expand All @@ -67,7 +66,6 @@ import "protos/perfetto/metrics/android/startup_metric.proto";
import "protos/perfetto/metrics/android/surfaceflinger.proto";
import "protos/perfetto/metrics/android/task_names.proto";
import "protos/perfetto/metrics/android/trace_quality.proto";
import "protos/perfetto/metrics/android/android_trusty_workqueues.proto";
import "protos/perfetto/metrics/android/unsymbolized_frames.proto";
import "protos/perfetto/metrics/android/binder_metric.proto";
import "protos/perfetto/metrics/android/monitor_contention_metric.proto";
Expand Down Expand Up @@ -251,11 +249,13 @@ message TraceMetrics {
// Metrics for IRQ runtime.
optional AndroidIrqRuntimeMetric android_irq_runtime = 43;

// Metrics for the Trusty team.
optional AndroidTrustyWorkqueues android_trusty_workqueues = 44;
// Was metrics for the Trusty team.
reserved 44;
reserved 'android_trusty_workqueues';

// Summary of other concurrent trace recording.
optional AndroidOtherTracesMetric android_other_traces = 45;
// Was summary of concurrent trace recording.
reserved 45;
reserved 'android_other_traces';

// Per-process Binder transaction metrics.
optional AndroidBinderMetric android_binder = 46;
Expand Down
Loading

0 comments on commit 4d39a15

Please sign in to comment.