final case class CausalProfiler(iterations: Int = 100, candidateSelector: (String) => Boolean = _ => true, samplingPeriod: zio.Duration = 20.millis, minExperimentDuration: zio.Duration = 1.second, experimentTargetSamples: Int = 30, warmUpPeriod: zio.Duration = 30.seconds, coolOffPeriod: zio.Duration = 2.seconds, zeroSpeedupWeight: Int = 10, maxConsideredSpeedUp: Int = 100, sleepPrecision: zio.Duration = 10.millis) extends Product with Serializable
A causal profiler inspired by https://github.com/plasma-umass/coz, that can be used to instrument code and automatically figure out which areas should be optimized to increase overall throughput.
The profiler will periodically select regions of code for optimization and will artifically speed them up by slowing down all code that runs concurrently with it. It will determine throughput based on the number of times that zio.profiling.causal.CausalProfiler.progressPoint has been invoked during an experiment.
Only zio.profiling.CostCenter will be considered for optimization, so make sure to tag the code.
- iterations
the number of experiments to perform
- candidateSelector
when a new experiment is about to be performed, this is used to decide on a candidate for optimization
- samplingPeriod
how often data about fiber locations gets collected. Lower values increase the overhead of the profiler.
- minExperimentDuration
minimum duration of an experiment
- experimentTargetSamples
number of times every progress point should be invoked during an experiment. will be used to adjust duration of the next experiment.
- warmUpPeriod
period of time to delay start of the profiler.
- coolOffPeriod
period of time to wait between experiments.
- zeroSpeedupWeight
rate of selecting no speedup for the experiment. A
zeroSpeedupWeight
of n means that that every nth experiment will have no speedup applied.- maxConsideredSpeedUp
maximum speedup percentage that will be selected for experiments. Values over 100 do not have any practical use.
- sleepPrecision
estimated precision of
Thread.sleep
. The profiler will busy spin once it enters this proximity to the target time in order to increase accuraccy.
- Alphabetic
- By Inheritance
- CausalProfiler
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new CausalProfiler(iterations: Int = 100, candidateSelector: (String) => Boolean = _ => true, samplingPeriod: zio.Duration = 20.millis, minExperimentDuration: zio.Duration = 1.second, experimentTargetSamples: Int = 30, warmUpPeriod: zio.Duration = 30.seconds, coolOffPeriod: zio.Duration = 2.seconds, zeroSpeedupWeight: Int = 10, maxConsideredSpeedUp: Int = 100, sleepPrecision: zio.Duration = 10.millis)
- iterations
the number of experiments to perform
- candidateSelector
when a new experiment is about to be performed, this is used to decide on a candidate for optimization
- samplingPeriod
how often data about fiber locations gets collected. Lower values increase the overhead of the profiler.
- minExperimentDuration
minimum duration of an experiment
- experimentTargetSamples
number of times every progress point should be invoked during an experiment. will be used to adjust duration of the next experiment.
- warmUpPeriod
period of time to delay start of the profiler.
- coolOffPeriod
period of time to wait between experiments.
- zeroSpeedupWeight
rate of selecting no speedup for the experiment. A
zeroSpeedupWeight
of n means that that every nth experiment will have no speedup applied.- maxConsideredSpeedUp
maximum speedup percentage that will be selected for experiments. Values over 100 do not have any practical use.
- sleepPrecision
estimated precision of
Thread.sleep
. The profiler will busy spin once it enters this proximity to the target time in order to increase accuraccy.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- val candidateSelector: (String) => Boolean
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- val coolOffPeriod: zio.Duration
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- val experimentTargetSamples: Int
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val iterations: Int
- val maxConsideredSpeedUp: Int
- val minExperimentDuration: zio.Duration
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def profile[R, E](zio: ZIO[R, E, Nothing])(implicit trace: Trace): ZIO[R, E, ProfilingResult]
Profile a program and get the result.
Profile a program and get the result. The program must run long enough for the profiler to complete and will be interrupted once the profiling is done.
The profiled program must use the
progressPoint
function to signal progress to the profiler. - def profileIterations[R, E](zio: ZIO[R, E, Any])(implicit trace: Trace): ZIO[R, E, ProfilingResult]
Profile a zio program by running it in a loop and using completion of an iteration as the progress metric.
Profile a zio program by running it in a loop and using completion of an iteration as the progress metric.
profileIterations { val fast = ZIO.succeed(Thread.sleep(20)) <# "fast" val slow = ZIO.succeed(Thread.sleep(60)) <# "slow" fast <&> slow }
- val samplingPeriod: zio.Duration
- val sleepPrecision: zio.Duration
- def supervisor(implicit trace: Trace): ZIO[Scope, Nothing, Supervisor[ProfilingResult]]
Create a supervisor that can be used to profile a zio program.
Create a supervisor that can be used to profile a zio program. Getting the
value
of the supervisor will suspend until profiling to complete. For profiling to work correctly, OpSupervision must be enabled for the effect. - final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- val warmUpPeriod: zio.Duration
- val zeroSpeedupWeight: Int