25 : getTimestamp(getTimestamp_),
26 getRealtimeBase(getRealtimeBase_),
35 if (spec.metricId == (
int)
id) {
36 return spec.name.c_str();
48 LOGP(
debug,
"MetricID {} is disabled", (
int)cmd.
id);
60 auto idx =
nextCmd.fetch_add(1, std::memory_order_relaxed);
61 if (idx ==
cmds.size()) {
64 while (
pendingCmds.load(std::memory_order_relaxed) > 0) {
69 std::this_thread::sleep_for(std::chrono::milliseconds(1));
73 nextCmd.store(0, std::memory_order_relaxed);
75 idx =
nextCmd.fetch_add(1, std::memory_order_relaxed);
76 }
else if (idx >
cmds.size()) {
79 std::this_thread::sleep_for(std::chrono::milliseconds(1));
80 idx =
nextCmd.load(std::memory_order_relaxed);
85 assert(idx <
cmds.size());
96 std::array<char, MAX_CMDS> order;
103 std::iota(order.begin(), order.begin() +
range, 0);
107 std::stable_sort(order.begin(), order.begin() +
range, [
this](
char a,
char b) {
108 return cmds[a].timestamp < cmds[b].timestamp;
120 if (cmd.value !=
metrics[cmd.id] && cmd.timestamp >= update.timestamp) {
123 update.timestamp = cmd.timestamp;
131 update.timestamp = cmd.timestamp;
139 update.timestamp = cmd.timestamp;
144 if (cmd.value >
metrics[cmd.id]) {
147 update.timestamp = cmd.timestamp;
152 if (cmd.value <
metrics[cmd.id]) {
155 update.timestamp = cmd.timestamp;
160 if (cmd.value > 0 && cmd.timestamp >= update.timestamp) {
163 update.timestamp = cmd.timestamp;
176 if (update.timestamp == 0) {
177 update.timestamp = cmd.timestamp;
190 if (update.timestamp == 0) {
191 update.timestamp = cmd.timestamp;
199 nextCmd.store(0, std::memory_order_relaxed);
212 if (spec.
name.empty()) {
216 LOGP(
debug,
"Metric {} is disabled", spec.
name);
221 update.timestamp = currentTimestamp;
231 LOGP(fatal,
"Metric {} has unknown kind", spec.
name);
234 if (currentTimestamp - update.timestamp == 0) {
235 callback(spec, update.timestamp, 0);
240 update.timestamp = currentTimestamp;
242 callback(spec, update.timestamp,
metrics[mi]);
246 update.lastPublished = currentTimestamp;
252 static int64_t startTime = uv_hrtime();
255 auto timeDelta = std::max(
int64_t(1), now - startTime);
259 LOGP(
debug,
"Publishing invoked {} times / s, {} metrics published / s", (
int)averageInvocations, (
int)averagePublishing);
264 if (spec.
name.size() == 0) {
274 auto currentMetric = std::find_if(
metricSpecs.begin(),
metricSpecs.end(), [&spec](
MetricSpec const&
s) { return s.name == spec.name && s.metricId != spec.metricId; });
276 throw runtime_error_f(
"Metric %s already registered with id %d. Cannot reregister with %d.", spec.
name.data(), currentMetric->metricId, spec.
metricId);
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
GLsizei GLenum const void GLuint GLsizei GLfloat * metrics
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
Defining ITS Vertex explicitly as messageable.
RuntimeErrorRef runtime_error(const char *)
RuntimeErrorRef runtime_error_f(const char *,...)
int64_t minOnlinePublishInterval
int64_t minPublishInterval
How many milliseconds must have passed since the last publishing.
int64_t defaultValue
The default value for the metric.
Kind kind
The kind of the metric.
uint64_t maxRefreshLatency
std::atomic< int > pendingCmds
std::array< bool, MAX_METRICS > updated
char const * findMetricNameById(ProcessingStatsId id) const
void registerMetric(MetricSpec const &spec)
std::array< MetricSpec, MAX_METRICS > metricSpecs
std::vector< int > availableMetrics
int64_t publishingInvokedTotal
std::function< int64_t(int64_t base, int64_t offset)> getTimestamp
std::atomic< int64_t > updatedMetricsLapse
@ SetIfPositive
Set the value to the specified value.
@ InstantaneousRate
Update the rate of the metric given the cumulative value since last time it got published.
@ Max
Subtract the value from the current value.
@ Min
Set the value to the maximum of the current value and the specified value.
@ CumulativeRate
Set the value to the specified value if it is positive.
@ Sub
Add the value to the current value.
@ Add
Update the rate of the metric given the amount since the last time.
void updateStats(CommandSpec cmd)
int64_t initialTimeOffset
std::array< std::string, MAX_METRICS > metricsNames
int64_t publishedMetricsLapse
std::array< Command, MAX_CMDS > cmds
std::atomic< int > nextCmd
std::atomic< int > insertedCmds
void flushChangedMetrics(std::function< void(MetricSpec const &, int64_t, int64_t)> const &callback)
std::array< int64_t, MAX_METRICS > lastPublishedMetrics
DataProcessingStats(std::function< void(int64_t &base, int64_t &offset)> getRealtimeBase, std::function< int64_t(int64_t base, int64_t offset)> getTimestamp, DefaultConfig config)
std::function< void(int64_t &base, int64_t &offset)> getRealtimeBase
void processCommandQueue()
std::array< UpdateInfo, MAX_METRICS > updateInfos
int64_t pushedMetricsLapse
int64_t publishingDoneTotal