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.5k
- 派生
- 2.5k
- 平均合并
- 4 天 14 小时
- 30 天内合并 PR
- 303
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/datafusion 的其他 Issue
-
[Bug] atan2 does not normalize -0.0 the way Spark does可能已有人在做 @spicysharkco 于 5 天前认领。 未关闭bug spark
难度 2/5 1-3 小时 新手友好度 72/100
apache/datafusion#26333 ·
维护者通常 1 天内回复
-
bug help wanted unparser
难度 2/5 1-3 小时 新手友好度 72/100
apache/datafusion#26316 · 1 条评论 ·
维护者通常 1 天内回复
-
Deduplicate bucket computation in width_bucket_interval_mdn_exact可能已有人在做 @Shahzeb-DataEngineer 于 2 天前认领。 未关闭enhancement good first issue help wanted spark tech debt
难度 2/5 1-3 小时 新手友好度 85/100
apache/datafusion#26307 · 3 条评论 ·
维护者通常 1 天内回复
-
Use the shared aggr_test_schema in CSV scan tests instead of a local copy可能已有人在做 @nishant4671 于 1 天前认领。 未关闭core enhancement good first issue help wanted tech debt
难度 2/5 1-3 小时 新手友好度 85/100
apache/datafusion#26306 · 2 条评论 ·
维护者通常 1 天内回复
-
Struct union type coercion takes field nullability from the wrong field when field order differs可能已有人在做 @med9110 于 6 天前认领。 未关闭bug help wanted logical-expr tech debt
难度 2/5 1-3 小时 新手友好度 68/100
apache/datafusion#26296 · 1 条评论 ·
维护者通常 1 天内回复
查看 apache/datafusion 的全部 Issue
相似的 Issue
-
corro-client drops the last byte of a response line that has no trailing newline可能已有人在做 @RaphaelFakhri 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
-
proxy: include denial_category in the "proxy request denied" log line可能已有人在做 @sreyas-endor 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
metasequoiaime/msime#9113 ·
维护者通常 1 天内回复
-
area:desktop priority:p2 type:chore
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
area: supply-chain
难度 1/5 1 小时以内 新手友好度 73/100
维护者通常 1 天内回复