Class DataFlowTracker

class DataFlowTracker

The DataFlowTracker class is used to track the data flow metrics for different paths between the root operators and leaf operators. This class is used by the developers to get the metrics data for flow during the execution of the application and at the end of it.

This class uses mutex locks on metric properties so that multiple threads on multiple operators can update the metrics without conflicts.

Public Functions

inline DataFlowTracker()
~DataFlowTracker()
inline void set_skip_starting_messages(uint64_t num)

Set the number of messages to skip at the beginning of the execution.

This does not affect the log file or the number of source messages metric.

Parameters
void set_skip_latencies(int threshold)

Set the threshold latency for which the end-to-end latency calculations will be done. Any latency strictly less than the threshold latency will be ignored.

This does not affect the log file or the number of source messages metric.

Parameters
inline void set_discard_last_messages(uint64_t num)

Set the number of messages to discard at the end of the execution.

This does not affect the log file or the number of source messages metric.

Parameters
void enable_logging(std::string filename = kDefaultLogfileName, uint64_t num_buffered_messages = kDefaultNumBufferedMessages)

Enable message logging at the end of the every execution of a leaf Operator.

A path consisting of an array of tuples in the form of (an Operator name, message receive timestamp, message publish timestamp) is logged in a file. The logging does not take into account the number of message to skip or discard or the threshold latency.

This function buffers a number of lines set by the @num_buffered_messages parameter before flushing the buffer to the log file.

Parameters
void print() const
int get_num_paths()

Return the number of tracked paths.

Returns
std::vector<std::string> get_path_strings()

Return an array of strings which are path names. Each path name is a comma-separated list of Operator names in a path. The paths are agnostic to the edges between two Operators.

Returns
double get_metric(std::string pathstring, holoscan::DataFlowMetric metric)

Return the value of a metric m for a given path.

If m is DataFlowMetric::kNumSrcMessages, then the function returns -1.

Parameters
Returns
std::map<std::string, uint64_t> get_metric(holoscan::DataFlowMetric metric = DataFlowMetric::kNumSrcMessages)

Return the value of a metric.

The metric must be DataFlowMetric::kNumSrcMessages.

Parameters
Returns
void end_logging()

Protected Functions

void update_latency(std::string pathstring, double current_latency)

Update the tracker with the current latency for a given path.

The function internally takes care of skipping beginning messages or discarding last messages.

This function is not intended to be called by the developers. However, they may choose to update the latencies manually to account for some external overheads.

Parameters
void update_source_messages_number(std::string source, uint64_t num)

Update the tracker with the number of published messages for a given source Operator.

This function is not intended to be called by the developers. However, they may choose to update the number of messages externally.

Parameters
void write_to_logfile(std::string text)

Writes to a log file only if file logging is enabled. Otherwise, the function does nothing. It also takes care of buffering the messages and flushing them to the log file periodically.

Parameters

Friends

friend class DFFTCollector

© Copyright 2022-2023, NVIDIA. Last updated on Feb 9, 2024.