← ZIO Profiling docs

CausalProfiler

zio.profiling.causal.CausalProfiler
See theCausalProfiler companion object
final case class CausalProfiler(iterations: Int = ..., candidateSelector: String => Boolean = ..., samplingPeriod: Duration = ..., minExperimentDuration: Duration = ..., experimentTargetSamples: Int = ..., warmUpPeriod: Duration = ..., coolOffPeriod: Duration = ..., zeroSpeedupWeight: Int = ..., maxConsideredSpeedUp: Int = ..., sleepPrecision: Duration = ...)

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.

Value parameters

candidateSelector

when a new experiment is about to be performed, this is used to decide on a candidate for optimization

coolOffPeriod

period of time to wait between experiments.

experimentTargetSamples

number of times every progress point should be invoked during an experiment. will be used to adjust duration of the next experiment.

iterations

the number of experiments to perform

maxConsideredSpeedUp

maximum speedup percentage that will be selected for experiments. Values over 100 do not have any practical use.

minExperimentDuration

minimum duration of an experiment

samplingPeriod

how often data about fiber locations gets collected. Lower values increase the overhead of the profiler.

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.

warmUpPeriod

period of time to delay start of the profiler.

zeroSpeedupWeight

rate of selecting no speedup for the experiment. A zeroSpeedupWeight of n means that that every nth experiment will have no speedup applied.

Attributes

Companion
object
Source
CausalProfiler.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def profile[R, E](zio: ZIO[R, E, Nothing])(implicit trace: Trace): ZIO[R, E, ProfilingResult]

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.

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.

Attributes

Source
CausalProfiler.scala
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
}

Attributes

Source
CausalProfiler.scala
def supervisor(implicit trace: Trace): ZIO[Scope, Nothing, Supervisor[ProfilingResult]]

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.

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.

Attributes

Source
CausalProfiler.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product