BaselineMetrics output_bytes converts every column to ArrayData for every batch
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
- 領域
- performance
調査の方向性
datafusion/physical-expr-common/src/metrics/baseline.rsから始め、RecordOutput::record_outputとget_record_batch_memory_sizeを読み、output_bytesがどのように記録されるかを確認します。提案されているArray::get_array_memory_sizeのアプローチを、既存の共有バッファの計上方法と比較してください。出力バイトの記録時に列がArrayDataに変換されなくなり、メモリ計上には引き続きget_record_batch_memory_sizeを利用できる状態が完了条件です。
索引モデルが issue の本文から書いたものです。
説明
Is your feature request related to a problem or challenge?
Every operator's BaselineMetrics records output_bytes for every output batch through RecordOutput::record_output (datafusion/physical-expr-common/src/metrics/baseline.rs), which calls get_record_batch_memory_size. That function converts each column, and each child of a nested column, to ArrayData and inserts every buffer's address into a HashSet, so that buffers shared between columns are counted once. Exact accounting matters for memory reservations; for a per-batch metric it is a cost every query pays, and it grows with the width and nesting of the schema rather than with the data.
Measured on main (c0e872f), release build, Apple M1 Max, one batch of Int32 struct columns:
| batch | get_record_batch_memory_size |
sum of Array::get_array_memory_size |
|---|---|---|
| 35 struct columns x 20 fields, 100 rows | 21.9 µs | 1.6 µs |
| 35 struct columns x 20 fields, 4,000 rows | 15.1 µs | 1.5 µs |
| 5 struct columns x 5 fields, 4,000 rows | 0.58 µs | 0.05 µs |
That is per operator per batch. We hit it running one wide plan repeatedly (a game's world, 35 struct columns, a few thousand rows, a few hundred operators, through Sail on DataFusion 55.1): in a sampled profile, BaselineMetrics::record_poll -> get_record_batch_memory_size -> StructArray::to_data was about 12% of executing the plan, and computing the metric as below took a run from 40 ms to 34 ms.
Describe the solution you'd like
Compute output_bytes without ArrayData, for example:
fn output_bytes(batch: &RecordBatch) -> usize {
batch.columns().iter().map(|c| c.get_array_memory_size()).sum()
}
This can count a buffer shared between columns more than once (in the table above it reports 350,840 bytes against 280,000 for the 100-row batch, which shares nothing; the difference is the arrays' own structures), which seems acceptable for a metric; get_record_batch_memory_size would stay for memory accounting. Alternatively, output_bytes could be computed only when a metrics level that shows it is requested.
Describe alternatives you've considered
Making get_record_batch_memory_size itself cheaper for nested arrays (walking the arrays' buffers without building ArrayData) would help memory accounting too, but keeps the hash set per batch.
Additional context
Related: #26065 (struct literal comparisons through ArrayData in physical planning) and the planning-speed work in #19795.
- 主要言語
- Rust
- スター
- 9.4k
- フォーク
- 2.5k
- 平均マージ
- 4日 5時間
- マージ済み PR(30日)
- 331
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/datafusion#26259 ·
メンテナーはふだん 1 日以内に返信
-
`array_concat` with an untyped `NULL` argument fails with "does not support type Int64"対応中かも @RishavTiwari25 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
apache/datafusion#26243 ·
メンテナーはふだん 1 日以内に返信
-
array_min / array_max fail on a zero-row batch for non-primitive element types対応中かも @linuxpi が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/datafusion#26072 ·
メンテナーはふだん 1 日以内に返信
-
Replace manual `RowSelection` bitmap conversion with `force_mask()` after arrow-rs release対応中かも @isabellehuangg が 8 日前に担当しました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/datafusion#26030 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Lambda examples in the SQL function docs fail with the default dialect対応中かも @Prajwal-k-tech が 9 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
apache/datafusion#25960 ·
メンテナーはふだん 1 日以内に返信
apache/datafusion の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
cmlarsen/writemorebetter#158 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
state:triage-needed
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
scanaislop/aislop#482 ·
メンテナーはふだん 1 日以内に返信
-
docs(skills): issue-first should reference an existing Linear ticket instead of filing a duplicateオープンdocumentation
難易度 1/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信