perf(arrow codec): optimize scalar RecordBatch encoding#25734
Open
dannote wants to merge 1 commit into
Open
Conversation
Contributor
|
Thank you for your contribution! Before we can merge this PR, please sign our Contributor License Agreement. To sign, copy and post the phrase below as a new comment on this PR.
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
9 tasks
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
perf(arrow codec): optimize scalar RecordBatch encoding
Summary
This PR optimizes
ArrowStreamSerializer::encode_to_record_batchfor table/native sinks that encode log events into an ArrowRecordBatchwith a fixed scalar schema.Previously, this path always encoded through an intermediate JSON representation:
That path is flexible and remains the fallback. This PR adds a direct path for schemas made of supported scalar Arrow types:
The direct path currently supports:
If the schema contains unsupported types, or if a value needs Arrow's more permissive JSON decoder behavior, encoding falls back to the existing JSON decoder path.
Vector configuration
This change is in the Arrow codec internals and does not add or change Vector configuration.
The motivating workload was a schema-aware sink that appends Arrow
RecordBatchvalues into a table-native destination. In that setup, the destination append path was fast enough that RecordBatch construction became a visible part of the hot path.Representative test configuration used for end-to-end validation while developing the downstream sink:
The DuckDB sink itself is not part of this PR; this configuration is included only to explain the use case that exposed the bottleneck.
How did you test this PR?
Added tests covering the direct RecordBatch path and its fallback behavior:
Ran the following local checks:
All passed.
I also ran release-mode stress tests against the downstream table-native sink workload while developing this change. In a direct sink stress test with a scalar schema:
Before the direct path:
After the direct path:
In a full file-source JSON pipeline, file reading and JSON parsing dominated, and the sink using RecordBatch encoding was close to a blackhole baseline:
Change Type
Is this a breaking change?
Does this PR include user facing changes?
no-changeloglabel to this PR.References
Related follow-up work: a table-native DuckDB sink that uses
ArrowStreamSerializer::encode_to_record_batchfor appends.Notes
The existing JSON decoder path is intentionally preserved as the fallback. This keeps compatibility for nested schemas and for values that Arrow's JSON decoder can coerce more broadly than the direct scalar path.