Repository navigation
ui: build BreakdownTracks counters with INTERVAL FLATTEN - #7787
gignat-dev wants to merge 6 commits into
Conversation
Replace the interval_self_intersect! segments table (one row per atomic segment and live interval, joined back on id) with one INTERVAL FLATTEN table per hierarchy level, partitioned by that level's breakdown columns. A node's counter is then a filter on its level's table; FLATTEN emits nothing over uncovered time, so the per-node query appends a 0 at the end of each run of segments to make the counter drop there. Intervals with dur = 0 are dropped (dur > 0 instead of >= 0): the macro counted them as 0, FLATTEN would count them over a zero-width segment. With that filter the counter step functions are identical to before. Measured on android_startup_real's slice table with 5 breakdown columns (314k rows): 32.5 s / 35.5M rows for the macro vs 0.6 s / 0.94M rows for the six FLATTEN tables. Enabled with PERFETTO PRAGMA pipelines = 1 at the start of the table-building batch.
Children of each binder counter are now ordered by their peak concurrent transaction count, busiest first (ties stay alphabetical), like the memory breakdowns already do. The ordering costs one GROUP BY over the next level's INTERVAL FLATTEN table per expand, a few ms at most.
🎨 Perfetto UI Builds & Tests
|
Drop the id column from the intervals table: FLATTEN keeps only ts, dur and the PER columns, and nothing else reads the table, so the column (and the ROW_NUMBER window pass behind it when no sliceIdColumn is set) was dead. Filter ts >= 0 instead of IS NOT NULL: FLATTEN rejects a negative ts, which would have failed the whole batch and with it every track of the instance. Document that valueCol must be an integer column, as FLATTEN only sums integers.
|
@LalitMaganti, two things to confirm:
|
That's fine.
Please make a UI wide global feature set when you first init trace processor. |
Run PERFETTO PRAGMA pipelines = 1 in loadTrace, after notifyEof / restoreInitialTables, instead of inside BreakdownTracks. The flag is per connection and restoreInitialTables rebuilds the connection, so this is the first point where it sticks for both the Wasm and the HTTP RPC engine. Any plugin can now use pipe syntax without setting it.
Done. Put it inside |
|
I feel like there's still a lot of complexity here, a lot more than I would ideally like. Why do you still need all the "level" machinery - can you not build it with one query instead of N queries now? |
Each level counts overlaps for a different grouping, so a parent can't be derived from its children's segments (they start and end at different times) — N levels of counters means N FLATTENs. I can make it one query though: UNION ALL the intervals once per level with a Same work, one table and one statement instead of N, and level is just a filter per node; Happy to do that if you prefer. |
Sure but isn't this what |
Yes, you're right. I should've used |
Replace the per-level segments tables with a single one: the intervals are replicated once per hierarchy level with a level column (deeper breakdown columns NULL) and flattened once with level as the first PER column, so every level's segments come out of one pass. A counter node pins its level as a plain filter next to its breakdown columns.
Every per-node counter query filters on level plus the breakdown columns above the node. With all levels in one table a plain scan touches every level's segments, so index on exactly those columns.
|
Thank you for the comments. Let me know if they were addressed correctly. |
|
Am I missing something? You still seem to be having most of the levels logic etc? Unless I"m wrong, none of that should be necessary. But I feel at this point I am missing something. |
Replaces the
interval_self_intersect!macro in BreakdownTracks (binder and memory breakdowns) with oneINTERVAL FLATTENtable per hierarchy level. A node's counter is a filter on its level's table, with a 0 appended at the end of each run of segments since FLATTEN emits nothing over uncovered time.Also turns on sortTracks for the binder breakdowns.
MAX aggregation is unavailable until FLATTEN supports it (no caller uses it).