Skip to content

fix(arrow-flight): adaptively re-split oversized FlightData based on actual encoded size - #11048

Open
DevMattG wants to merge 4 commits into
apache:mainfrom
DevMattG:flight/adaptive-grpc-response-splitting
Open

DevMattG wants to merge 4 commits into
apache:mainfrom
DevMattG:flight/adaptive-grpc-response-splitting

Conversation

@DevMattG

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

FlightDataEncoder splits record batches based on a cheap, buffer-memory-size heuristic before IPC encoding. That heuristic can be significantly wrong -- it ignores IPC framing/padding overhead, and undercounts batches with dictionaries or highly skewed row sizes -- so pieces produced by the initial split can still end up well over max_flight_data_size once actually encoded.

What changes are included in this PR?

  • After the initial heuristic split, each piece is now IPC-encoded and its actual encoded size is checked against max_flight_data_size in FlightDataEncoder::encode_piece_adaptive. If it's still too large, the piece is re-split using the real size ratio and the sub-pieces are recursively re-checked, so oversized pieces get corrected regardless of why the initial estimate was wrong.
  • Dictionaries are queued unconditionally as soon as they're encoded, independent of whether the record batch carrying them ends up split further.
  • Fixed split_batch_for_grpc_response's batch-count calculation to round up (div_ceil) instead of using floor division, which could previously produce one too few batches.

Are these changes tested?

Yes. Added/extended unit tests in arrow-flight/src/encode.rs covering:

  • Repeated/deep adaptive re-splitting under a heavily skewed dictionary size distribution.
  • Adaptive re-splitting with both DictionaryHandling::Resend and the default DictionaryHandling::Hydrate.
  • A single row whose own encoded size exceeds max_flight_data_size (can't be split further, must still be emitted).

Are there any user-facing changes?

No breaking API changes.

@DevMattG
DevMattG marked this pull request as ready for review September 10, 2026 14:28
@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-flight arrow-flight crate labels Sep 10, 2026

@Rich-T-kid Rich-T-kid left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't taken a deeper look but from the description it seems we arrived at the same conclusion.

@DevMattG do you mind taking a glance at #10383, we might be able to close the issues related to that PR as well.

Will try and review this PR today

@DevMattG

Copy link
Copy Markdown
Author

@Rich-T-kid, while in #10383 you focus on changing the heuristic, this PR introduces a second step after it, that directly evaluates the actual encoded size of the flight batch. If it still exceeds max_flight_data_size a re-split is performed. I think this could solve the problem of the inflated sizes after IPC encoding you were addressing here #10383 (comment).

Maybe combining this PR with yours could be the best solution so far? (at least I could think of)

@Rich-T-kid

Copy link
Copy Markdown
Contributor

yea ill close #10383 in favor of this one.

@Rich-T-kid

Copy link
Copy Markdown
Contributor

run benchmark ipc_writer

1 similar comment
@Rich-T-kid

Copy link
Copy Markdown
Contributor

run benchmark ipc_writer

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c5753267044-2536-fcrzr 6.12.94+ #1 SMP Tue Aug 4 08:44:15 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing flight/adaptive-grpc-response-splitting (68c48e9) to f9e02ba (merge-base) diff

Run configuration
run benchmark ipc_writer

BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench ipc_writer
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c5753268442-2537-g7bdf 6.12.94+ #1 SMP Tue Aug 4 08:44:15 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing flight/adaptive-grpc-response-splitting (68c48e9) to f9e02ba (merge-base) diff

Run configuration
run benchmark ipc_writer

BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench ipc_writer
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

Comparing flight/adaptive-grpc-response-splitting (68c48e9) to f9e02ba (merge-base) diff

Run configuration
run benchmark ipc_writer
CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                                                         flight_adaptive-grpc-response-splitting    main
-----                                                         ---------------------------------------    ----
arrow_ipc_stream_writer/FileWriter/write_10                   1.00     89.9±0.52µs        ? ?/sec        1.00     89.7±0.51µs        ? ?/sec
arrow_ipc_stream_writer/FileWriter/write_10/dict/delta        1.00    153.8±3.72µs        ? ?/sec        1.00    154.5±3.36µs        ? ?/sec
arrow_ipc_stream_writer/StreamEncoder/encode_10               1.00     22.1±0.18µs        ? ?/sec        1.00     22.1±0.29µs        ? ?/sec
arrow_ipc_stream_writer/StreamEncoder/encode_10/dict          1.03     69.0±0.47µs        ? ?/sec        1.00     66.9±4.28µs        ? ?/sec
arrow_ipc_stream_writer/StreamEncoder/encode_10/dict/delta    1.00    131.5±3.60µs        ? ?/sec        1.03    135.1±3.40µs        ? ?/sec
arrow_ipc_stream_writer/StreamEncoder/encode_10/zstd          1.00      7.3±0.03ms        ? ?/sec        1.00      7.2±0.04ms        ? ?/sec
arrow_ipc_stream_writer/StreamWriter/write_10                 1.02     87.8±0.48µs        ? ?/sec        1.00     86.4±0.84µs        ? ?/sec
arrow_ipc_stream_writer/StreamWriter/write_10/dict            1.22     87.5±1.17µs        ? ?/sec        1.00     71.7±0.40µs        ? ?/sec
arrow_ipc_stream_writer/StreamWriter/write_10/dict/delta      1.00    147.1±3.13µs        ? ?/sec        1.05    154.9±4.36µs        ? ?/sec
arrow_ipc_stream_writer/StreamWriter/write_10/zstd            1.00      7.2±0.03ms        ? ?/sec        1.00      7.2±0.04ms        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 110.0s
Peak memory 12.5 MiB
Avg memory 10.5 MiB
CPU user 105.6s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 110.0s
Peak memory 12.5 MiB
Avg memory 10.5 MiB
CPU user 106.1s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

Comparing flight/adaptive-grpc-response-splitting (68c48e9) to f9e02ba (merge-base) diff

Run configuration
run benchmark ipc_writer
CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                                                         flight_adaptive-grpc-response-splitting    main
-----                                                         ---------------------------------------    ----
arrow_ipc_stream_writer/FileWriter/write_10                   1.02     90.1±0.58µs        ? ?/sec        1.00     88.4±0.30µs        ? ?/sec
arrow_ipc_stream_writer/FileWriter/write_10/dict/delta        1.01    149.9±3.12µs        ? ?/sec        1.00    148.1±2.95µs        ? ?/sec
arrow_ipc_stream_writer/StreamEncoder/encode_10               1.00     22.3±0.22µs        ? ?/sec        1.00     22.2±0.34µs        ? ?/sec
arrow_ipc_stream_writer/StreamEncoder/encode_10/dict          1.19     67.6±0.45µs        ? ?/sec        1.00     56.9±5.35µs        ? ?/sec
arrow_ipc_stream_writer/StreamEncoder/encode_10/dict/delta    1.00    128.0±3.25µs        ? ?/sec        1.03    131.2±2.81µs        ? ?/sec
arrow_ipc_stream_writer/StreamEncoder/encode_10/zstd          1.00      7.2±0.03ms        ? ?/sec        1.00      7.1±0.03ms        ? ?/sec
arrow_ipc_stream_writer/StreamWriter/write_10                 1.03     88.1±0.33µs        ? ?/sec        1.00     85.8±0.47µs        ? ?/sec
arrow_ipc_stream_writer/StreamWriter/write_10/dict            1.02     86.6±0.92µs        ? ?/sec        1.00     84.7±0.40µs        ? ?/sec
arrow_ipc_stream_writer/StreamWriter/write_10/dict/delta      1.00    144.0±3.08µs        ? ?/sec        1.03    148.8±3.91µs        ? ?/sec
arrow_ipc_stream_writer/StreamWriter/write_10/zstd            1.00      7.2±0.04ms        ? ?/sec        1.00      7.2±0.04ms        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 110.0s
Peak memory 12.6 MiB
Avg memory 10.5 MiB
CPU user 105.2s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 110.0s
Peak memory 12.5 MiB
Avg memory 10.4 MiB
CPU user 105.1s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@Rich-T-kid Rich-T-kid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will take a closer look but for the most part this makes sense to me.

Comment thread arrow-flight/src/encode.rs Resolved
@Rich-T-kid

Copy link
Copy Markdown
Contributor

@DevMattG could you rebase this PR

@Rich-T-kid Rich-T-kid added the bug Squash those bugs label Oct 22, 2026
@DevMattG
DevMattG force-pushed the flight/adaptive-grpc-response-splitting branch from 0b396e3 to a5b296a Compare October 22, 2026 07:52
@DevMattG

Copy link
Copy Markdown
Author

@DevMattG could you rebase this PR

Done. Please let me know if there's something else I should do. Thanks!

@Rich-T-kid
Rich-T-kid self-requested a review October 28, 2026 03:31
… size

`split_batch_for_grpc_response` only estimates a RecordBatch's encoded
size from `get_buffer_memory_size()`, which ignores IPC framing/padding
overhead and can badly undercount for variable-length data (dictionaries,
strings). This let `FlightDataEncoder` silently emit `FlightData` messages
larger than `max_flight_data_size` (see apache#3478).

`FlightDataEncoder::encode_batch` now delegates to a new
`encode_piece_adaptive`, which encodes each heuristic-split piece, queues
any dictionaries unconditionally (they're keyed by id and correct to send
regardless of how the batch body ends up sliced), and if the *actual*
encoded size still exceeds the limit, re-splits, recursively if necessary.

To avoid paying for that fallback on every batch whose estimated size
lands right at the limit, the first-pass heuristic now targets 90% of
`max_flight_data_size` (`SPLIT_HEURISTIC_MARGIN_DIVISOR`), leaving
headroom for the framing overhead the estimate doesn't account for.
@DevMattG
DevMattG force-pushed the flight/adaptive-grpc-response-splitting branch from a5b296a to b68800e Compare October 28, 2026 09:20

@azecevic000 azecevic000 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DevMattG @Rich-T-kid I believe both this PR and #10383 solve #3478 from different directions. This PR makes max_flight_data_size a hard limit (documentation should be updated in this PR).

But there is still an issue where the memory size is overestimated because the size of the underlying buffer is taken instead of the size of the encoded slice. The notable pathological case is when you want to reencode the batch that was produced during the IPC serialization. Each column counts the whole message as its own buffer size, so it depends on the schema, but often the end result will be the split which split the batch into single row batches.

I think it makes sense to incorporate #10383 into this PR, what do you guys think? Thank you both for working on #3478, hopefully this can be resolved and merged soon.

@Rich-T-kid

Copy link
Copy Markdown
Contributor

sorry for the delay, will spend a block of time reviewing this tommorow

@Rich-T-kid

Copy link
Copy Markdown
Contributor

@DevMattG @Rich-T-kid I believe both this PR and #10383 solve #3478 from different directions. This PR makes max_flight_data_size a hard limit (documentation should be updated in this PR).

👍 I agree

But there is still an issue where the memory size is overestimated because the size of the underlying buffer is taken instead of the size of the encoded slice. The notable pathological case is when you want to reencode the batch that was produced during the IPC serialization. Each column counts the whole message as its own buffer size, so it depends on the schema, but often the end result will be the split which split the batch into single row batches.
I think it makes sense to incorporate #10383 into this PR, what do you guys think? Thank you both for working on #3478, hopefully this can be resolved and merged soon.

I agree. would be nice to solve both of these. typically Id be in favor of splitting this into two PR's but I think they are quite related

@azecevic000

azecevic000 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

@DevMattG Kindly nudge, do you have time to work on this in the near future? I hope this can land in 61.0. I'm more than happy to offer any kind of help (reviewing or taking this to the finish line if you're out of time).

CC: @Rich-T-kid

@DevMattG

Copy link
Copy Markdown
Author

@DevMattG Kindly nudge, do you have time to work on this in the near future? I hope this can land in 61.0. I'm more than happy to offer any kind of help (reviewing or taking this to the finish line if you're out of time).

CC: @Rich-T-kid

Sorry for the delay. I was hoping to gather some time to work on this, but as a matter of fact I have no idea when I'd be able to continue. So, please feel free to take over and finish it! Sorry again :(

@azecevic000

Copy link
Copy Markdown
Contributor

@DevMattG No worries, thanks for letting me know! Sure, I would love to drive this to completion. I will prioritize this.

azecevic000 added a commit to azecevic000/arrow-rs that referenced this pull request Nov 27, 2026
Continue apache#11048, which encodes each piece and splits a message that is
larger than the limit again. Make the first split fit, and keep the
splits from sending data again with every row:

- Estimate the first split from the slices of the arrays
  (`ArrayData::get_slice_memory_size`, the idea of apache#10383), with room
  for the IPC framing of the message and of each column. Decoded and
  sliced batches are then no longer split into many small messages.
- Compact the top-level view columns of a piece with `gc()` when that
  makes them smaller: the IPC writer writes all data buffers of a view
  array, however it is sliced.
- Encode the pieces of a message over the limit before they are used.
  If they do not all fit, and add more than half of the limit for each
  additional piece, for example because each repeats the child of a
  list view array or a large IPC header, send the message as it is.

Document the limit and its exceptions.
@Rich-T-kid

Copy link
Copy Markdown
Contributor

@azecevic000 should we close this pr in favor of yours?

@azecevic000

Copy link
Copy Markdown
Contributor

@azecevic000 should we close this pr in favor of yours?

Yes, please. I'm working on a few more details; I plan to open a PR very soon (hopefully by the end of the day).

azecevic000 added a commit to azecevic000/arrow-rs that referenced this pull request Dec 2, 2026
Continue apache#11048, which encodes each piece and splits a message that is
larger than the limit again. Make the first split fit, and keep the
splits from sending data again with every row:

- Estimate the first split from the slices of the arrays
  (`ArrayData::get_slice_memory_size`, the idea of apache#10383), with room
  for the IPC framing of the message and of each column. Decoded and
  sliced batches are then no longer split into many small messages.
- Compact the top-level view columns of a piece with `gc()` when that
  makes them smaller: the IPC writer writes all data buffers of a view
  array, however it is sliced.
- Encode the pieces of a message over the limit before they are used.
  If they do not all fit, and add more than half of the limit for each
  additional piece, for example because each repeats the child of a
  list view array or a large IPC header, send the message as it is.
- Let `IpcWriteContext` allocate the reserved scratch on the next
  encode, and let `set_reserve_scratch(false)` drop a pending capacity.
  The encoder then reserves for all pieces of a batch, instead of
  passing down to each split whether its piece is the last one.

Document the limit and its exceptions.
azecevic000 added a commit to azecevic000/arrow-rs that referenced this pull request Dec 2, 2026
Continue apache#11048, which encodes each piece and splits a message that is
larger than the limit again. Make the first split fit, and keep the
splits from sending data again with every row:

- Estimate the first split from the slices of the arrays
  (`ArrayData::get_slice_memory_size`, the idea of apache#10383), with room
  for the IPC framing of the message and of each column. Decoded and
  sliced batches are then no longer split into many small messages.
- Compact the top-level view columns of a piece with `gc()` when that
  makes them smaller: the IPC writer writes all data buffers of a view
  array, however it is sliced.
- Encode the pieces of a message over the limit before they are used.
  If they do not all fit, and add more than half of the limit for each
  additional piece, for example because each repeats the child of a
  list view array or a large IPC header, send the message as it is.
- Let `IpcWriteContext` allocate the reserved scratch on the next
  encode, and let `set_reserve_scratch(false)` drop a pending capacity.
  The encoder then reserves for all pieces of a batch, instead of
  passing down to each split whether its piece is the last one.

Document the limit and its exceptions.
azecevic000 added a commit to azecevic000/arrow-rs that referenced this pull request Dec 3, 2026
Continue apache#11048, which encodes each piece and splits a message that is
larger than the limit again. Make the first split fit, and keep the
splits from sending data again with every row:

- Estimate the first split from the slices of the arrays
  (`ArrayData::get_slice_memory_size`, the idea of apache#10383), with room
  for the IPC framing of the message and of each column. Decoded and
  sliced batches are then no longer split into many small messages.
- Compact the top-level view columns of a piece with `gc()` when that
  makes them smaller: the IPC writer writes all data buffers of a view
  array, however it is sliced.
- Encode the pieces of a message over the limit before they are used.
  If they do not all fit and each repeats more than half of the limit,
  for example the child of a list view array or a large IPC header,
  send the message as-is.
- Encode the pieces of a split message without reserving the scratch
  buffer of the IPC writer: every body would start with at least the
  capacity of the split message, which is over the limit.

Document the limit and its exceptions.
azecevic000 added a commit to azecevic000/arrow-rs that referenced this pull request Dec 3, 2026
Continue apache#11048, which encodes each piece and splits a message that is
larger than the limit again. Make the first split fit, and keep the
splits from sending data again with every row:

- Estimate the first split from the slices of the arrays
  (`ArrayData::get_slice_memory_size`, the idea of apache#10383), with room
  for the IPC framing of the message and of each column. Decoded and
  sliced batches are then no longer split into many small messages.
- Compact the top-level view columns of a piece with `gc()` when that
  makes them smaller: the IPC writer writes all data buffers of a view
  array, however it is sliced.
- Encode the pieces of a message over the limit before they are used.
  If they do not all fit and the overhead of each piece, for example a
  large IPC header or the child of a list view array, is more than half
  of the limit, send the message as-is.
- Encode the pieces of a split message without reserving the scratch
  buffer of the IPC writer: every body would start with at least the
  capacity of the split message, which is over the limit.

Document the limit and its exceptions.
azecevic000 added a commit to azecevic000/arrow-rs that referenced this pull request Dec 3, 2026
Continue apache#11048, which encodes each piece and splits a message that is
larger than the limit again. Make the first split fit, and keep the
splits from sending data again with every row:

- Estimate the first split from the slices of the arrays
  (`ArrayData::get_slice_memory_size`, the idea of apache#10383), with room
  for the IPC framing of the message and of each column. Decoded and
  sliced batches are then no longer split into many small messages.
- Compact the top-level view columns of a piece with `gc()` when that
  makes them smaller: the IPC writer writes all data buffers of a view
  array, however it is sliced.
- Encode the pieces of a message over the limit before they are used.
  If they do not all fit and the overhead of each piece, for example a
  large IPC header or the child of a list view array, is more than half
  of the limit, send the message as-is.
- Encode the pieces of a split message without reserving the scratch
  buffer of the IPC writer: every body would start with at least the
  capacity of the split message, which is over the limit.

Document the limit and its exceptions.
azecevic000 added a commit to azecevic000/arrow-rs that referenced this pull request Dec 3, 2026
Continue apache#11048, which encodes each piece and splits a message that is
larger than the limit again. Make the first split fit, and keep the
splits from sending data again with every row:

- Estimate the first split from the slices of the arrays
  (`ArrayData::get_slice_memory_size`, the idea of apache#10383), with room
  for the IPC framing of the message and of each column. Decoded and
  sliced batches are then no longer split into many small messages.
- Compact the top-level view columns of a piece with `gc()` when that
  makes them smaller: the IPC writer writes all data buffers of a view
  array, however it is sliced.
- Encode the pieces of a message over the limit before they are used.
  If they do not all fit and the overhead of each piece, for example a
  large IPC header or the child of a list view array, is more than half
  of the limit, send the message as-is.
- Encode the pieces of a split message without reserving the scratch
  buffer of the IPC writer: every body would start with at least the
  capacity of the split message, which is over the limit.

Document the limit and its exceptions.
azecevic000 added a commit to azecevic000/arrow-rs that referenced this pull request Dec 3, 2026
Continue apache#11048, which encodes each piece and splits a message that is
larger than the limit again. Make the first split fit, and keep the
splits from sending data again with every row:

- Estimate the first split from the slices of the arrays
  (`ArrayData::get_slice_memory_size`, the idea of apache#10383), with room
  for the IPC framing of the message and of each column. Decoded and
  sliced batches are then no longer split into many small messages.
- Compact the top-level view columns of a piece with `gc()` when that
  makes them smaller: the IPC writer writes all data buffers of a view
  array, however it is sliced.
- Encode the pieces of a message over the limit before they are used.
  If they do not all fit and the overhead of each piece, for example a
  large IPC header or the child of a list view array, is more than half
  of the limit, send the message as-is.
- Encode the pieces of a split message without reserving the scratch
  buffer of the IPC writer: every body would start with at least the
  capacity of the split message, which is over the limit.

Document the limit and its exceptions.
azecevic000 added a commit to azecevic000/arrow-rs that referenced this pull request Dec 3, 2026
Continue apache#11048, which encodes each piece and splits a message that is
larger than the limit again. Make the first split fit, and keep the
splits from sending data again with every row:

- Estimate the first split from the slices of the arrays
  (`ArrayData::get_slice_memory_size`, the idea of apache#10383), with room
  for the IPC framing of the message and of each column. Decoded and
  sliced batches are then no longer split into many small messages.
- Compact the top-level view columns of a piece with `gc()` when that
  makes them smaller: the IPC writer writes all data buffers of a view
  array, however it is sliced.
- Encode the pieces of a message over the limit before they are used.
  If they do not all fit and the overhead of each piece, for example a
  large IPC header or the child of a list view array, is more than half
  of the limit, send the message as-is.
- Encode the pieces of a split message without reserving the scratch
  buffer of the IPC writer: every body would start with at least the
  capacity of the split message, which is over the limit.

Document the limit and its exceptions.
azecevic000 added a commit to azecevic000/arrow-rs that referenced this pull request Dec 3, 2026
Continue apache#11048, which encodes each piece and splits a message that is
larger than the limit again. Make the first split fit, and keep the
splits from sending data again with every row:

- Estimate the first split from the slices of the arrays
  (`ArrayData::get_slice_memory_size`, the idea of apache#10383), with room
  for the IPC framing of the message and of each column. Decoded and
  sliced batches are then no longer split into many small messages.
- Compact the top-level view columns of a piece with `gc()` when that
  makes them smaller: the IPC writer writes all data buffers of a view
  array, however it is sliced.
- Encode the pieces of a message over the limit before they are used.
  If they do not all fit and the overhead of each piece, for example a
  large IPC header or the child of a list view array, is more than half
  of the limit, send the message as-is.
- Encode the pieces of a split message without reserving the scratch
  buffer of the IPC writer: every body would start with at least the
  capacity of the split message, which is over the limit.

Document the limit and its exceptions.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-flight arrow-flight crate bug Squash those bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve ability of FlightDataEncoder to respect max_flight_data_size for certain data types (strings, dictionaries, etc)

4 participants