[flink] size aware partitioner for full compaction job#8583
Open
dwangatt wants to merge 8 commits into
Open
Conversation
…ibution Support custom bucket distribution based on bucket size.
Contributor
|
When |
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
This PR adds a new dedicated compaction bucket distribution strategy:
The new strategy is intended for bounded full compaction jobs. It improves compaction workload balance by assigning compact buckets based on their total input file size, instead of relying on the existing linear partition/bucket channel mapping.
Problem
The previous compaction distribution strategy could assign multiple heavy buckets to the same writer while other writers received much lighter work. This caused long-tail compaction tasks where a small number of writers determined the overall job runtime.
This was especially visible in high-parallelism full compaction jobs where the total workload was large, but writer-level input distribution was uneven.
What changed
When compaction.bucket-distribution-strategy=size-aware-batch is enabled for a batch full compaction job:
This keeps compaction correctness while improving writer-level workload balance.
Scope
The new strategy is only applied to:
batch full compaction
For streaming compaction or non-full compaction, the strategy falls back to the existing linear behavior.
Why bucket-level grouping is needed
A single (partition, bucket) can be split into multiple DataSplits. If size-aware assignment were done at the individual split level, splits from the same bucket could be sent to different writers, causing multiple writers to compact the same bucket and potentially conflict during commit.
To avoid this, the assignment is performed at the bucket-group level:
group key = partition + bucket
weight = sum(data file sizes across all splits in that bucket group)
This ensures that each bucket is compacted by only one writer while still balancing heavy buckets across the job.
Expected impact
This should reduce compaction long tail by distributing heavy buckets more evenly across writers. In benchmark runs, size-aware compaction significantly improved writer input balance and reduced overall full-compaction wall-clock time for large Paimon tables.
Tests
Added/updated tests for:
• parsing compaction.bucket-distribution-strategy
• ensuring size-aware-batch is only used for batch full compaction
• source parallelism selection for size-aware compaction
• bucket file-size weight calculation
• grouping splits by (partition, bucket)
• ensuring splits from the same bucket group are assigned to the same downstream writer
• preserving existing fair split assignment behavior when no grouping function is provided
We also verified this change in compaction job. The new stragety can reduce compaction time from 5 hours to 1.5 hours without any significant long tail workers processing heavy buckets.