Conversation
|
Can you post the HTTP benchmark results? It might help show if there's a leak. |
|
As discussed offline, there may be a leak. I think zio-http needs I've seen the The client is being reused 🙂 |
| else | ||
| zio.Runtime.default.unsafe | ||
| else | ||
| KyoSchedulerZioRuntime.default.unsafe |
There was a problem hiding this comment.
Would it be possible to support the case when Kyo's scheduler is enabled for ZIO?
There was a problem hiding this comment.
With the layer mechanism? Definitely
There was a problem hiding this comment.
I just pushed a change to do so, but I realized that the override val zioRuntimeLayer = zio.http.Client.default will hide the fact that the kyo scheduler is not being used. We would need to write:
override def zioRuntimeLayer = super.zioRuntimeLayer ++ zio.http.Client.default
There was a problem hiding this comment.
I think it could be a def since zioRuntime is a lazy val and will call zioRuntimeLayer only once. Don't you need to handle the else branch here when Kyo's scheduler is enabled?
There was a problem hiding this comment.
You are correct, we need to ensure the kyo scheduler is combined with the layers in the child bench. This is fixed in my latest commit.
|
The updated code with finalizers fixes the shutdown problem. Netty still throws some random errors intermittently - though I don't know if we can fix that. |
Are the errors after the benchmark execution? It should be ok if that's the case. |
hearnadam
left a comment
There was a problem hiding this comment.
jmh:clean;kyo-bench/jmh:run -wi 15 -i 5 -r 1 -w 1 -f 1 -t 1 -foe true Http
[info] Benchmark Mode Cnt Score Error Units
[info] HttpClientBench.forkCats thrpt 5 8371.550 ± 1340.961 ops/s
[info] HttpClientBench.forkKyo thrpt 5 10806.917 ± 5024.439 ops/s
[info] HttpClientBench.forkZio thrpt 5 1429.425 ± 1310.774 ops/s
[info] HttpClientContentionBench.forkCats thrpt 5 3147.521 ± 787.903 ops/s
[info] HttpClientContentionBench.forkKyo thrpt 5 3686.940 ± 981.584 ops/s
[info] HttpClientContentionBench.forkZio thrpt 5 695.971 ± 616.321 ops/s
[info] HttpClientRaceContentionBench.forkCats thrpt 5 1.539 ± 1.978 ops/s
[info] HttpClientRaceContentionBench.forkKyo thrpt 5 70.515 ± 227.973 ops/s
[info] HttpClientRaceContentionBench.forkZio thrpt 5 58.362 ± 59.659 ops/s
Still seeing errors like:
[error] May 22, 2024 9:15:31 PM io.netty.channel.kqueue.KQueueEventLoop processReady
[error] WARNING: events[0]=[153, -1] had no channel!
But that may be a bug/issue with zio-http.
|
|
||
| class HttpClientBench extends Bench.ForkOnly("pong"): | ||
|
|
||
| override val zioRuntimeLayer = super.zioRuntimeLayer.merge(zio.http.Client.default) |
There was a problem hiding this comment.
theoretically I think we could make the parent class do this, but we would need to make Bench accept an R parameter. Adding to a ZEnvironment will need a tag for the type representation.
Let me know what you think @fwbrasil
| extension (parent: ZLayer[Any, Any, Any]) | ||
| def merge[R](child: ZLayer[Any, Any, R])(using Tag[R]): ZLayer[Any, Any, R] = |
There was a problem hiding this comment.
Are you okay with this being in this file?
This is the only way I can think of to initialize a zio-http client once... the zlayer -> runtime mechanism is not type safe, but I don't expect it to be widely used.
Hopefully I fixed the resource leak I had in #354
/resolves #329
/claim #329