scheduler (runtime_tools v1.16.2)

This module contains utility functions for easier measurement and calculation of scheduler utilization, otherwise obtained from calling the more primitive statistics(scheduler_wall_time).

The simplest usage is to call scheduler:utilization(Seconds).

Link to this section Summary

Types

A list of tuples containing results for individual schedulers as well as aggregated averages. Util is the scheduler utilization as a floating point value between 0.0 and 1.0. Percent is the same utilization as a more human readable string expressed in percent.

Functions

Return a scheduler utilization sample for normal and dirty-cpu schedulers.

Return a scheduler utilization sample for all schedulers, including dirty-io schedulers.

Measure utilization for normal and dirty-cpu schedulers during Seconds seconds, and then return the result.

Calculate scheduler utilizations for the time interval from when Sample was taken and "now". The same as calling scheduler:utilization(Sample, scheduler:sample_all()).

Calculates scheduler utilizations for the time interval between the two samples obtained from calling sample/0 or sample_all/0.

Link to this section Types

Link to this type

-type sched_id() :: term().

Specs

sched_id() :: integer().
Link to this opaque

-type sched_sample() :: term().

(opaque)

Specs

sched_sample()
Link to this type

-type sched_type() :: term().

Specs

sched_type() :: normal | cpu | io.
Link to this type

-type sched_util_result() :: term().

Specs

sched_util_result() ::
    [{sched_type(), sched_id(), float(), string()} |
     {total, float(), string()} |
     {weighted, float(), string()}].

A list of tuples containing results for individual schedulers as well as aggregated averages. Util is the scheduler utilization as a floating point value between 0.0 and 1.0. Percent is the same utilization as a more human readable string expressed in percent.

{normal, SchedulerId, Util, Percent}
Scheduler utilization of a normal scheduler with number SchedulerId. Schedulers that are not online will also be included. Online schedulers have the lowest SchedulerId.
{cpu, SchedulerId, Util, Percent}
Scheduler utilization of a dirty-cpu scheduler with number SchedulerId.
{io, SchedulerId, Util, Percent}
Scheduler utilization of a dirty-io scheduler with number SchedulerId. This tuple will only exist if both samples were taken with sample_all/0.
{total, Util, Percent}
Total utilization of all normal and dirty-cpu schedulers.
{weighted, Util, Percent}
Total utilization of all normal and dirty-cpu schedulers, weighted against maximum amount of available CPU time.

Link to this section Functions

Link to this function

sample/0

(since OTP 21.0)

Specs

sample() -> sched_sample().

Return a scheduler utilization sample for normal and dirty-cpu schedulers.

Link to this function

sample_all/0

(since OTP 21.0)

Specs

sample_all() -> sched_sample().

Return a scheduler utilization sample for all schedulers, including dirty-io schedulers.

Link to this function

utilization/1

(since OTP 21.0)

Specs

utilization(Seconds) -> sched_util_result() when Seconds :: pos_integer();
           (Sample) -> sched_util_result() when Sample :: sched_sample().

Measure utilization for normal and dirty-cpu schedulers during Seconds seconds, and then return the result.

Link to this function

utilization/1

(since OTP 21.0)

Specs

utilization(Seconds) -> sched_util_result() when Seconds :: pos_integer();
           (Sample) -> sched_util_result() when Sample :: sched_sample().

Calculate scheduler utilizations for the time interval from when Sample was taken and "now". The same as calling scheduler:utilization(Sample, scheduler:sample_all()).

Scheduler utilization is measured as an average value over a time interval, calculated as the difference between two samples. To get good useful utilization values at least a couple of seconds should have passed between the two samples. For this reason, you should not do

scheduler:utilization(scheduler:sample()). % DO NOT DO THIS!

The above example takes two samples in rapid succession and calculates the scheduler utilization between them. The resulting values will probably be more misleading than informative.

Instead use scheduler:utilization(Seconds) or let some time pass between Sample=scheduler:sample() and scheduler:utilization(Sample).

Link to this function

utilization/2

(since OTP 21.0)

Specs

utilization(Sample1, Sample2) -> sched_util_result()
               when Sample1 :: sched_sample(), Sample2 :: sched_sample().

Calculates scheduler utilizations for the time interval between the two samples obtained from calling sample/0 or sample_all/0.