Merge "Change experimental_flamegraph API." am: 42b4ebd694
Original change: https://android-review.googlesource.com/c/platform/external/perfetto/+/1869198
Change-Id: I14b3cfec0f3e6cd5e3ec2130983599fe05738b5f
diff --git a/docs/data-sources/java-heap-profiler.md b/docs/data-sources/java-heap-profiler.md
index 1187b7a..f67cf03 100644
--- a/docs/data-sources/java-heap-profiler.md
+++ b/docs/data-sources/java-heap-profiler.md
@@ -74,7 +74,10 @@
```sql
select name, cumulative_size
- from experimental_flamegraph(56785646801, 1, 'graph')
+ from experimental_flamegraph
+ where ts = 56785646801
+ and upid = 1
+ and profile_type = 'graph'
order by 2 desc;
```
diff --git a/docs/data-sources/native-heap-profiler.md b/docs/data-sources/native-heap-profiler.md
index 47c3122..56ef95c 100644
--- a/docs/data-sources/native-heap-profiler.md
+++ b/docs/data-sources/native-heap-profiler.md
@@ -566,9 +566,12 @@
```sql
select name, map_name, cumulative_size
- from experimental_flamegraph(8300973884377,1,'native')
+ from experimental_flamegraph
+ where ts = 8300973884377
+ and upid = 1
+ and profile_type = 'native'
order by abs(cumulative_size) desc;
-```
+```
| name | map_name | cumulative_size |
|------|----------|----------------|
diff --git a/src/trace_processor/importers/proto/flamegraph_construction_algorithms.cc b/src/trace_processor/importers/proto/flamegraph_construction_algorithms.cc
index 83dcc48..67184e5 100644
--- a/src/trace_processor/importers/proto/flamegraph_construction_algorithms.cc
+++ b/src/trace_processor/importers/proto/flamegraph_construction_algorithms.cc
@@ -139,8 +139,11 @@
// The 'ts' column is given a default value, taken from the query.
// So if the query is:
- // `select * form experimental_flamegraph(605908369259172, 1, 'native')`
- // then ts == 605908369259172
+ // `select * form experimental_flamegraph
+ // where ts = 605908369259172
+ // and upid = 1
+ // and profile_type = 'native'`
+ // then row.ts == 605908369259172, for all rows
// This is not accurate. However, at present there is no other
// straightforward way of assigning timestamps to non-leaf nodes in the
// flamegraph tree. Non-leaf nodes would have to be assigned >= 1
diff --git a/test/trace_processor/profiling/heap_graph_flamegraph.sql b/test/trace_processor/profiling/heap_graph_flamegraph.sql
index 92367f9..34692ef 100644
--- a/test/trace_processor/profiling/heap_graph_flamegraph.sql
+++ b/test/trace_processor/profiling/heap_graph_flamegraph.sql
@@ -8,8 +8,8 @@
size,
cumulative_size,
parent_id
-FROM experimental_flamegraph(
- (select max(graph_sample_ts) from heap_graph_object),
- (select max(upid) from heap_graph_object),
- 'graph')
+FROM experimental_flamegraph
+where upid = (select max(upid) from heap_graph_object)
+ and profile_type = 'graph'
+ and ts = (select max(graph_sample_ts) from heap_graph_object)
LIMIT 10
diff --git a/test/trace_processor/profiling/heap_graph_flamegraph_focused.sql b/test/trace_processor/profiling/heap_graph_flamegraph_focused.sql
index 95d498a..e6b514c 100644
--- a/test/trace_processor/profiling/heap_graph_flamegraph_focused.sql
+++ b/test/trace_processor/profiling/heap_graph_flamegraph_focused.sql
@@ -7,9 +7,9 @@
size,
cumulative_size,
parent_id
-FROM experimental_flamegraph(
- (select max(graph_sample_ts) from heap_graph_object),
- (select max(upid) from heap_graph_object),
- 'graph')
-WHERE focus_str = 'left'
+FROM experimental_flamegraph
+where upid = (select max(upid) from heap_graph_object)
+ and profile_type = 'graph'
+ and ts = (select max(graph_sample_ts) from heap_graph_object)
+ and focus_str = 'left'
LIMIT 10
diff --git a/test/trace_processor/profiling/heap_profile_flamegraph.sql b/test/trace_processor/profiling/heap_profile_flamegraph.sql
index fa90b15..e1feb37 100644
--- a/test/trace_processor/profiling/heap_profile_flamegraph.sql
+++ b/test/trace_processor/profiling/heap_profile_flamegraph.sql
@@ -1 +1,5 @@
-select * from experimental_flamegraph(605908369259172, 1, 'native') limit 10;
+select * from experimental_flamegraph
+where ts = 605908369259172
+ and upid = 1
+ and profile_type = 'native'
+limit 10;
diff --git a/ui/src/controller/flamegraph_controller.ts b/ui/src/controller/flamegraph_controller.ts
index 9fec1f5..cb7ea7e 100644
--- a/ui/src/controller/flamegraph_controller.ts
+++ b/ui/src/controller/flamegraph_controller.ts
@@ -384,8 +384,7 @@
// for each marker.
let focusRegexConditional = '';
if (focusRegex !== '') {
- const linkingWord = type === 'perf' ? 'and' : 'where';
- focusRegexConditional = `${linkingWord} focus_str = '${focusRegex}'`;
+ focusRegexConditional = `and focus_str = '${focusRegex}'`;
}
/*
@@ -410,8 +409,11 @@
`select id, name, map_name, parent_id, depth, cumulative_size,
cumulative_alloc_size, cumulative_count, cumulative_alloc_count,
size, alloc_size, count, alloc_count, source_file, line_number
- from experimental_flamegraph(${endNs}, ${upids[0]}, '${type}') ${
- focusRegexConditional}`);
+ from experimental_flamegraph
+ where profile_type = '${type}'
+ and ts = ${endNs}
+ and upid = ${upids[0]}
+ ${focusRegexConditional}`);
}
getMinSizeDisplayed(flamegraphData: CallsiteInfo[], rootSize?: number):