Skip to content
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

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants