-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trigger latencies + monitoring (v5) #342
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ab5812e
latency test in RTCM
MRiganSUSX e6ef2a3
new latency class and first implementation
MRiganSUSX 210456d
Merge branch 'mrigan/new_opmon' into mrigan/new_latency
MRiganSUSX 54c6a8a
fixing merge mistake
MRiganSUSX 8e270a6
add tcproc proto
MRiganSUSX 84fe1fd
Merge branch 'develop' into mrigan/new_latency
MRiganSUSX a004b17
fixing running_flag globally
MRiganSUSX 3a51e70
adding latency to tcproc, mlt
MRiganSUSX 9155d64
fix for latency get functions and weird time cases
MRiganSUSX 6bd087c
adding comments to proto files
MRiganSUSX 0dcc5f2
reworking latency messages
MRiganSUSX 64e03f1
making latency monitoring configurable
MRiganSUSX ec83c08
making latency monitoring configurable
MRiganSUSX a1cbfc6
trigger latency configuration propagation
MRiganSUSX 8120c0a
adding the option for us precision in latency class
MRiganSUSX 0822cc0
fixing incorrect tlog
MRiganSUSX dc4ea9c
fix for latency class
MRiganSUSX 4201bdb
merging develop
MRiganSUSX bbddc50
some latency improvements
MRiganSUSX 6b33efd
small rework of latency class
MRiganSUSX 22f6687
latency: making micros the default
MRiganSUSX da978b7
simplifying latency monitoring
MRiganSUSX b05c8f2
Merge branch 'develop' into mrigan/new_latency
MRiganSUSX 45905a7
update for latencies for standalone makers
MRiganSUSX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* @file Latency.hpp | ||
* | ||
* This is part of the DUNE DAQ Application Framework, copyright 2021. | ||
* Licensing/copyright details are in the COPYING file that you should have | ||
* received with this code. | ||
*/ | ||
|
||
#ifndef TRIGGER_INCLUDE_TRIGGER_LATENCY_HPP_ | ||
#define TRIGGER_INCLUDE_TRIGGER_LATENCY_HPP_ | ||
|
||
#include "utilities/TimestampEstimator.hpp" | ||
#include "utilities/TimestampEstimatorSystem.hpp" | ||
|
||
#include <atomic> | ||
#include <chrono> | ||
#include <iostream> // Include for std::ostream | ||
|
||
namespace dunedaq { | ||
namespace trigger { | ||
|
||
class Latency { | ||
using latency = uint64_t; | ||
|
||
public: | ||
// Enumeration for selecting time units | ||
enum class TimeUnit { Microseconds = 1, Milliseconds = 2 }; | ||
|
||
// Constructor with optional time unit selection (defaults to Microseconds) | ||
Latency(TimeUnit time_unit = TimeUnit::Microseconds) | ||
: m_latency_in(0), m_latency_out(0), m_time_unit(time_unit) { | ||
setup_conversion(); | ||
} | ||
|
||
~Latency() {} | ||
|
||
// Function to update latency_in | ||
void update_latency_in(uint64_t latency) { | ||
update_single_latency(latency, m_latency_in); | ||
} | ||
|
||
// Function to update latency_out | ||
void update_latency_out(uint64_t latency) { | ||
update_single_latency(latency, m_latency_out); | ||
} | ||
|
||
// Function to get the value of latency_in | ||
latency get_latency_in() const { | ||
return m_latency_in.load(); | ||
} | ||
|
||
// Function to get the value of latency_out | ||
latency get_latency_out() const { | ||
return m_latency_out.load(); | ||
} | ||
|
||
private: | ||
// Set up conversion based on the selected time unit | ||
void setup_conversion() { | ||
if (m_time_unit == TimeUnit::Microseconds) { | ||
m_clock_ticks_conversion = 16 * 1e-3; // Conversion for microseconds | ||
m_get_current_time = []() { | ||
return std::chrono::duration_cast<std::chrono::microseconds>( | ||
std::chrono::system_clock::now().time_since_epoch()).count(); | ||
}; | ||
} else { | ||
m_clock_ticks_conversion = 16 * 1e-6; // Conversion for milliseconds | ||
m_get_current_time = []() { | ||
return std::chrono::duration_cast<std::chrono::milliseconds>( | ||
std::chrono::system_clock::now().time_since_epoch()).count(); | ||
}; | ||
} | ||
} | ||
|
||
// Function to get the current system time based on the set time unit | ||
uint64_t get_current_system_time() const { | ||
return m_get_current_time(); | ||
} | ||
|
||
// Single update function for both latencies | ||
void update_single_latency(uint64_t latency, std::atomic<uint64_t>& latency_atomic) { | ||
uint64_t current_time = get_current_system_time(); | ||
uint64_t latency_time = latency * m_clock_ticks_conversion; | ||
uint64_t diff = (current_time >= latency_time) ? (current_time - latency_time) : 0; | ||
latency_atomic.store(diff); | ||
} | ||
|
||
std::atomic<latency> m_latency_in; // Member variable to store latency_in | ||
std::atomic<latency> m_latency_out; // Member variable to store latency_out | ||
TimeUnit m_time_unit; // Member variable to store the selected time unit (ms or ns) | ||
double m_clock_ticks_conversion; // Conversion factor from ticks to the selected time unit | ||
|
||
// Lambda to get the current time | ||
std::function<uint64_t()> m_get_current_time; | ||
}; | ||
|
||
} // namespace trigger | ||
} // namespace dunedaq | ||
|
||
#endif // TRIGGER_INCLUDE_TRIGGER_LATENCY_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ RandomTCMakerModule::init(std::shared_ptr<appfwk::ModuleConfiguration> mcfg) | |
m_time_sync_source = get_iom_receiver<dfmessages::TimeSync>(con->UID()); | ||
} | ||
m_conf = mtrg->get_configuration(); | ||
m_latency_monitoring.store( m_conf->get_latency_monitoring() ); | ||
} | ||
|
||
void | ||
|
@@ -74,6 +75,14 @@ RandomTCMakerModule::generate_opmon_data() | |
info.set_tc_failed_sent_count( m_tc_failed_sent_count.load() ); | ||
|
||
this->publish(std::move(info)); | ||
|
||
if ( m_latency_monitoring.load() && m_running_flag.load() ) { | ||
opmon::TriggerLatencyStandalone lat_info; | ||
|
||
lat_info.set_latency_out( m_latency_instance.get_latency_out() ); | ||
|
||
this->publish(std::move(lat_info)); | ||
} | ||
} | ||
|
||
void | ||
|
@@ -89,6 +98,11 @@ RandomTCMakerModule::do_start(const nlohmann::json& obj) | |
|
||
m_running_flag.store(true); | ||
|
||
// OpMon. | ||
m_tc_made_count.store(0); | ||
m_tc_sent_count.store(0); | ||
m_tc_failed_sent_count.store(0); | ||
|
||
std::string timestamp_method = m_conf->get_timestamp_method(); | ||
if (timestamp_method == "kTimeSync") { | ||
TLOG_DEBUG(0) << "Creating TimestampEstimator"; | ||
|
@@ -208,11 +222,13 @@ RandomTCMakerModule::send_trigger_candidates() | |
} | ||
next_trigger_timestamp = m_timestamp_estimator->get_timestamp_estimate(); | ||
triggeralgs::TriggerCandidate candidate = create_candidate(next_trigger_timestamp); | ||
|
||
m_tc_made_count++; | ||
|
||
TLOG_DEBUG(1) << get_name() << " at timestamp " << m_timestamp_estimator->get_timestamp_estimate() | ||
<< ", pushing a candidate with timestamp " << candidate.time_candidate; | ||
|
||
if (m_latency_monitoring.load()) m_latency_instance.update_latency_out( candidate.time_candidate ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto here, we only need one latency in standalone makers, having in and out doesn't make sense, and will give identical numbers (unless we switch to nanoseconds or picoseconds. |
||
try{ | ||
m_trigger_candidate_sink->send(std::move(candidate), std::chrono::milliseconds(10)); | ||
m_tc_sent_count++; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
syntax = "proto3"; | ||
|
||
package dunedaq.trigger.opmon; | ||
|
||
// Message for latency variables | ||
// Latency represents the difference between current system (clock) time and the data time of particular (TX) data object | ||
// Units are us | ||
// Used by many trigger modules | ||
message TriggerLatency { | ||
uint32 latency_in = 1; | ||
uint32 latency_out = 2; | ||
} | ||
|
||
// Message for latency variables | ||
// Latency represents the difference between current system (clock) time and the data time of particular (TX) data object | ||
// Units are us | ||
// Special case for Standalone makers | ||
message TriggerLatencyStandalone { | ||
uint32 latency_out = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need both latency in and latency in and out here? The time difference here is literally the time taken to do
m_tc_made_count++
, which will be in nanoseconds. Out latency would be more than enough.I think in & out makes sense if we have some input data, a processing stage, and output data. In the standalone TC makers we just have the output data