Repository navigation
Add skipReshuffleForParDo option to FlinkPipelineOptions - #164
Merged
Merged
Conversation
Adds a new boolean option `skipReshuffleForParDo` (default false) to `FlinkPipelineOptions`. When true, `FlinkStreamingTransformTranslators` uses `DataStreamUtils.reinterpretAsKeyedStream()` instead of `.keyBy()` before stateful ParDo operators, eliminating the HASH network exchange. The option extends the existing CPK/GBK skip-reshuffle path — the same `reinterpretAsKeyedStream` branch already used after GroupByKey/Combine is now also taken when this option is set. No new code paths are added; the change is a one-line condition extension. Safety: callers must guarantee that every input PCollection is already correctly key-partitioned using Flink's KvToByteBufferKeySelector hash function. Incorrect alignment causes silent state corruption. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
yanxinyi
marked this pull request as ready for review
May 4, 2026 21:07
yananhao12
approved these changes
May 4, 2026
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.
Summary
skipReshuffleForParDoboolean option (defaultfalse) toFlinkPipelineOptionstrue, extends the existing CPK/GBK reshuffle-skip path inFlinkStreamingTransformTranslatorsto also apply for all stateful ParDooperators — using
DataStreamUtils.reinterpretAsKeyedStream()instead of.keyBy(), eliminating the HASH network exchange2.45.53→2.45.54Motivation
CTC Flink jobs have stateful DoFns (e.g.
CtcPipelineDoFn). Under hot-key load the HASH exchange before each stateful ParDo fills a sharednetwork buffer and cascades backpressure to all source tasks. Eliminating the HASH makes backpressure local to the affected task.
Design
One-line condition extension in the existing reshuffle decision in
FlinkStreamingTransformTranslators— no new code paths, off by default.Safety
Callers must guarantee every input PCollection is already correctly key-partitioned via Flink's
KvToByteBufferKeySelectorhash. A runtimevalidator (
FlinkKeyGroupValidator) is being added in the beam-runner layer to catch drift.Test plan
FlinkStreamingTransformTranslatorsTestpasses (no regression)LiFlinkParDoTranslatorTest:false→ 2 HASH edges;true→ 1 HASH edgeFORWARDbeforeCtcPipelineDoFn;flink_key_group_mismatches == 0