-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bench] disable HttpClientRaceContentionBench (#796)
The benchmark is failing for both Kyo and ZIO. This PR comments out the benchmark as a workaround for now so we can can run the benchmark suite in CI
- Loading branch information
Showing
1 changed file
with
81 additions
and
81 deletions.
There are no files selected for viewing
162 changes: 81 additions & 81 deletions
162
kyo-bench/src/main/scala/kyo/bench/HttpClientRaceContentionBench.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,81 @@ | ||
package kyo.bench | ||
|
||
import org.http4s.ember.client.EmberClientBuilder | ||
|
||
class HttpClientRaceContentionBench | ||
extends Bench.ForkOnly("pong"): | ||
|
||
override val zioRuntimeLayer = super.zioRuntimeLayer.merge(zio.http.Client.default) | ||
|
||
val concurrency = 100 | ||
val url = TestHttpServer.start(concurrency) | ||
|
||
lazy val catsClient = | ||
import cats.effect.* | ||
import cats.effect.unsafe.implicits.global | ||
EmberClientBuilder.default[IO].build.allocated.unsafeRunSync()._1 | ||
end catsClient | ||
|
||
val catsUrl = | ||
import org.http4s.* | ||
Uri.fromString(url).toOption.get | ||
|
||
def catsBench() = | ||
import cats.* | ||
import cats.effect.* | ||
import cats.implicits.* | ||
import cats.effect.implicits.* | ||
|
||
// from https://github.com/jamesward/easyracer/blob/a9aa01afefe00ab905af53a27bb2e2f005b0d00d/scala-ce3/src/main/scala/EasyRacerClient.scala#L92 | ||
def multiRace[F[_]: Concurrent, A](fas: Seq[F[A]]): F[A] = | ||
def spawn[B](fa: F[B]): Resource[F, Unit] = | ||
Resource.make(fa.start)(_.cancel).void | ||
|
||
def finish(fa: F[A], d: Deferred[F, Either[Throwable, A]]): F[Unit] = | ||
fa.attempt.flatMap(d.complete).void | ||
|
||
Deferred[F, Either[Throwable, A]] | ||
.flatMap { result => | ||
fas | ||
.traverse(fa => spawn(finish(fa, result))) | ||
.use(_ => result.get.rethrow) | ||
} | ||
end multiRace | ||
|
||
multiRace(Seq.fill(concurrency)(catsClient.expect[String](catsUrl))) | ||
end catsBench | ||
|
||
lazy val kyoClient = | ||
import kyo.* | ||
import AllowUnsafe.embrace.danger | ||
IO.Unsafe.run(Meter.initSemaphore(5).map(PlatformBackend.default.withMeter)).eval | ||
end kyoClient | ||
|
||
val kyoUrl = | ||
import sttp.client3.* | ||
uri"$url" | ||
|
||
override def kyoBenchFiber() = | ||
import kyo.* | ||
|
||
Async.race(Seq.fill(concurrency)(Requests.let(kyoClient)(Requests(_.get(kyoUrl))))) | ||
end kyoBenchFiber | ||
|
||
val zioUrl = | ||
import zio.http.* | ||
URL.decode(this.url).toOption.get | ||
|
||
def zioBench() = | ||
import zio.* | ||
import zio.http.* | ||
|
||
val request = | ||
ZIO.service[Client] | ||
.flatMap(_.url(zioUrl).get("")) | ||
.flatMap(_.body.asString) | ||
.provideSome[Client](Scope.default) | ||
.asInstanceOf[Task[String]] | ||
ZIO.raceAll(request, Seq.fill(concurrency - 1)(request)).orDie | ||
end zioBench | ||
|
||
end HttpClientRaceContentionBench | ||
// package kyo.bench | ||
|
||
// import org.http4s.ember.client.EmberClientBuilder | ||
|
||
// class HttpClientRaceContentionBench | ||
// extends Bench.ForkOnly("pong"): | ||
|
||
// override val zioRuntimeLayer = super.zioRuntimeLayer.merge(zio.http.Client.default) | ||
|
||
// val concurrency = 100 | ||
// val url = TestHttpServer.start(concurrency) | ||
|
||
// lazy val catsClient = | ||
// import cats.effect.* | ||
// import cats.effect.unsafe.implicits.global | ||
// EmberClientBuilder.default[IO].build.allocated.unsafeRunSync()._1 | ||
// end catsClient | ||
|
||
// val catsUrl = | ||
// import org.http4s.* | ||
// Uri.fromString(url).toOption.get | ||
|
||
// def catsBench() = | ||
// import cats.* | ||
// import cats.effect.* | ||
// import cats.implicits.* | ||
// import cats.effect.implicits.* | ||
|
||
// // from https://github.com/jamesward/easyracer/blob/a9aa01afefe00ab905af53a27bb2e2f005b0d00d/scala-ce3/src/main/scala/EasyRacerClient.scala#L92 | ||
// def multiRace[F[_]: Concurrent, A](fas: Seq[F[A]]): F[A] = | ||
// def spawn[B](fa: F[B]): Resource[F, Unit] = | ||
// Resource.make(fa.start)(_.cancel).void | ||
|
||
// def finish(fa: F[A], d: Deferred[F, Either[Throwable, A]]): F[Unit] = | ||
// fa.attempt.flatMap(d.complete).void | ||
|
||
// Deferred[F, Either[Throwable, A]] | ||
// .flatMap { result => | ||
// fas | ||
// .traverse(fa => spawn(finish(fa, result))) | ||
// .use(_ => result.get.rethrow) | ||
// } | ||
// end multiRace | ||
|
||
// multiRace(Seq.fill(concurrency)(catsClient.expect[String](catsUrl))) | ||
// end catsBench | ||
|
||
// lazy val kyoClient = | ||
// import kyo.* | ||
// import AllowUnsafe.embrace.danger | ||
// IO.Unsafe.run(Meter.initSemaphore(5).map(PlatformBackend.default.withMeter)).eval | ||
// end kyoClient | ||
|
||
// val kyoUrl = | ||
// import sttp.client3.* | ||
// uri"$url" | ||
|
||
// override def kyoBenchFiber() = | ||
// import kyo.* | ||
|
||
// Async.race(Seq.fill(concurrency)(Requests.let(kyoClient)(Requests(_.get(kyoUrl))))) | ||
// end kyoBenchFiber | ||
|
||
// val zioUrl = | ||
// import zio.http.* | ||
// URL.decode(this.url).toOption.get | ||
|
||
// def zioBench() = | ||
// import zio.* | ||
// import zio.http.* | ||
|
||
// val request = | ||
// ZIO.service[Client] | ||
// .flatMap(_.url(zioUrl).get("")) | ||
// .flatMap(_.body.asString) | ||
// .provideSome[Client](Scope.default) | ||
// .asInstanceOf[Task[String]] | ||
// ZIO.raceAll(request, Seq.fill(concurrency - 1)(request)).orDie | ||
// end zioBench | ||
|
||
// end HttpClientRaceContentionBench |