Skip to content

Add skipReshuffleForParDo option to FlinkPipelineOptions - #164

Merged
yanxinyi merged 1 commit into
li_trunkfrom
xiyan/skip
May 4, 2026
Merged

yanxinyi merged 1 commit into
li_trunkfrom
xiyan/skip

Conversation

@yanxinyi

@yanxinyi yanxinyi commented May 4, 2026

Copy link
Copy Markdown

Summary

  • Adds skipReshuffleForParDo boolean option (default false) to FlinkPipelineOptions
  • When true, extends the existing CPK/GBK reshuffle-skip path in FlinkStreamingTransformTranslators to also apply for all stateful ParDo
    operators — using DataStreamUtils.reinterpretAsKeyedStream() instead of .keyBy(), eliminating the HASH network exchange
  • Bumps version 2.45.53 → 2.45.54

Motivation

CTC Flink jobs have stateful DoFns (e.g. CtcPipelineDoFn). Under hot-key load the HASH exchange before each stateful ParDo fills a shared
network 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 KvToByteBufferKeySelector hash. A runtime
validator (FlinkKeyGroupValidator) is being added in the beam-runner layer to catch drift.

Test plan

  • Existing FlinkStreamingTransformTranslatorsTest passes (no regression)
  • Downstream beam-runner LiFlinkParDoTranslatorTest: false → 2 HASH edges; true → 1 HASH edge
  • CTC EI: Flink UI shows FORWARD before CtcPipelineDoFn; flink_key_group_mismatches == 0

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
yanxinyi marked this pull request as ready for review May 4, 2026 21:07
@yanxinyi
yanxinyi merged commit 40e5541 into li_trunk May 4, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants