rionmonster opened a new pull request, #30273:
URL: https://github.com/apache/flink/pull/30273

   ## What is the purpose of the change
   
   `VertexParallelismAndInputInfosDeciderUtils#computeSubpartitionSliceRanges` 
fills each task up to the data volume limit before it starts the next one, so 
every task but the last gets about the limit and the last gets the remainder. 
With 69 MB of input and a 64 MB 
`execution.batch.adaptive.auto-parallelism.avg-data-volume-per-task`, a vertex 
gets parallelism 2 with tasks of 64 MB and 5 MB. The stage then takes as long 
as a 64 MB task instead of a 35 MB one.
   
   `adjustToClosestLegalParallelism` already avoids this when it raises the 
parallelism to the configured minimum: it searches for the smallest limit that 
keeps the chosen parallelism. This change applies the same search when the 
first pass already gives a legal parallelism.
   
   ## Brief change log
   
   - After `computeSubpartitionSliceRanges` yields a legal parallelism p, find 
the smallest limit for which `computeParallelism` still yields p tasks 
(`BisectionSearchUtils#findMinLegalValue`), and recompute the ranges with that 
limit. Filling greedily at the smallest workable limit minimizes the largest 
task among contiguous splits into p tasks. The parallelism does not change.
   - Updated the expected ranges in three 
`DefaultVertexParallelismAndInputInfosDeciderTest` cases. Each one is now more 
even:
   
   | Test | Data per task before | Data per task after |
   |---|---|---|
   | `testAllEdgesAllToAll` | 45, 55, 58, 59, 22 | 45, 55, 58, 33, 48 |
   | `testAllEdgesAllToAllAndOneIsBroadcast` | 51, 50, 17 | 38, 31, 49 |
   | `testHavePointwiseAndBroadcastEdge` | 20, 30, 20, 19, 27, 5 | 20, 21, 22, 
26, 13, 19 |
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - 
`VertexParallelismAndInputInfosDeciderUtilsTest#testComputeSubpartitionSliceRangeBalancesDataVolume`:
 69 one-byte slices with a 64-byte limit give ranges of 35 and 34 bytes. Before 
the change they gave 64 and 5.
   - 
`VertexParallelismAndInputInfosDeciderUtilsTest#testComputeSubpartitionSliceRangeWithZeroDataVolumeLimit`:
 an input group whose limit rounds down to 0 
(`calculateDataVolumePerTaskForInputsGroup`) keeps its ranges.
   - All tests under `org.apache.flink.runtime.scheduler.adaptivebatch` pass. 
So do the ITs that run on the adaptive batch scheduler with auto parallelism: 
`AdaptiveBatchSchedulerITCase`, `JMFailoverITCase`, 
`SpeculativeExecutionITCase`, `ForwardEdgeParallelismMismatchOverridesITCase`, 
`RestartStrategyITCase`, `HybridShuffleITCase` and `CacheITCase` in 
flink-tests, and `AdaptiveSkewedJoinITCase`, `AdaptiveBroadcastJoinITCase` and 
`MultipleInputITCase` in flink-table-planner.
   - Manually, with a MiniCluster DataStream job: `fromSequence(0, 199999)` at 
parallelism 4, then keyBy or rebalance, then a map whose parallelism the 
scheduler decides and which counts records per subtask. I swept 
`avg-data-volume-per-task` from 96 KB to 2 MB. In all 20 runs the decided 
parallelism and the total stay the same. The largest subtask never grows by 
more than one record (rebalance starts at a random channel), and it shrinks by 
up to a third:
   
   | Edge | Limit | Parallelism | Records per subtask before | Records per 
subtask after |
   |---|---|---|---|---|
   | keyBy | 1 MB | 5 | 48628, 48371, 48359, 48355, 6287 | 39347, 40420, 40551, 
39105, 40577 |
   | keyBy | 2 MB | 3 | 98578, 98248, 3174 | 65880, 66830, 67290 |
   | rebalance | 1 MB | 5 | 49610, 49610, 49607, 49613, 1560 | 40229, 39849, 
39863, 40199, 39860 |
   | rebalance | 2 MB | 3 | 99218, 99218, 1564 | 66422, 66801, 66777 |
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no. The 
search adds about log2(limit) passes over the subpartition slices when a 
vertex's parallelism is decided.
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no. The decided 
parallelism is unchanged; only which subpartitions each task reads changes.
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Claude Opus 5.5)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to