-
Notifications
You must be signed in to change notification settings - Fork 695
Add redacted traces PerfettoSQL module #4790
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
edgararriagag
merged 6 commits into
main
from
dev/edgararriagag/ea_add_redactor_stdlib_module
Feb 17, 2026
+156
−0
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9f22566
Add redacted traces PerfettoSQL module
edgararriagag 3a620b5
Merge branch 'main' into ea_add_redactor_stdlib_module
edgararriagag 74cfda8
Rewrite generate slices query to be more optimal and easier to read
edgararriagag 3574e42
Remove no longer necessary function and make private generate slices …
edgararriagag d8946cf
Rename redacted module to profiling_manager to better express the intent
edgararriagag cdbb919
Add profiling manager prefix to cold start table and improve docs
edgararriagag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/trace_processor/perfetto_sql/stdlib/android/profiling_manager/BUILD.gn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Copyright (C) 2026 The Android Open Source Project | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import("../../../../../../gn/perfetto_sql.gni") | ||
|
|
||
| perfetto_sql_source_set("profiling_manager") { | ||
| sources = [ | ||
| "startup.sql", | ||
| "util.sql", | ||
| ] | ||
| } | ||
52 changes: 52 additions & 0 deletions
52
src/trace_processor/perfetto_sql/stdlib/android/profiling_manager/startup.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| -- | ||
| -- Copyright 2026 The Android Open Source Project | ||
| -- | ||
| -- Licensed under the Apache License, Version 2.0 (the "License"); | ||
| -- you may not use this file except in compliance with the License. | ||
| -- You may obtain a copy of the License at | ||
| -- | ||
| -- https://www.apache.org/licenses/LICENSE-2.0 | ||
| -- | ||
| -- Unless required by applicable law or agreed to in writing, software | ||
| -- distributed under the License is distributed on an "AS IS" BASIS, | ||
| -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| -- See the License for the specific language governing permissions and | ||
| -- limitations under the License. | ||
|
|
||
| INCLUDE PERFETTO MODULE android.profiling_manager.util; | ||
|
|
||
| -- Provides cold startups for redacted traces | ||
| -- Note: Redacted traces contain a subset of slices compare to a regular perfetto trace as they contain information only about the process | ||
| -- starting its own profiling, thus, queries in this section may omit process information as its assumed that slices belong | ||
| -- to the single profiled process. | ||
| CREATE PERFETTO TABLE android_profiling_manager_cold_startup ( | ||
| -- Initial timestamp for startup from apps perspective | ||
| ts TIMESTAMP, | ||
| -- slice name to identify the startup | ||
| name STRING, | ||
| -- duration in nanoseconds | ||
| dur DURATION, | ||
| -- Checkpoint where startup is marked as finished. Two cases: | ||
| -- TTFF (Time to first frame): Startup marked as finished after first frame done | ||
| -- TTI (Time to interactive): Startup marked as finished after app calls Activity#reportFullyDrawn() | ||
| startup_checkpoint STRING | ||
| ) AS | ||
| WITH | ||
| startups AS ( | ||
| SELECT | ||
| ts, | ||
| 'app_startup_ttff' AS name, | ||
| dur, | ||
| 'TTFF' AS startup_checkpoint | ||
| FROM _android_generate_start_to_end_slices('bindApplication', 'Choreographer#doFrame [0-9]*', TRUE) | ||
| UNION ALL | ||
| SELECT | ||
| ts, | ||
| 'app_startup_tti' AS name, | ||
| dur, | ||
| 'TTI' AS startup_checkpoint | ||
| FROM _android_generate_start_to_end_slices('bindApplication', 'reportFullyDrawn*', TRUE) | ||
| ) | ||
| SELECT | ||
| * | ||
| FROM startups; |
55 changes: 55 additions & 0 deletions
55
src/trace_processor/perfetto_sql/stdlib/android/profiling_manager/util.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| -- | ||
| -- Copyright 2026 The Android Open Source Project | ||
| -- | ||
| -- Licensed under the Apache License, Version 2.0 (the "License"); | ||
| -- you may not use this file except in compliance with the License. | ||
| -- You may obtain a copy of the License at | ||
| -- | ||
| -- https://www.apache.org/licenses/LICENSE-2.0 | ||
| -- | ||
| -- Unless required by applicable law or agreed to in writing, software | ||
| -- distributed under the License is distributed on an "AS IS" BASIS, | ||
| -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| -- See the License for the specific language governing permissions and | ||
| -- limitations under the License. | ||
|
|
||
| -- Returns an artificially generated slice for each pair of (matched(startSlicePattern), matched(endSlicePattern)) | ||
| -- Caveat: If multiple slices match endSlicePattern it will only return one per start slice and it will be closest slice in the timeline. | ||
| CREATE PERFETTO FUNCTION _android_generate_start_to_end_slices( | ||
| -- GLOB pattern to find the start slices | ||
| start_pattern STRING, | ||
| -- GLOB pattern to find the matching end slice for each slice matched by startSlicePattern | ||
| end_pattern STRING, | ||
| -- Whether the generated slice should include the duration of the end slice or not | ||
| inclusive BOOL | ||
| ) | ||
| RETURNS TABLE ( | ||
| -- slice name | ||
| name STRING, | ||
| -- slice timestamp | ||
| ts LONG, | ||
| -- slice duration in nanoseconds | ||
| dur LONG | ||
| ) AS | ||
| SELECT | ||
| s.name, | ||
| s.ts, | ||
| -- Calculate duration by looking ahead for the nearest end slice | ||
| ( | ||
| SELECT | ||
| e.ts + iif($inclusive, e.dur, 0) | ||
| FROM slice AS e | ||
| WHERE | ||
| e.name GLOB $end_pattern | ||
| -- Ensure the end slice occurs after the start slice | ||
| -- Ensure the end slice occurs after the start slice | ||
| AND e.ts > s.ts | ||
| ORDER BY | ||
| e.ts ASC | ||
| LIMIT 1 | ||
| ) - s.ts AS dur | ||
| FROM slice AS s | ||
| WHERE | ||
| s.name GLOB $start_pattern | ||
| -- Filter out start slices that did not find a matching end slice (where dur becomes NULL) | ||
| AND dur IS NOT NULL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 4c0997d6021f94f94fe9dc495b43a047471aff79f8d43a0fe3132998b03c2dc8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.