-
Notifications
You must be signed in to change notification settings - Fork 83
Update zio to 2.1.0-RC3 in benchmarks #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thank you @kyri-petrou! Yes, please feel free to submit library upgrades and even new benchmarks, especially if they show areas that Kyo doesn't perform well! We have similar benchmarks to the one you used for the optimization but with some important differences that can influence performance. I've prepared a PR with a port of ZIO's benchmark: #304. What is the |
|
I was trying to check how ZIO performs with Kyo's scheduler but I'm having trouble to configure it. My failed attempt so far: @Benchmark
def forkZio(): T = zio.Unsafe.unsafe(implicit u =>
val exec = new ZioKyoExecutor
zio.Runtime.unsafe.fromLayer(zio.Runtime.setExecutor(exec) ++ zio.Runtime.setBlockingExecutor(exec))
.run(zio.ZIO.yieldNow.flatMap(_ => zioBench())).getOrThrow()
)I also wanted to remove this configuration from the hot path of the benchmark execution and put the runtime in a pre-initialized |
|
You can use Unsafe.unsafe{ } directly to remove the unsafe requirement. |
|
@fwbrasil I think the best way to
I think the best way to do this would be something along these lines: import kyo.scheduler.Scheduler as KyoScheduler
import zio.*
object ZioRunner {
private given Unsafe = Unsafe.unsafe(identity)
private val kExecutorLayer = Runtime.setExecutor(Executor.fromJavaExecutor(KyoScheduler.get.asExecutor))
private val rt = Runtime.unsafe.fromLayer(kExecutorLayer).unsafe
def run[A](f: ZIO[Any, Throwable, A]) = rt.run(f).getOrThrowFiberFailure()
}Note that in Scala 3 you could also do this (notice it's def run[A](f: ZIO[Any, Throwable, A]) = Unsafe.unsafely(rt.run(f).getOrThrowFiberFailure()) |
@fwbrasil The The tracking of fibers is mostly necessary for being able to interrupt them safely and await for their completion when the application exits |
|
@kyri-petrou Thanks for the tips! I used a similar approach to set the executor in #306. There's a performance regression I still have to investigate. About For safe closing of resources, maybe you could track the resources themselves instead of all fibers since it's typically a much smaller set? For fiber dumps, the scheduler itself should already have a reference to all active fibers but that would have a compromise of not reporting suspended fibers. |
|
@fwbrasil thanks for the recommendations! I agree that By the way zio v2.1.0-RC4 was just released where I added a very convenient method for disabling runtime flags. Unsafe.unsafely {
Runtime.unsafe.fromLayer(Runtime.disableFlags(RuntimeFlag.FiberRoots)).unsafe
} |
Hey Kyo team π Let me start by saying that I'm a huge fan of the work you've been doing, and that I've been following a lot of it from the sidelines. Also really looking forward to trying out the new
kyo-schedulernow that it's been made into a separate module and cross compiled for Scala 2 as well!So just a small introduction: I've been actively contributing to Caliban for quite some time now, but since the departure of Adam from Ziverge I've been actively contributing / maintaining
zioand otherzio-*libraries; which brings me to why I'm opening this PR. We'll be soon releasing ZIO 2.1.0 (hopefully no more than 1-2 more RC versions before we pull the trigger). The 2.1.0 version has a fully redesigned fiber runtime, and had some very extensive optimizations done to improve fork-join performance. While the benchmarks in the ZIO repo show some significant improvements, I would like to see how it also performs in external benchmarks and whether we might have any regressions in areas that we're not capturing well.If it's okay with you, would you mind to update the zio version in your benchmarks to the latest RC to see how it performs and compares against the 2.0.x version and the rest of the Scala effect libraries in your benchmarks?