bart.sched.functions module¶
Scheduler specific Functionality for the stats framework
The Scheduler stats aggregation is based on a signal which is generated by the combination of two triggers from the events with the following parameters
EVENT | VALUE | FILTERS |
---|---|---|
sched_switch() |
1 | next_pid |
sched_switch() |
-1 | prev_pid |
Both these Triggers are provided by the event
trappy.sched.SchedSwitch
which correspond to
the sched_switch
unique word in the trace
See also
trappy.stats.Trigger.Trigger
Using the above information the following signals are generated.
EVENT SERIES
This is a combination of the two triggers as specified above and has alternating +/- 1 values and is merely a representation of the position in time when the process started or stopped running on a CPU
RESIDENCY SERIES
This series is a cumulative sum of the event series and is a representation of the continuous residency of the process on a CPU
The pivot for the aggregators is the CPU on which the event occurred on. If N is the number of CPUs in the system, N signal for each CPU are generated. These signals can then be aggregated by specifying a Topology
See also
trappy.stats.Topology.Topology
-
bart.sched.functions.
CPU_FIELD
= '__cpu'¶ The column in the sched_switch event that indicates the CPU on which the event occurred
-
bart.sched.functions.
NEXT_PID_FIELD
= 'next_pid'¶ The column in the sched_switch event that indicates the PID of the next process to be scheduled
-
bart.sched.functions.
NO_EVENT
= 0¶ Signifies no event on an event trace
-
bart.sched.functions.
PREV_PID_FIELD
= 'prev_pid'¶ The column in the sched_switch event that indicates the PID of the process that was scheduled in
-
bart.sched.functions.
SCHED_SWITCH_IN
= 1¶ Value of the event when a task is switch in or scheduled on a CPU
-
bart.sched.functions.
SCHED_SWITCH_OUT
= -1¶ Value of the event when a task is switched out or relinquishes a CPU
-
bart.sched.functions.
SERIES_SANTIZED
= '_sched_sanitized'¶ A memoized flag which is set when an event series is checked for boundary conditions
-
bart.sched.functions.
TASK_NOT_RUNNING
= 0¶ In a residency series, a zero indicates that the task is not running
-
bart.sched.functions.
TASK_RUNNING
= 1¶ The column in the sched_switch event that indicates the CPU on which the event occurred
-
bart.sched.functions.
TIME_INVAL
= -1¶ Standard Value to indicate invalid time data
-
bart.sched.functions.
WINDOW_SIZE
= 0.0001¶ A control config for filter events. Some analyses may require ignoring of small interruptions
-
bart.sched.functions.
binary_correlate
(series_x, series_y)[source]¶ Helper function to Correlate binary Data
Both the series should have same indices
For binary time series data:
\[\alpha_{corr} = \frac{N_{agree} - N_{disagree}}{N}\]Parameters: - series_x (
pandas.Series
) – First time Series data - series_y (
pandas.Series
) – Second time Series data
- series_x (
-
bart.sched.functions.
csum
(series, window=None, filter_gaps=False)[source]¶ aggfunc()
for the cumulative sum of the input series dataParameters: - series (
pandas.Series
) – Input Time Series data - window (tuple) – A tuple indicating a time window
- filter_gaps (bool) – If set, a process being switched out
for
bart.sched.functions.WINDOW_SIZE
is ignored. This is helpful when small interruptions need to be ignored to compare overall correlation
- series (
-
bart.sched.functions.
filter_small_gaps
(series)[source]¶ A helper function that does filtering of gaps in residency series <
bart.sched.functions.WINDOW_SIZE
Parameters: series ( pandas.Series
) – Input Time Series data
-
bart.sched.functions.
first_cpu
(series, window=None)[source]¶ aggfunc()
to calculate the time of the first switch in event in the series This is returned as a vector of unit length so that it can be aggregated and reduced across nodes to find the first cpu of a taskParameters: - series (
pandas.Series
) – Input Time Series data - window (tuple) – A tuple indicating a time window
- series (
-
bart.sched.functions.
first_time
(series, value, window=None)[source]¶ aggfunc()
to:- Return the first index where the series == value
- If no such index is found +inf is returned
Parameters: - series (
pandas.Series
) – Input Time Series data - window (tuple) – A tuple indicating a time window
Returns: A vector of Unit Length
-
bart.sched.functions.
get_pids_for_process
(ftrace, execname, cls=None)[source]¶ Get the PIDs for a given process
Parameters: - ftrace (
trappy.ftrace.FTrace
) – A ftrace object with a sched_switch event - execname (str) – The name of the process
- cls (
trappy.base.Base
) – The SchedSwitch event class (required if a different event is to be used)
Returns: The set of PIDs for the execname
- ftrace (
-
bart.sched.functions.
get_task_name
(ftrace, pid, cls=None)[source]¶ Returns the execname for pid
Parameters: - ftrace (
trappy.ftrace.FTrace
) – A ftrace object with a sched_switch event - pid (int) – The PID of the process
- cls (
trappy.base.Base
) – The SchedSwitch event class (required if a different event is to be used)
Returns: The execname for the PID
- ftrace (
-
bart.sched.functions.
last_cpu
(series, window=None)[source]¶ aggfunc()
to calculate the time of the last switch out event in the series This is returned as a vector of unit length so that it can be aggregated and reduced across nodes to find the last cpu of a taskParameters: - series (
pandas.Series
) – Input Time Series data - window (tuple) – A tuple indicating a time window
- series (
-
bart.sched.functions.
last_time
(series, value, window=None)[source]¶ aggfunc()
to:- The first index where the series == value
- If no such index is found
bart.sched.functions.TIME_INVAL
is returned
Parameters: - series (
pandas.Series
) – Input Time Series data - window (tuple) – A tuple indicating a time window
Returns: A vector of Unit Length
-
bart.sched.functions.
period
(series, align='start', window=None)[source]¶ This
aggfunc()
returns a tuple of the average duration between two triggers:- When
align=start
theSCHED_IN
trigger is used - When
align=end
theSCHED_OUT
trigger is used
\[\begin{split}E = e_{1}, e_{2}...e_{N} \\ T_p = \frac{\sum_{j}^{\lfloor N/2 \rfloor}(e_{2j + 1} - e_{2j})}{N}\end{split}\]Parameters: - series (
pandas.Series
) – Input Time Series data - window (tuple) – A tuple indicating a time window
Returns: A list of deltas of successive starts/stops of a task
- When
-
bart.sched.functions.
residency_sum
(series, window=None)[source]¶ aggfunc()
to calculate the total residencyThe input series is processed for intervals between a
bart.sched.functions.SCHED_SWITCH_OUT
andbart.sched.functions.SCHED_SWITCH_IN
to track additive residency of a task\[\begin{split}S_{in} = i_{1}, i_{2}...i_{N} \\ S_{out} = o_{1}, o_{2}...o_{N} \\ R_{total} = \sum_{k}^{N}\Delta_k = \sum_{k}^{N}(o_{k} - i_{k})\end{split}\]Parameters: - series (
pandas.Series
) – Input Time Series data - window (tuple) – A tuple indicating a time window
Returns: A scalar float value
- series (
-
bart.sched.functions.
sanitize_asymmetry
(series, window=None)[source]¶ Sanitize the cases when a
SWITCH_OUT
happens before aSWITCH_IN
. (The case when a process is already running before the trace started)Parameters: - series (
pandas.Series
) – Input Time Series data - window (tuple) – A tuple indicating a time window
- series (
-
bart.sched.functions.
sched_switch_in_trigger
(ftrace, pid, sched_switch_class)[source]¶ Parameters: - ftrace (
trappy.ftrace.FTrace
) – A ftrace object with a sched_switch event - pid (int) – The PID of the associated process
- sched_switch_class (
trappy.base.Base
) – The SchedSwitch event class
Returns: trappy.stats.Trigger.Trigger
on the SchedSwitch: IN for the given PID- ftrace (
-
bart.sched.functions.
sched_switch_out_trigger
(ftrace, pid, sched_switch_class)[source]¶ Parameters: - ftrace (
trappy.ftrace.FTrace
) – A ftrace object with a sched_switch event - pid (int) – The PID of the associated process
- sched_switch_class (
trappy.base.Base
) – The SchedSwitch event class
Returns: trappy.stats.Trigger.Trigger
on the SchedSwitch: OUT for the given PID- ftrace (
-
bart.sched.functions.
sched_triggers
(ftrace, pid, sched_switch_class)[source]¶ Returns the list of sched_switch triggers
Parameters: - ftrace (
trappy.ftrace.FTrace
) – A ftrace object with a sched_switch event - pid (int) – The PID of the associated process
- sched_switch_class (
trappy.base.Base
) – The SchedSwitch event class
Returns: List of triggers, such that
triggers[0] = switch_in_trigger triggers[1] = switch_out_trigger
- ftrace (
-
bart.sched.functions.
select_window
(series, window)[source]¶ Helper Function to select a portion of pandas time series
Parameters: - series (
pandas.Series
) – Input Time Series data - window (tuple) – A tuple indicating a time window
- series (
-
bart.sched.functions.
trace_event
(series, window=None)[source]¶ aggfunc()
to be used for plotting the process residency data usingtrappy.plotter.EventPlot
Parameters: - series (
pandas.Series
) – Input Time Series data - window (tuple) – A tuple indicating a time window
Returns: A list of events of the type:
[ [start_time_1, stop_time_1], [start_time_2, stop_time_2], # # [start_time_N, stop_time_N], ]
- series (