BatchCoalescer: add a target batch size in bytes
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Find BatchCoalescer and its primitive and view builders in the Rust source; read how batches are sized, finished, and allocated, then trace the existing biggest_coalesce_batch_size bypass. Implement the optional byte target using the stated per-batch average row size and right-sized output buffers. Done means byte-targeted batches split as described, including oversized batches and single rows, while behavior without a target remains unchanged; add or run the relevant tests.
索引モデルが issue の本文から書いたものです。
説明
Is your feature request related to a problem or challenge?
BatchCoalescer completes an output batch at target_batch_size rows and has no notion of bytes. With wide rows that makes very large batches: 8,192 rows of 10,000 Float64 columns are 655 MB, and 8,192 rows that each hold a 100 KB list are about 800 MB. Operators downstream then have to buffer, sort or spill such a batch whole. DataFusion's sort reserves roughly twice a batch's size before buffering it, so one of these batches fails a memory-limited query that has plenty of room for the same rows in smaller batches.
A caller cannot fix this from outside. Lowering target_batch_size penalizes narrow rows, and the row width is not known before the data arrives and can change during a stream. Calling finish_buffered_batch early does cut a batch, but the primitive and view builders reserve target_batch_size values for every output batch and hand that capacity to the array, so a batch cut at 100 rows still holds buffers allocated for 8,192.
Describe the solution you'd like
An optional byte target next to the row target:
let coalescer = BatchCoalescer::new(schema, 8192)
.with_target_batch_bytes(Some(32 * 1024 * 1024));
With a target, an output batch is also completed once the rows buffered for it reach that many bytes. Each row counts as an equal share of the batch it arrived in (ArrayData::get_slice_memory_size divided by the row count), which costs one pass over the columns per pushed batch and nothing per row. A batch larger than the target is split instead of taking the biggest_coalesce_batch_size bypass, a single row larger than the target is a batch of its own, and each output batch's buffers are allocated for the rows it is expected to hold. Without a target nothing changes.
Describe alternatives you've considered
- A wrapper around
BatchCoalescerthat measures input batches and callsfinish_buffered_batch. It cannot avoid the full-size allocation described above, and it cannot split a filtered push without materializing it first. - Exact per-row sizes instead of the batch average. That is precise for rows of uneven size, but needs a pass over the offsets of every variable-width column, nested ones included. The average keeps the cost per batch and can be refined later.
- A re-chunking operator in the query engine (apache/datafusion#23390 proposed one for data sources). It bounds what one operator emits, but every operator that coalesces after it builds large batches again.
Additional context
DataFusion's filter, hash join, sort-merge join and nested loop join build their output through BatchCoalescer, so a target here gives each of them a byte bound with one builder call.
Willingness to contribute
I plan to contribute to this feature independently
- 主要言語
- Rust
- スター
- 3.7k
- フォーク
- 1.5k
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 183
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/arrow-rs のほかの issue
-
parquet: `ArrowWriter::try_new` panics on a schema with a Union field instead of returning an errorオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
`RunArray::try_new` rejects run ends whose null buffer has no nulls対応中かも @Surajsuthar が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/arrow-rs#12427 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Variant] `variant_get` string and binary cast errors show Rust builder type names再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 61/100
メンテナーはふだん 1 日以内に返信
apache/arrow-rs の issue をすべて見る
似ている issue
-
area:ui effort:medium enhancement P7 source:agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
marketing
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousオープンmaintainer-needed p2 remote triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug help wanted ui
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
userFRM/egui-charts#4605 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信