Skip to content

perf: reuse Arrow IPC compression context across shuffle blocks - #5038

Open
peterxcli wants to merge 2 commits into
apache:mainfrom
peterxcli:perf/reuse-compression-context-across-shuffle-blocks
Open

perf: reuse Arrow IPC compression context across shuffle blocks#5038
peterxcli wants to merge 2 commits into
apache:mainfrom
peterxcli:perf/reuse-compression-context-across-shuffle-blocks

Conversation

@peterxcli

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #5008.

Rationale for this change

Avoid recreating Arrow IPC compression state for every shuffle block.

What changes are included in this PR?

Reuse one CompressionContext per buffered partition writer and across batches in the JVM row conversion path. Update benchmarks and callers accordingly.

How are these changes tested?

Existing shuffle IPC round-trip, buffered writer, and shuffle scan tests pass. The shuffle writer benchmark also compiles successfully.

@andygrove

Copy link
Copy Markdown
Member

Thanks @peterxcli. Can you share any benchmark results?

@peterxcli

peterxcli commented Jul 26, 2026

Copy link
Copy Markdown
Member Author

@andygrove this would take effect only after #4888 is merged.
and the reason is:


with arrow 58.4:

Production path Baseline / patch blocks FlatBuffer allocations per block FlatBuffer bytes per block Context allocations
JVM sort → row.rs 2,688 / 2,441 11 / 11 4,136 / 4,136 0 / 0
Native → BufBatchWriter 5,857 / 4,298 11 / 11 4,136 / 4,136 0 / 0

with arrow 59.1:

1,000 blocks Fresh context Reused context
Allocation calls 212,000 201,011
Requested bytes 8,508,496,000 8,504,364,136

@peterxcli

Copy link
Copy Markdown
Member Author

@andygrove I've publish the benchmark, would appreciate it if you could take a look at this and see if we can get this merged.

@sunchao sunchao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. The mutable context stays with the buffered writer or row-conversion loop, while dictionary tracking and outer compression frames remain independent for each block.

I also compared the base and head writers using a focused Arrow 58.4 probe covering all four codecs, dictionary and schema changes, repeated flushes, and output failures. All seven tests passed. The Arrow-version dependency of the performance benefit is already covered in the benchmark discussion.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: reuse Arrow IPC CompressionContext across shuffle blocks instead of per-batch allocation

3 participants