The GitHub Actions job "Scalafmt" on 
pekko.git/perf/map-async-partitioned-drain-queue has succeeded.
Run started by GitHub user He-Pin (triggered by He-Pin).

Head commit for run:
81ef46eec6ffa8176abf76a50aa9c04ce80f0b7b / 虎鸣 <[email protected]>
perf: skip drainQueue buffer snapshot when all parallelism slots are full

Motivation:
drainQueue() is called on every future completion and performs an O(n)
buffer.toList snapshot plus iteration. When all parallelism slots are
occupied (partitionsInProgress.size >= parallelism), canStartNextElement
returns false for every element, making the entire snapshot and
iteration wasted work. This is the common steady-state case.

Modification:
Add a guard `partitionsInProgress.size < parallelism` to the drainQueue
condition, skipping the O(n) allocation and traversal when no new
element can possibly be started.

Result:
In steady state (all parallelism slots busy), each future completion
avoids an unnecessary O(n) buffer snapshot. The benefit scales with
buffer size and parallelism.

Tests:
- sbt "stream-tests / Test / testOnly 
org.apache.pekko.stream.scaladsl.FlowMapAsyncPartitionedSpec"
- sbt "stream-typed-tests / Test / testOnly 
org.apache.pekko.stream.MapAsyncPartitionedSpec"

References:
Refs akka/akka-core#32031

Report URL: https://github.com/apache/pekko/actions/runs/31874822272

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to