You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "dwangatt (via GitHub)" <gi...@apache.org> on 2026/08/24 03:48:26 UTC
[PR] [flink][core] Introduce file-size option in Paimon source [paimon]
dwangatt opened a new pull request, #9368:
URL: https://github.com/apache/paimon/pull/9368
### Purpose
The existing FAIR split assignment uses row count as the split weight. This works well when records have similar sizes, but can create significant workload skew for tables containing records with highly variable payload sizes.
Two splits with the same row count may represent very different amounts of data. As a result, splits containing large-payload records can become concentrated on a small number of source subtasks or TaskManagers, causing:
• Uneven S3 read and network load
• Higher memory and CPU pressure on a subset of TaskManagers
• Long-running straggler tasks
• Longer overall batch and rescale job duration
This change introduces a new split weight mode:
scan.split-enumerator.weight-mode=file-size
When used with the FAIR split assigner, Paimon calculates each DataSplit weight from the total size of its data files rather than its row count. The assigner can therefore distribute byte-heavy splits more evenly across source subtasks.
For split types without file-size information, the implementation falls back to row-count weighting.
The goal is to improve source workload balancing for large-payload tables—particularly during Paimon rescale and other bounded batch reads—by spreading heavy IO tasks across more TaskManagers and reducing execution long tails.
### Tests
Add some tests to cover new code. Also tested in our FLINK batch job and new option reduced job running time from 8 hours -> 2 hours.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink][core] Introduce file-size option in Paimon source [paimon]
Posted by "dwangatt (via GitHub)" <gi...@apache.org>.
dwangatt commented on code in PR #9368:
URL: https://github.com/apache/paimon/pull/9368#discussion_r3891453771
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/FlinkConnectorOptions.java:
##########
@@ -181,6 +181,16 @@ public class FlinkConnectorOptions {
.withDescription(
"The mode used by StaticFileStoreSplitEnumerator to assign splits.");
+ public static final ConfigOption<SplitWeightMode> SCAN_SPLIT_ENUMERATOR_WEIGHT_MODE =
+ key("scan.split-enumerator.weight-mode")
+ .enumType(SplitWeightMode.class)
+ .defaultValue(SplitWeightMode.ROW_COUNT)
+ .withDescription(
+ "The weight metric used by StaticFileStoreSplitEnumerator. "
Review Comment:
thanks! @JingsongLi
PR has been updated ✔️
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink][core] Introduce file-size option in Paimon source [paimon]
Posted by "dwangatt (via GitHub)" <gi...@apache.org>.
dwangatt commented on PR #9368:
URL: https://github.com/apache/paimon/pull/9368#issuecomment-5448121417
Thanks @JingsongLi for reviewing! I updated the code accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink][core] Introduce file-size option in Paimon source [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #9368:
URL: https://github.com/apache/paimon/pull/9368#discussion_r3859278197
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/source/FlinkSourceBuilder.java:
##########
@@ -227,10 +230,55 @@ private DataStream<RowData> buildStaticFileSource() {
options.get(FlinkConnectorOptions.SCAN_SPLIT_ENUMERATOR_ASSIGN_MODE),
dynamicPartitionFilteringInfo,
outerProject(),
+ splitWeightFunc(options),
+ null,
options.get(CoreOptions.BLOB_AS_DESCRIPTOR),
skipPreloadTargetSnapshot));
}
+ private static SerializableFunction<FileStoreSourceSplit, Long> splitWeightFunc(
+ Options options) {
+ if (isFileSizeWeightMode(options)) {
+ return FlinkSourceBuilder::splitFileSizeOrRowCount;
Review Comment:
[P2] Please assign the largest byte-weighted splits first. The supplied weight is consumed by BinPacking.packForFixedBinNumber, which sorts items in ascending order before placing each item in the lightest bin. With two readers, 100 splits of weight 1, and one split of weight 100, the current algorithm produces loads of 50 and 150, while largest-first placement produces 100 and 100. A large file plus many small files is a realistic case for this option, so the new mode can preserve the long-tail skew it is intended to remove. Please use descending/LPT order for this path (or fix the shared packer if compatible) and add this distribution as a regression test.
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/source/FlinkSourceBuilder.java:
##########
@@ -227,10 +230,55 @@ private DataStream<RowData> buildStaticFileSource() {
options.get(FlinkConnectorOptions.SCAN_SPLIT_ENUMERATOR_ASSIGN_MODE),
dynamicPartitionFilteringInfo,
outerProject(),
+ splitWeightFunc(options),
+ null,
options.get(CoreOptions.BLOB_AS_DESCRIPTOR),
skipPreloadTargetSnapshot));
}
+ private static SerializableFunction<FileStoreSourceSplit, Long> splitWeightFunc(
+ Options options) {
+ if (isFileSizeWeightMode(options)) {
+ return FlinkSourceBuilder::splitFileSizeOrRowCount;
+ }
+ switch (options.get(FlinkConnectorOptions.SCAN_SPLIT_ENUMERATOR_WEIGHT_MODE)) {
+ case ROW_COUNT:
+ return split -> split.split().rowCount();
+ default:
+ throw new UnsupportedOperationException(
+ "Unsupported split weight mode "
+ + options.get(
+ FlinkConnectorOptions.SCAN_SPLIT_ENUMERATOR_WEIGHT_MODE));
+ }
+ }
+
+ private static void validateSplitWeightMode(Options options) {
+ checkArgument(
+ !isFileSizeWeightMode(options)
+ || options.get(FlinkConnectorOptions.SCAN_SPLIT_ENUMERATOR_ASSIGN_MODE)
+ == FlinkConnectorOptions.SplitAssignMode.FAIR,
+ "'%s' = '%s' only works with '%s' = '%s'.",
+ FlinkConnectorOptions.SCAN_SPLIT_ENUMERATOR_WEIGHT_MODE.key(),
+ FlinkConnectorOptions.SplitWeightMode.FILE_SIZE,
+ FlinkConnectorOptions.SCAN_SPLIT_ENUMERATOR_ASSIGN_MODE.key(),
+ FlinkConnectorOptions.SplitAssignMode.FAIR);
+ }
+
+ private static boolean isFileSizeWeightMode(Options options) {
+ return options.get(FlinkConnectorOptions.SCAN_SPLIT_ENUMERATOR_WEIGHT_MODE)
+ == FlinkConnectorOptions.SplitWeightMode.FILE_SIZE;
+ }
+
+ @VisibleForTesting
+ static long splitFileSizeOrRowCount(FileStoreSourceSplit sourceSplit) {
+ Split split = sourceSplit.split();
+ if (split instanceof DataSplit) {
Review Comment:
[P2] Please preserve file-size weighting through QueryAuthSplit. When query-auth.enabled is true and REST authorization returns a row filter or column mask, TableQueryAuthResult.convertPlan wraps each underlying DataSplit in QueryAuthSplit. This outer-type check then falls back to rowCount, so authenticated bounded reads silently ignore file-size mode even though QueryAuthSplit exposes the wrapped split. Please unwrap transparent QueryAuthSplit layers before checking for DataSplit and add a wrapped-split test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink][core] Introduce file-size option in Paimon source [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on PR #9368:
URL: https://github.com/apache/paimon/pull/9368#issuecomment-5748032207
Requirement fit: SUPPORTED. Implementation: CLEAN.
The user-visible value is demonstrated rather than hypothetical: the reported bounded Flink workload dropped from 8 hours to 2 hours when byte-heavy splits were balanced by file size. The implementation limits file-size weighting to FAIR assignment, unwraps authorization wrappers, falls back to row count for split types without file metadata, applies the same option to bounded system-table sources, and fixes fixed-bin packing to place the largest item first. The generated option documentation and focused assignment tests are present, and the full CI matrix is green.
I found no new correctness issue in the reviewed scope. The PR currently has merge conflicts with master, so it needs a rebase and a rerun before merge; that is repository state, not a defect in the feature logic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink][core] Introduce file-size option in Paimon source [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #9368:
URL: https://github.com/apache/paimon/pull/9368#discussion_r3886657469
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/FlinkConnectorOptions.java:
##########
@@ -181,6 +181,16 @@ public class FlinkConnectorOptions {
.withDescription(
"The mode used by StaticFileStoreSplitEnumerator to assign splits.");
+ public static final ConfigOption<SplitWeightMode> SCAN_SPLIT_ENUMERATOR_WEIGHT_MODE =
+ key("scan.split-enumerator.weight-mode")
+ .enumType(SplitWeightMode.class)
+ .defaultValue(SplitWeightMode.ROW_COUNT)
+ .withDescription(
+ "The weight metric used by StaticFileStoreSplitEnumerator. "
Review Comment:
[P2] Apply the weight mode to bounded system-table sources
This option is currently consumed only by FlinkSourceBuilder. SystemTableSource also constructs StaticFileStoreSource for bounded system-table reads and already propagates the batch size and assign mode, but it calls the overload that leaves the weight function null. A query such as a bounded $ro read with scan.split-enumerator.weight-mode=file-size therefore silently continues balancing by row count, and file-size with preemptive is accepted without the documented validation. Please share the parsing/validation and weight function with SystemTableSource (including copy()), or explicitly reject/document the unsupported path, and add a bounded system-table regression test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink][core] Introduce file-size option in Paimon source [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #9368:
URL: https://github.com/apache/paimon/pull/9368
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org