Repository navigation
[Flink] Skip pre-combine step for batch GroupByKey - #41908
Draft
pkuzmickas wants to merge 1 commit into
Draft
pkuzmickas wants to merge 1 commit into
pkuzmickas wants to merge 1 commit into
Conversation
Co-Authored-By: Xirp Agent (gemini-4-neon) <xirp-agent@users.noreply.ghe.spotify.net>
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.
Addresses #40607.
In batch on the DataStream translation path (always on the Flink 2 runner, and with
--useDataStreamForBatchon Flink 1),FlinkStreamingAggregationsTranslators.batchGroupByKeyroutes everyGroupByKeythroughPartialReduceBundleOperatorwithConcatenateAsIterable, followed by aFlattenIterableflatMap after the shuffle.Unlike
Combine.perKey, grouping values into anIterablecannot reduce payload bytes: every input value still crosses the shuffle verbatim, with extraIterableCoderframing andO(n^2)list copying inConcatenateAsIterable#addInputwhen keys repeat in a bundle. Worse, inCoGroupByKeythe input toGroupByKeyis aunionof multiple branches, so Flink cannot chainPartialReduceBundleOperatoronto its upstream inputs and inserts an extra blocking-shuffle stage. In a production Scio batch job joining ~2.2B records (~83 TB), those redundantCombine:stages wrote and re-read ~102 TB with 0.04% record reduction, adding ~15 minutes to wall-clock time.What changes
batchGroupByKeydirectly asinputDataStream.keyBy(keySelector)followed by the final grouping operator (SortedBatchCombineOperatororWindowDoFnOperator), removingConcatenateAsIterable,FlattenIterable, and thePartialReduceBundleOperatorstage forGroupByKey.--lazyBatchGroupingInputsby settingwithLazyKvValues()only on theKeyedStream'sPartitionTransformationoutput type, leaving upstream streams and peer consumers unchanged while keeping lazy deserialization intoLazyKvWindowedValueon the grouping operator's input.FlinkStreamingAggregationsTranslatorsTestcoveringGroupByKey(global and fixed windows),CoGroupByKey, and lazy input serialization.🤖 Generated with Xirp Agent