lavanv11 opened a new pull request, #709: URL: https://github.com/apache/spark-connect-rust/pull/709
### What changes were proposed in this pull request? Consume native result rows as Python Rows are constructed, freeing each native payload immediately after conversion. Apply the ownership change to collect, first/head, take, and tail. Add 18 compatibility cases and a local memory benchmark that needs no Spark cluster. ### Why are the changes needed? Collection currently retains every native row while allocating the Python result, keeping both representations alive together. Large string and binary payloads therefore consume avoidable peak memory. Matched release builds, 131,072 rows × two 1,024-byte fields, 4,096 rows per Arrow batch: | Payload | Peak client RSS before → after | Wall time before → after | | --- | ---: | ---: | | String | 779.8 → 515.0 MiB (−34.0%) | 582 → 497 ms (−14.7%) | | Binary | 775.6 → 514.9 MiB (−33.6%) | 577 → 480 ms (−16.7%) | Medians of four fresh processes per build and payload, in ABBAABBA order, on the same Linux host with Python 3.12, identical dependencies and CPU affinity. Peak RSS includes client fixture setup and excludes the separate fixture server. A 524,288 × eight-long control was essentially unchanged (1.135 → 1.130 s). These are matched builds of public source snapshot `cdf38e8734619bf95aa9a0e6d12ed53240bb29ac`, with and without this ownership change; they are not measurements of current master. The original Python Row constructor is retained in both builds, so this result is independent of https://github.com/apache/spark-connect-rust/pull/665. ### Does this PR introduce _any_ user-facing change? Lower peak memory during collection; returned values and Row behavior are unchanged. Iterator and configuration-read behavior are unchanged. ### How was this patch tested? - Both matched builds passed 532 existing collection-focused cases plus all 18 new cases, with 8 skips and no failures. New cases cover empty, single-row and multi-batch results; heap-backed strings, binary data, nested Rows, nulls and pickle round trips across collect, first/head, take and tail. This is focused validation using the matching downstream test harness, not a full current-master test pass. - `cargo fmt --all --check`, `ruff check python/tests/test_dropin_offline.py scripts/benchmark_collect_memory.py`, and `ruff format --check scripts/benchmark_collect_memory.py` passed. - Reproducer, run once per fresh process with each Rust-backed client build activated: ```sh python scripts/benchmark_collect_memory.py --kind string python scripts/benchmark_collect_memory.py --kind binary ``` - Current-master Cargo execution checks remain pending: the local dependency source does not provide the locked `zstd-sys 2.1.3+zstd.1.5.7`. CI must validate the current upstream build before this draft is ready. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex (GPT-6). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
