-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compute] map LIR to dataflow (#29848)
This PR introduces two new introspection sources and two new introspection views. These novel forms of introspection allow us to map LIR operators down to dataflow operators; we can now attribute existing introspection data about dataflows to LIR operators. # Introspection The two new sources are `ComputeLog` sources that run per worker. ## `mz_introspection.mz_compute_dataflow_global_ids_per_worker` Maps dataflow identifiers to the global IDs used internally for things that get built as dataflows. ``` name | nullable | type | comment -----------+----------+-------+--------- id | f | uint8 | dataflow ID worker_id | f | uint8 | global_id | f | text | ``` ## `mz_introspection.mz_compute_lir_mapping_per_worker` Tracks attribution information for LIR terms (in terms of `FlatPlan`). ``` name | nullable | type | comment -------------------+----------+-------+--------- global_id | f | text | lir_id | f | uint8 | AST node number worker_id | f | uint8 | operator | f | text | rendered string parent_lir_id | t | uint8 | parent AST node number nesting | f | uint2 | nesting (used for indentation) operator_id_start | t | uint8 | first dataflow operator (inclusive) operator_id_end | t | uint8 | last dataflow oeprator (exclusive) ``` ## Views We use two introspection views to work with these per-worker sources. It ought to be the case that all workers agree about _this_ metadata (though they may not agree on, say, the amount of memory a dataflow operator is using!). So: these are just views that set `worker_id = 0`. ### `mz_introspection.mz_dataflow_global_ids` ``` name | nullable | type | comment -----------+----------+-------+--------- id | f | uint8 | global_id | f | text | ``` ### `mz_introspection.mz_lir_mapping` ``` name | nullable | type | comment -------------------+----------+-------+--------- global_id | f | text | lir_id | f | uint8 | operator | f | text | parent_lir_id | t | uint8 | nesting | f | uint2 | operator_id_start | t | uint8 | operator_id_end | t | uint8 | ``` # Attributing to LIR We can see a sample interaction as follows: ```sql CREATE TABLE t(x INT NOT NULL, y INT, z TEXT); CREATE VIEW v AS SELECT t1.x AS x, t1.z AS z1, t2.z AS z2 FROM t AS t1, t AS t2 WHERE t1.x = t2.y; CREATE INDEX v_idx_x ON v(x); \! sleep 1 SELECT global_id, lir_id, REPEAT(' ', MAX(nesting) * 2) || operator AS operator, SUM(duration_ns) AS duration, SUM(count) AS count FROM mz_introspection.mz_lir_mapping mlm LEFT JOIN mz_introspection.mz_compute_operator_durations_histogram mcodh ON (mlm.operator_id_start <= mcodh.id AND mcodh.id < mlm.operator_id_end) GROUP BY global_id, lir_id, operator ORDER BY global_id, lir_id DESC; ``` which yields an output like: ``` global_id | lir_id | operator | duration | count -----------+--------+----------------------------+----------+------- u2 | 4 | Join::Differential 1 » 3 | 1261568 | 17 u2 | 3 | Arrange 2 | 466944 | 16 u2 | 2 | Get::Collection u1 | 69632 | 7 u2 | 1 | Arrange 0 | 417792 | 16 u2 | 0 | Get::Collection u1 | 73728 | 7 u3 | 6 | Arrange 5 | 454656 | 17 u3 | 5 | Get::PassArrangements u2 | | ``` ### Motivation * This PR adds a known-desirable feature. The first step in attribution/plan profiling. MaterializeInc/database-issues#6551
- Loading branch information
Showing
31 changed files
with
1,405 additions
and
376 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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
Oops, something went wrong.