NVIDIA / NVIDIA/cudf

[FEA] Add mechanism to print annotated physical plan

Open
#21,367 2 comments 0 reactions 0 assignees View on GitHub
cudf-polars feature request rapids-mpf
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

We need a utility that converts the structlog trace of a cudf-polars utility into an annotated physical plan. We need this for dynamic planning to inspect what happened during execution.

- Part of https://github.com/rapidsai/cudf/issues/20482
- Follow up to https://github.com/rapidsai/cudf/issues/21244, and (probably) related to https://github.com/rapidsai/cudf/pull/21315

**Example**

I put together an example of what we need in https://github.com/rjzamora/cudf/tree/dynamic-planning-on-structlog/python/cudf_polars/cudf_polars/experimental/benchmarks/explain_trace

For example, I can run through the queries at sf300 on this `dynamic-planning-on-structlog` branch:

```
rm pdsh_results.jsonl; CUDF_POLARS_LOG_TRACES=1 CUDF_POLARS_LOG_TRACES_DATAFRAMES=0 CUDF_POLARS_LOG_TRACES_MEMORY=0 python -m cudf_polars.experimental.benchmarks.pdsh --path $DATA_DIR --rmm-async --spill-device 0.8 --cluster distributed --runtime rapidsmpf --max-io-threads 4 --blocksize 1_000_000_000 --broadcast-join-limit 4 --n-workers 4 --iteration 1 --no-native-parquet --dynamic-planning --collect-traces all
```

Then I can use the `cudf_polars.experimental.benchmarks.explain_trace` utility to see what query plans are available:

```
$ python -m cudf_polars.experimental.benchmarks.explain_trace pdsh_results.jsonl -l
Available queries with traces:
Query 1, Iteration 0: 3.267s [has plan]
Query 2, Iteration 0: 0.902s [has plan]
Query 3, Iteration 0: 2.965s [has plan]
Query 4, Iteration 0: 1.418s [has plan]
Query 5, Iteration 0: 2.972s [has plan]
Query 6, Iteration 0: 1.625s [has plan]
Query 7, Iteration 0: 4.031s [has plan]
Query 8, Iteration 0: 3.944s [has plan]
Query 9, Iteration 0: 4.665s [has plan]
Query 10, Iteration 0: 3.609s [has plan]
Query 11, Iteration 0: 0.729s [has plan]
Query 12, Iteration 0: 1.988s [has plan]
Query 13, Iteration 0: 2.585s [has plan]
Query 14, Iteration 0: 2.143s [has plan]
Query 15, Iteration 0: 2.134s [has plan]
Query 16, Iteration 0: 1.143s [has plan]
Query 17, Iteration 0: 1.866s [has plan]
Query 18, Iteration 0: 1.997s [has plan]
Query 19, Iteration 0: 3.100s [has plan]
Query 20, Iteration 0: 2.939s [has plan]
Query 21, Iteration 0: 6.400s [has plan]
Query 22, Iteration 0: 0.529s [has plan]
```

And I can print an annotated plan:
```
python -m cudf_polars.experimental.benchmarks.explain_trace pdsh_results.jsonl -q 9
Query 9, Iteration 0
========================================
SORT [rows=175, chunks=1, time=4.1ms, workers=4, duplicated]
REPARTITION [rows=175, chunks=1, workers=4, duplicated]
SELECT [rows=175, chunks=1, time=1.2ms, workers=4, duplicated]
GROUPBY [rows=700, chunks=4, time=38ms, decision=tree_allgather, workers=4]
SELECT [rows=98M, chunks=8, time=33ms, workers=4]
PROJECTION [rows=98M, chunks=8, time=2.4e+02us, workers=4]
JOIN [rows=98M, chunks=8, time=1.2e+02ms, decision=broadcast_right, workers=4]
PROJECTION [rows=98M, chunks=8, time=2.2e+02us, workers=4]
JOIN [rows=98M, chunks=8, time=4e+02ms, decision=shuffle, workers=4]
PROJECTION [rows=98M, chunks=84, time=3.4ms, workers=4]
JOIN [rows=98M, chunks=84, time=2.4s, decision=broadcast_left, workers=4]
JOIN [rows=13M, chunks=6, time=34ms, decision=broadcast_right, workers=4]
JOIN [rows=13M, chunks=6, time=78ms, decision=broadcast_left, workers=4]
SCAN [rows=3.3M, chunks=3, time=1.2s, workers=4]
SCAN [rows=2.4e+02M, chunks=5, time=1.5s, workers=4]
SCAN [rows=3M, chunks=1, time=1.5e+02ms, workers=4]
SCAN [rows=1.8B, chunks=84, time=13s, workers=4]
SCAN [rows=4.5e+02M, chunks=5, time=1.5s, workers=4]
SCAN [rows=25, chunks=1, time=5.1ms, workers=4]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.