laserdisc-io/tamer

Lower CPU usage

Closed this issue · 1 comments

@barambani noticed with S3 module tamer uses 100% cpu.
I suspect because of

ZStream.fromEffect(sink(q, p, sinkRegistry).forever.fork <* log.info("running sink perpetually")).flatMap { fiber =>

More evidence comes from dumping the fibers in a random moment:

#64 (14m871s871268ms) 
   Status: Running()
Fiber:Id(1613749779114,64) was supposed to continue to:
  a future continuation at zio.ZIO.forever(ZIO.scala:686)

Fiber:Id(1613749779114,64) execution trace:
  at zio.ZIO.forever(ZIO.scala:686)
  at zio.ZIO.unit(ZIO.scala:2014)
  at log.effect.LogWriterConstructor$$anon$1$$anon$2.write(LogWriterConstructor.scala:31)
  at tamer.kafka.Kafka$$anon$1.runLoop(Kafka.scala:66)
  at zio.ZQueue$$anon$4.takeAll(ZQueue.scala:627)
  at zio.ZIO$.effectSuspendTotal(ZIO.scala:2662)
  ...

Do you think this is the problem?
Should we solve it by using take, which suspends, instead of takeAll that continuously returning an empty list?

As discussed offline, let's try take.