zio icon indicating copy to clipboard operation
zio copied to clipboard

mapZIOParUnordered does not respect parallelism

Open adrian-salajan opened this issue 10 months ago • 4 comments

I am surprised of what this program using mapZIOParUnordered outputs

  override def run: ZIO[Any with ZIOAppArgs with Scope, Any, Any] = for {
    _ <- ZIO.debug("start")
    _ <- ZStream
      .iterate[Int](0)(n => n +1)
      .mapZIOParUnordered(2){ _ =>
        ZIO.debug("tick").delay(1.second)
      }.runDrain.zipParLeft(ZIO.debug("----").delay(2.seconds).forever)

  } yield ()

the number of ticks printed between the ----- is: 2, 7, 11, 15, 19, 23 .... while if instead of mapZIOParUnordered(2) i use mapZioPar(2) ticks printed is: 2, 6, 6, 6, 6. Here i would expect it to be 4, 4, 4, 4 but at least it does not keep increasing

adrian-salajan avatar Apr 16 '24 06:04 adrian-salajan

/bounty $100

jdegoes avatar May 08 '24 17:05 jdegoes

💎 $100 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #8753 with your implementation plan
  2. Submit work: Create a pull request including /claim #8753 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🔴 @varshith257 May 20, 2024, 2:57:18 PM WIP

algora-pbc[bot] avatar May 08 '24 17:05 algora-pbc[bot]

/attempt #8753

varshith257 avatar May 20 '24 14:05 varshith257

@varshith257: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

algora-pbc[bot] avatar May 27 '24 14:05 algora-pbc[bot]

The bounty is up for grabs! Everyone is welcome to /attempt #8753 🙌

algora-pbc[bot] avatar Jun 03 '24 14:06 algora-pbc[bot]

Can't reproduce your issue with zio 2.1.3 neither with 2.1.2 https://scastie.scala-lang.org/narma/Vt1F43dAQ8un6yfvK9YLTA/2

narma avatar Jun 12 '24 16:06 narma