[
https://issues.apache.org/jira/browse/FLINK-41832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated FLINK-41832:
-----------------------------------
Labels: pull-request-available (was: )
> AdaptiveBatchScheduler fills tasks up to avg-data-volume-per-task, so the
> last task of a vertex gets only the remainder
> -----------------------------------------------------------------------------------------------------------------------
>
> Key: FLINK-41832
> URL: https://issues.apache.org/jira/browse/FLINK-41832
> Project: Flink
> Issue Type: Improvement
> Components: Runtime / Coordination
> Affects Versions: 2.1.0, 2.2.0, 2.3.0, 2.4.0, 2.5.0
> Reporter: Rion Williams
> Priority: Major
> Labels: pull-request-available
>
> h3. Problem
> {{DefaultVertexParallelismAndInputInfosDecider}} assigns subpartition slices
> to the tasks of a vertex with
> {{VertexParallelismAndInputInfosDeciderUtils#computeSubpartitionSliceRanges}}.
> That method fills each task up to
> {{execution.batch.adaptive.auto-parallelism.avg-data-volume-per-task}} before
> it starts the next one. Every task but the last gets about the limit, and the
> last gets whatever is left.
> For example, a vertex with 69 MB of input and a 64 MB limit gets parallelism
> 2, with tasks of 64 MB and 5 MB. The stage takes as long as a 64 MB task,
> although two 35 MB tasks were possible. The gap is largest at low
> parallelism: at parallelism 2, the stage can take up to twice as long as with
> an even split.
> h3. Reproduction
> A DataStream job on a MiniCluster. Every option other than
> {{avg-data-volume-per-task}} keeps its default value.
> {code:java}
> Configuration conf = new Configuration();
> conf.set(
>
> BatchExecutionOptions.ADAPTIVE_AUTO_PARALLELISM_AVG_DATA_VOLUME_PER_TASK,
> MemorySize.parse("2mb"));
> StreamExecutionEnvironment env =
> StreamExecutionEnvironment.createLocalEnvironment(conf);
> env.setRuntimeMode(RuntimeExecutionMode.BATCH);
> env.setParallelism(-1); // the scheduler decides the parallelism of the map
> env.fromSequence(0, 199_999)
> .setParallelism(4)
> .rebalance() // or .keyBy(x -> x)
> .map(new CountRecordsPerSubtask()) // adds one LongCounter
> accumulator per subtask
> .sinkTo(new DiscardingSink<>());
> {code}
> Records received by each map subtask:
> ||Shuffle||avg-data-volume-per-task||Decided parallelism||Records per
> subtask||
> |keyBy|1 MB|5|48628, 48371, 48359, 48355, *6287*|
> |keyBy|2 MB|3|98578, 98248, *3174*|
> |rebalance|1 MB|5|49610, 49610, 49607, 49613, *1560*|
> |rebalance|2 MB|3|99218, 99218, *1564*|
> h3. Expected behavior
> * The option is documented as _"the average size of data volume to expect
> each task instance to process"_.
> * The Javadoc of {{computeSubpartitionSliceRanges}} says it reassembles the
> slices _"into balanced n parts"_.
> * {{adjustToClosestLegalParallelism}} already balances when it raises the
> parallelism to the configured minimum. It searches for the smallest limit
> that keeps the chosen parallelism, because _"the smaller the dataVolumeLimit,
> the more even the distribution"_. When it lowers the parallelism to the
> configured maximum, it searches for the smallest limit that fits, which is
> also even.
> The ordinary path, where the first greedy pass already gives a legal
> parallelism, does neither.
> h3. Proposed change
> Once the greedy pass yields a legal parallelism _p_:
> # Use {{BisectionSearchUtils#findMinLegalValue}} with {{computeParallelism}}
> to find the smallest limit for which the greedy pass still yields _p_ tasks.
> # Compute the ranges with that limit.
> Filling greedily at the smallest workable limit minimizes the largest task
> among all contiguous splits into _p_ tasks. The parallelism does not change,
> only the data each task reads. The search costs about log2(limit) extra
> passes over the slices when a vertex's parallelism is decided.
> With the change, the job above keeps the same parallelism and the same total
> in every case:
> ||Shuffle||avg-data-volume-per-task||Decided 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|
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)