zio
zio copied to clipboard
mapZIOParUnordered does not respect parallelism
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
/bounty $100
💎 $100 bounty • ZIO
Steps to solve:
-
Start working: Comment
/attempt #8753
with your implementation plan -
Submit work: Create a pull request including
/claim #8753
in the PR body to claim the bounty - 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 bounty • Share on socials
Attempt | Started (GMT+0) | Solution |
---|---|---|
🔴 @varshith257 | May 20, 2024, 2:57:18 PM | WIP |
/attempt #8753
@varshith257: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏
The bounty is up for grabs! Everyone is welcome to /attempt #8753
🙌
Can't reproduce your issue with zio 2.1.3 neither with 2.1.2 https://scastie.scala-lang.org/narma/Vt1F43dAQ8un6yfvK9YLTA/2