Perf: add in-process timing instrumentation to replace py-spy dependency
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 46/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
- 领域
- performance
调研方向
Start by reading read_xarray_table and _iteration_callback in the reader, then inspect perf_tests/profile.sh and perf_tests/query_large_synthetic.py to understand the current profiling workflow. Choose and implement a timing approach that reports per-partition costs across the relevant execution stages. Confirm the measurements distinguish I/O, conversion, and DataFusion work without requiring py-spy or root access.
由索引模型根据 Issue 内容生成。
描述
Problem
The current profiling workflow in perf_tests/ requires py-spy, which needs sudo on macOS:
sudo ./profile.sh groupby_air_full.py
This makes profiling unavailable in many CI environments and for users without root access. Additionally, cProfile only sees the Python side of query execution — the entire DataFusion execution appears as a single opaque to_arrow_table() call (0.66s for 320 MB of data in our benchmarks), making it impossible to distinguish:
- Time spent in xarray I/O (
ds.isel(block),.values) - Time spent in numpy → Arrow conversion (
iter_record_batches) - Time spent in DataFusion (aggregation, hash-grouping, row filtering)
- Time spent waiting for GIL between partitions
Proposed solution
Add a lightweight per-partition timing mode to the _iteration_callback mechanism already in read_xarray_table:
# reader.py — extend make_stream to record timing
def make_stream(projected_names=None) -> pa.RecordBatchReader:
if _timing_callback is not None:
t0 = time.perf_counter()
result = pa.RecordBatchReader.from_batches(...)
if _timing_callback is not None:
_timing_callback({"elapsed_s": time.perf_counter() - t0, "block": block})
return result
Or alternatively: add a verbose=True flag to read_xarray_table that prints per-partition timings to stderr, giving insight into whether execution is I/O-bound or compute-bound without requiring external tools.
A lower-overhead option is to expose a PartitionTimingHook via LazyArrowStreamTable that fires before/after each factory call.
Current profiling workaround
For the query_large_synthetic.py benchmark (320 MB, 8 partitions):
Full scan AVG: 0.662s (341 MB peak) ← all in Rust's to_arrow_table()
Filter pushdown: 0.005s (0.7 MB peak) ← 7/8 partitions pruned
GROUP BY lat/lon: 0.839s (341 MB peak) ← +27% vs. AVG for hash aggregation
cProfile shows 246 Python calls for the full scan, but 0.660s of those are attributed to {method 'to_arrow_table' of 'datafusion.DataFrame' objects} — a Rust builtin that cProfile cannot introspect.
Related
_iteration_callbackinXarrayRecordBatchReaderandread_xarray_table— already used for testingperf_tests/profile.sh— current py-spy based approachperf_tests/query_large_synthetic.py— new benchmark script added alongside this issue
- 主要语言
- Python
- 星标
- 142
- 派生
- 19
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
xqlsystems/xarray-sql 的其他 Issue
-
documentation
难度 1/5 1-3 小时 新手友好度 85/100
xqlsystems/xarray-sql#268 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 64/100
xqlsystems/xarray-sql#267 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 74/100
xqlsystems/xarray-sql#243 ·
维护者通常 1 天内回复
-
publish.yml: the TestPyPI verification step is unreachable (and installs the wrong package name)未关闭
难度 2/5 1-3 小时 新手友好度 62/100
xqlsystems/xarray-sql#242 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
xqlsystems/xarray-sql#237 ·
维护者通常 1 天内回复
查看 xqlsystems/xarray-sql 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
anchore/grype-db#1149 · 1 条评论 ·
维护者通常 1 天内回复
-
[Bug]: `hermes plugins update` clones an entire monorepo twice - `subdir` is resolved but dropped at both catalog-update call sites可能已有人在做 @HootRock 今天认领。 未关闭comp/cli P2 type/perf
难度 2/5 1-3 小时 新手友好度 72/100
NousResearch/hermes-agent#142417 · 2 条评论 ·
维护者通常 1 天内回复
-
SMC SPEC
难度 2/5 1-3 小时 新手友好度 70/100
tenstorrent/tt-oca-harness#3287 ·
维护者通常 1 天内回复
-
bug enhancement python
难度 2/5 1-3 小时 新手友好度 85/100
DewaldOosthuizen/tech-cheat-sheets-and-notes#392 ·
维护者通常 1 天内回复
-
security
难度 2/5 1-3 小时 新手友好度 72/100
fabriziosalmi/wildbox#801 ·
维护者通常 1 天内回复