fix(shm): split oversized batches so every frame fits its ring#37
Draft
mdashti wants to merge 1 commit into
Draft
fix(shm): split oversized batches so every frame fits its ring#37mdashti wants to merge 1 commit into
mdashti wants to merge 1 commit into
Conversation
mdashti
marked this pull request as draft
July 15, 2026 07:55
paradedb-github-bot
Bot
force-pushed
the
main
branch
4 times, most recently
from
July 21, 2026 14:58
83dc1ca to
0cfb2ed
Compare
Operators emit offset slices of their accumulated state, and arrow-ipc writes a sliced variable-length array's whole values buffer, so one frame balloons to the state's size no matter the batch size. Compacting and halving on the oversized path bounds frames by the ring instead of asking embedders to size rings for their widest state.
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.
What
This PR splits an oversized batch at the shm send path so every encoded frame fits its ring.
Why
Operators emit offset slices of their accumulated state, and arrow-ipc writes a sliced variable-length array's whole values buffer, so one frame balloons to the state's size no matter the batch size. Small rings then fail wide GROUP BY and DISTINCT shapes with
MessageTooLarge, and the only workaround was sizing every ring for the widest state any query might carry.How
BatchChannelSendergainsmax_frame_bytes()(the ring's combined slot payload;Nonefor unbounded in-proc channels). When an encoded frame exceeds it, the send path compacts the rows withtake(dropping the shared buffers that cause the ballooning) and halves by rows until each frame fits, left-to-right so row order survives for sorted streams. The common case pays one length check. A single row larger than the ring still errors with the raise-the-knob message.Tests
Unit: an oversized sliced batch splits into under-cap frames that decode back to the identical rows in order; a single oversized row still errors. End-to-end: a wide
max(s)GROUP BY over 64KiB rings, whose raw partial-aggregate emits are ~10x the ring, matches the serial reference exactly.