Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

isReachable is blocking fibers on thread pool #688

Open
eugeny-stoyka opened this issue Jul 20, 2024 · 3 comments
Open

isReachable is blocking fibers on thread pool #688

eugeny-stoyka opened this issue Jul 20, 2024 · 3 comments

Comments

@eugeny-stoyka
Copy link

eugeny-stoyka commented Jul 20, 2024

Hello, i had problem with parallelism on this code (it block my fibers on it, and CPU utilization was on ~1%)

def run: ZIO[Any, Throwable, Unit] = {
  ipStream.mapZIOParUnordered(100000) {
        for {
          ipaddr <- InetAddress.byName(ip.toString)
          r <- ipaddr.isReachable(10000)
          _ <- if(r) Console.printLine(ip) else ZIO.none
        } yield ()
  }.runDrain
}

can you add new or edit current behavior of isReachable

def run: ZIO[Any, Throwable, Unit] = {
  ipStream.mapZIOParUnordered(100000) {
      ip =>
        for {
          ipaddr <- InetAddress.byName(ip.toString)
          r <- ZIO.blocking(ipaddr.isReachable(10000))
          _ <- if(r) Console.printLine(ip) else ZIO.none
        } yield ()
  }.runDrain
}
@erikvanoosten
Copy link

From Discord I understood that the request is to make InetAddress.byName and InetAddress.isReachable run on the blocking threadpool.

@eugeny-stoyka
Copy link
Author

eugeny-stoyka commented Jul 20, 2024

or add a new method out of box for it

@eugeny-stoyka
Copy link
Author

is you accept it, can i add it to this zio-nio project?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants