NVIDIA Holoscan SDK v2.4.0
Holoscan v2.4.0

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

num – The number of messages to skip.

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

threshold – The threshold latency in milliseconds.

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

num – The number of messages to discard.

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
  • filename – The name of the log file.

  • num_buffered_messages – The number of messages to be buffered before flushing the buffer to the log file.

void print() const

Print the result of the data flow tracking in pretty-printed format to the standard output.

int get_num_paths()

Return the number of tracked paths.

Returns

The number of tracked paths.

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

An array of the path names.

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
  • pathstring – The path name string for which the metric is being queried.

  • metric – The metric to be queried.

Returns

The value of the metric m for the given path.

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

metric – The metric to be queried.

Returns

The map of source names to the number of published messages.

void end_logging()

Write out the remaining messages from the log buffer and close the ofstream.

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
  • pathstring – The path name string for which the latency is being updated.

  • current_latency – The current latency value.

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
  • source – The name of the source in the form of [OperatorName->OutputName].

  • num – The new number of published messages.

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

text – The new text to be written to the log file.

Friends

friend class DFFTCollector
friend class AnnotatedDoubleBufferReceiver

Previous Class DataExporter
Next Class DFFTCollector
© Copyright 2022-2024, NVIDIA. Last updated on Oct 1, 2024.