KushShriv opened a new pull request, #13755:
URL: https://github.com/apache/gluten/pull/13755
## What changes are proposed in this pull request?
This change is stacked on the untracked-allocator change (the first commit
of this branch), which stops operators from reserving Spark memory again for
Arrow batches they load from native batches. `ColumnarArrowEvalPythonExec`
couldn't use it. It took Java Arrow batches (`LoadArrowDataExec` below it),
joined the cached input columns with the Python results into one Java batch,
and emitted that (`OffloadArrowDataExec` above it). Arrow can't load buffers
from two allocator roots into one `VectorSchemaRoot`, so the loaded batches
stayed in the task allocator, and their memory was reserved twice.
Only the last commit is new here. `ColumnarArrowEvalPythonExec` now takes
and produces Velox batches, like `ColumnarPartialProjectExec`:
- **Input**: retains each input batch and loads only the columns the UDFs
read (`ColumnarBatches.select`), into
`ArrowBufferAllocators.contextUntrackedInstance()`. The runner closes them once
they're written to the Python worker. Before, every input column was loaded and
kept until the result came back.
- **Output**: offloads the Python results and merges them into the retained
input batch natively (`VeloxColumnarBatches.compose`), so the input columns
never leave Velox. Each input batch is released once its result is merged.
Before, all input batches of a partition were held until the partition ended.
The row-count check on the UDF result is kept and now also closes the output
batch and releases the input on failure.
- **No Arrow transitions around the UDF**: the plan goes from `Velox op →
LoadArrowData → ColumnarArrowEvalPython → OffloadArrowData →
ArrowColumnarToVeloxColumnar → Velox op` to `Velox op → ColumnarArrowEvalPython
→ Velox op`.
- **`ColumnarArrowPythonRunner`**:
- The writer serializes each input batch directly (`MessageSerializer`),
instead of loading it into a `VectorSchemaRoot` of the task allocator, which
fails across allocator roots.
- The reader moves each result batch's buffers into new vectors (a
transfer within the same allocator, no copy), so the batch owns them. It no
longer reuses the root's vectors, so `adjustRefCnt` is removed. The read-ahead
handling (`unclaimed`) for batches that `hasNext()` reads but `next()` hasn't
returned yet is kept.
- **Docs**: the Arrow UDF example in `ArrowColumnarConversion.md` is
rewritten for the new flow. The PlantUML source is updated, but
`docs/image/VeloxColumnArrowUdfLifecycle.png` isn't regenerated yet.
## How was this patch tested?
- `ArrowEvalPythonExecSuite`: the chained-UDF test now checks that there's
no `LoadArrowDataExec` below and no `OffloadArrowDataExec` above the UDFs.
- Spark 3.5 (pyspark/pandas/pyarrow 21.0.0), rebased on current main, all
passing: `ColumnarBatchTest` (7 tests), `ArrowEvalPythonExecSuite` (including
the several-batches-in-one-partition test), `ColumnarArrowEvalPythonExecSuite`,
`UDFPartialProjectSuite` and `VeloxTransitionSuite` (44 tests, 5 ignored, 0
failed). `spotless:check` and scalastyle pass.
- Not run locally: Spark 4.x, where the chained-UDF and parquet-scan tests
also run (CI).
## Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (claude-sonnet-5-5)
--
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]