Closed jeanmarc closed 9 months ago
Turns out, the issue is caused by not adding any CostCenter.withChildCostCenter
statements (the plugin isn't working, so this needed to be done manually). Revised code works as expected:
import zio.*
import zio.profiling.causal.*
import zio.profiling.CostCenter
object Main extends ZIOAppDefault {
val fast = CostCenter.withChildCostCenter("fast")(ZIO.succeed {
Thread.sleep(400)
println("A")
})
val slow1 = CostCenter.withChildCostCenter("slow1")(ZIO.succeed {
Thread.sleep(600)
println("B")
})
val slow2 = CostCenter.withChildCostCenter("slow2")(ZIO.succeed {
Thread.sleep(200)
println("C")
})
val slow = slow1 <&> slow2
val program = (fast <&> slow) *> CausalProfiler.progressPoint("iteration done")
def run = CausalProfiler(
iterations = 20,
warmUpPeriod = Duration.fromSeconds(1)
).profile(program.forever).flatMap(_.renderToFile("profile.coz"))
//def run = program
}
I am using Scala3 (3.3.0), ZIO (2.0.18), and ZIO Profiling (0.2.1) and try to run the causal profiler example from the readme.
When I run this app, it emits 1 log message about warmup and then hangs indefinitely (at least more than 30 minutes).
What am I doing wrong?
The main class is in an sbt module that has these dependencies:
(I get compiler errors when adding the
compilerPlugin("dev.zio" %% "zio-profiling-tagging-plugin" % "0.2.1")
to thelibraryDependencies
, so I omitted that one)